cognitive-engineering-lab / aquascope

Interactive visualizations of Rust at compile-time and run-time
https://cognitive-engineering-lab.github.io/aquascope/
MIT License
1.94k stars 44 forks source link

Match operand expected permissions doesn't match branches #100

Open willcrichton opened 1 year ago

willcrichton commented 1 year ago

This program:

fn main() {
let opt: Option<String> = 
    Some(String::from("Hello world"));

match opt {
    Some(_) => println!("Some!"),
    None => println!("None!")
};

println!("{:?}", opt);
}

Is visualized with these permission:

Screen Shot 2023-08-08 at 3 48 30 PM

The match on opt should not require the own permission. Case in point, if you do let x = &opt and x is live across the match, the program still compiles.

willcrichton commented 1 year ago

Core issue is that match operand really only expects R for the discriminant operation. Any additional permission expectations should be placed on the patterns where things get bound.