Skip to content

INSP: Add E0510 check #1

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
wants to merge 3 commits into from
Closed

INSP: Add E0510 check #1

wants to merge 3 commits into from

Conversation

kuksag
Copy link
Owner

@kuksag kuksag commented Nov 21, 2022

changelog:

@kuksag
Copy link
Owner Author

kuksag commented Nov 22, 2022

There's a false negative for situation like rust-lang/rust#27282 (mutation through lambda):

{
    let mut x = &mut &Some(&2);
    match **x {
        None => panic!("unreachable"),
        Some(&_) if {
            (|| { *x = &None; })();
            //~^ ERROR cannot mutably borrow `x` in match guard [E0510]
            false
        } => {}
        Some(&a) if { // this binds to garbage if we've corrupted discriminant
            println!("{}", a);
            panic!()
        } => {}
        _ => panic!("unreachable"),
    }
}

@kuksag kuksag closed this Nov 24, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant