We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
rest_when_destructuring_struct
1 parent d924014 commit 6d3f235Copy full SHA for 6d3f235
clippy_lints/src/rest_when_destructuring_struct.rs
@@ -1,6 +1,7 @@
1
use crate::rustc_lint::LintContext as _;
2
use clippy_utils::diagnostics::span_lint_and_then;
3
use itertools::Itertools;
4
+use rustc_abi::VariantIdx;
5
use rustc_lint::LateLintPass;
6
use rustc_middle::ty;
7
use rustc_session::declare_lint_pass;
@@ -53,7 +54,9 @@ impl<'tcx> LateLintPass<'tcx> for RestWhenDestructuringStruct {
53
54
let qty = cx.typeck_results().qpath_res(&path, pat.hir_id);
55
let ty = cx.typeck_results().pat_ty(pat);
56
if let ty::Adt(a, _) = ty.kind() {
- let vid = a.variant_index_with_id(qty.def_id());
57
+ let vid = qty
58
+ .opt_def_id()
59
+ .map_or(VariantIdx::ZERO, |x| a.variant_index_with_id(x));
60
let mut rest_fields = a.variants()[vid]
61
.fields
62
.iter()
0 commit comments