Skip to content

Commit

Permalink
Auto merge of rust-lang#7021 - camsteffen:7012, r=giraffate
Browse files Browse the repository at this point in the history
Fix ICE rust-lang#7012

changelog: none

Fixes rust-lang#7012
  • Loading branch information
bors committed Apr 4, 2021
2 parents 6bb608c + 7014340 commit a15d987
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
14 changes: 8 additions & 6 deletions clippy_lints/src/matches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1046,16 +1046,18 @@ fn check_wild_enum_match(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>])
path
},
PatKind::TupleStruct(path, patterns, ..) => {
if arm.guard.is_none() && patterns.iter().all(|p| !is_refutable(cx, p)) {
let id = cx.qpath_res(path, pat.hir_id).def_id();
missing_variants.retain(|e| e.ctor_def_id != Some(id));
if let Some(id) = cx.qpath_res(path, pat.hir_id).opt_def_id() {
if arm.guard.is_none() && patterns.iter().all(|p| !is_refutable(cx, p)) {
missing_variants.retain(|e| e.ctor_def_id != Some(id));
}
}
path
},
PatKind::Struct(path, patterns, ..) => {
if arm.guard.is_none() && patterns.iter().all(|p| !is_refutable(cx, p.pat)) {
let id = cx.qpath_res(path, pat.hir_id).def_id();
missing_variants.retain(|e| e.def_id != id);
if let Some(id) = cx.qpath_res(path, pat.hir_id).opt_def_id() {
if arm.guard.is_none() && patterns.iter().all(|p| !is_refutable(cx, p.pat)) {
missing_variants.retain(|e| e.def_id != id);
}
}
path
},
Expand Down
17 changes: 17 additions & 0 deletions tests/ui/crashes/ice-7012.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#![allow(clippy::all)]

enum _MyOption {
None,
Some(()),
}

impl _MyOption {
fn _foo(&self) {
match self {
&Self::Some(_) => {},
_ => {},
}
}
}

fn main() {}

0 comments on commit a15d987

Please sign in to comment.