Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

MIR borrowck: errors unreported in unreachable arms of match expressions #45043

Closed
zilbuz opened this issue Oct 5, 2017 · 1 comment · Fixed by #45384
Closed

MIR borrowck: errors unreported in unreachable arms of match expressions #45043

zilbuz opened this issue Oct 5, 2017 · 1 comment · Fixed by #45384
Labels
A-borrow-checker Area: The borrow checker

Comments

@zilbuz
Copy link
Contributor

zilbuz commented Oct 5, 2017

Note from @pnkfelix for people looking at this bug: See important soundness issue in ariel's issue.

In the following code the borrow error in the z arm isn't reported with MIR borrowck, but it is reported with AST borrowck:

fn main() {
    let mut x = 1;
    let _x = &mut x;
    match x {
        y => println!("y: {}", y), // Error in AST and MIR
        z => println!("z: {}", z), // Error only in AST
    }
}

(compile with -Z emit-end-regions -Z borrowck-mir to use the MIR borrowck)

@arielb1 arielb1 changed the title MIR borrowck: errors unreported in unreachable arms of match expressions binding-less matches on borrowed data are incorrectly allowed Oct 5, 2017
@arielb1 arielb1 added A-borrow-checker Area: The borrow checker I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness labels Oct 5, 2017
@arielb1 arielb1 changed the title binding-less matches on borrowed data are incorrectly allowed MIR borrowck: errors unreported in unreachable arms of match expressions Oct 5, 2017
@arielb1 arielb1 removed the I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness label Oct 5, 2017
@mikhail-m1
Copy link
Contributor

mikhail-m1 commented Oct 9, 2017

my idea of fix mikhail-m1@ff15f84, it works but doesn't finished

bors added a commit that referenced this issue Oct 15, 2017
MIR-borrowck: add false edges to match arms

basic fix for #45043, should be modified with #45184
bors added a commit that referenced this issue Nov 2, 2017
…, r=arielb1

add TerminatorKind::FalseEdges and use it in matches

impl #45184 and fixes #45043 right way.

False edges unexpectedly affects uninitialized variables analysis in MIR borrowck.
bors added a commit that referenced this issue Nov 4, 2017
…, r=arielb1

add TerminatorKind::FalseEdges and use it in matches

impl #45184 and fixes #45043 right way.

False edges unexpectedly affects uninitialized variables analysis in MIR borrowck.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-borrow-checker Area: The borrow checker
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants