diff options
| author | bors <bors@rust-lang.org> | 2021-04-04 23:51:31 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-04-04 23:51:31 +0000 |
| commit | a15d987c8f9c0c9e911f112d21d55e36da3df370 (patch) | |
| tree | 7941aacdb8603f1a84a515bc72aabcb12e79c9db | |
| parent | 6bb608c00cb2d4bf76b3e90f6c1adb78fbf802eb (diff) | |
| parent | 7014340d5713b9401d95a5ca3287163fd407da46 (diff) | |
| download | rust-a15d987c8f9c0c9e911f112d21d55e36da3df370.tar.gz rust-a15d987c8f9c0c9e911f112d21d55e36da3df370.zip | |
Auto merge of #7021 - camsteffen:7012, r=giraffate
Fix ICE #7012 changelog: none Fixes #7012
| -rw-r--r-- | clippy_lints/src/matches.rs | 14 | ||||
| -rw-r--r-- | tests/ui/crashes/ice-7012.rs | 17 |
2 files changed, 25 insertions, 6 deletions
diff --git a/clippy_lints/src/matches.rs b/clippy_lints/src/matches.rs index b13db4cd45c..ba49097fd3b 100644 --- a/clippy_lints/src/matches.rs +++ b/clippy_lints/src/matches.rs @@ -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 }, diff --git a/tests/ui/crashes/ice-7012.rs b/tests/ui/crashes/ice-7012.rs new file mode 100644 index 00000000000..60bdbc4f124 --- /dev/null +++ b/tests/ui/crashes/ice-7012.rs @@ -0,0 +1,17 @@ +#![allow(clippy::all)] + +enum _MyOption { + None, + Some(()), +} + +impl _MyOption { + fn _foo(&self) { + match self { + &Self::Some(_) => {}, + _ => {}, + } + } +} + +fn main() {} |
