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

Fix panic in match checking #4914

Merged
merged 2 commits into from Jun 17, 2020
Merged

Fix panic in match checking #4914

merged 2 commits into from Jun 17, 2020

Conversation

jonas-schievink
Copy link
Contributor

Fixes #4416

@jonas-schievink
Copy link
Contributor Author

Looks like there's another panic that this doesn't fix:

pub enum Category {
    Infinity,
    Zero,
}

fn panic(a: Category, b: Category) {
    match (a, b) {
        (Category::Infinity, Category::Infinity) | (Category::Zero, Category::Zero) => {}

        (Category::Infinity | Category::Zero, _) => {}
    }
}

Fixing that one causes a spurious "missing match arm" diagnostic that I'm not sure how to fix.

@matklad
Copy link
Member

matklad commented Jun 17, 2020

r? @flodiebold

Copy link
Member

@flodiebold flodiebold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bors r+

}

#[test]
fn expr_loop_missing_arm() {
let content = r"
// This is a false negative.
// We currently infer the type of `loop { break Foo::A }` to `!`, which
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we do support break-with-value now, the problem in this test is that Foo doesn't exist.

@flodiebold
Copy link
Member

I don't have the match checking algorithm in cache enough to see how that other example would crash or give a spurious error 😅

@bors
Copy link
Contributor

bors bot commented Jun 17, 2020

@bors bors bot merged commit 09c5cfe into rust-lang:master Jun 17, 2020
@jonas-schievink jonas-schievink deleted the matchck branch June 17, 2020 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Index out of bounds in _match::is_useful
3 participants