Skip to content

Conversation

camsteffen
Copy link
Contributor

changelog: none

Fixes #7012

@rust-highfive
Copy link

r? @giraffate

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Apr 2, 2021
@digama0
Copy link
Contributor

digama0 commented Apr 3, 2021

This fixes the ICE, but it looks like it might give the wrong result when Self is used in variants. Does this variation on the first example in match_wildcard_for_single_variants.rs correctly trigger the match_wildcard_for_single_variants lint?

#![warn(clippy::match_wildcard_for_single_variants)]
#![allow(dead_code)]

enum Color {
    Red,
    Green,
    Blue,
    Rgb(u8, u8, u8),
}
impl Color {
    fn f(&self) {
        match self {
            Self::Red => (),
            Self::Green => (),
            &Self::Rgb(_, _, _) => (),
            _ => (),
        };
    }
}

fn main() {}

@digama0
Copy link
Contributor

digama0 commented Apr 3, 2021

I think, instead of opt_def_id, it should match on if let Res::Def(_, id) | Res::SelfTy(_, Some((id, _))) = res, since opt_def_id returns None on SelfTy for some reason.

@camsteffen
Copy link
Contributor Author

camsteffen commented Apr 3, 2021

I'd like to just fix the ICE first. But feel free to file a bug and/or open a PR.

Copy link
Contributor

@giraffate giraffate left a comment

Choose a reason for hiding this comment

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

It looks good!

The test looks to fail because of formatting, so can you update on this?

@camsteffen
Copy link
Contributor Author

Oops. Fixed.

@giraffate
Copy link
Contributor

@bors r+

Thanks!

@bors
Copy link
Contributor

bors commented Apr 4, 2021

📌 Commit 7014340 has been approved by giraffate

@bors
Copy link
Contributor

bors commented Apr 4, 2021

⌛ Testing commit 7014340 with merge a15d987...

@bors
Copy link
Contributor

bors commented Apr 5, 2021

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: giraffate
Pushing a15d987 to master...

@bors bors merged commit a15d987 into rust-lang:master Apr 5, 2021
@camsteffen camsteffen deleted the 7012 branch July 8, 2021 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ICE in clippy_lints::matches::Matches
5 participants