Auto merge of #7021 - camsteffen:7012, r=giraffate

Fix ICE #7012

changelog: none

Fixes #7012
This commit is contained in:
bors 2021-04-04 23:51:31 +00:00
commit a15d987c8f
2 changed files with 25 additions and 6 deletions

View file

@ -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
},

View file

@ -0,0 +1,17 @@
#![allow(clippy::all)]
enum _MyOption {
None,
Some(()),
}
impl _MyOption {
fn _foo(&self) {
match self {
&Self::Some(_) => {},
_ => {},
}
}
}
fn main() {}