diff options
Diffstat (limited to 'compiler/rustc_passes/src/dead.rs')
-rw-r--r-- | compiler/rustc_passes/src/dead.rs | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/compiler/rustc_passes/src/dead.rs b/compiler/rustc_passes/src/dead.rs index 1e2fbeb38..f141d7bee 100644 --- a/compiler/rustc_passes/src/dead.rs +++ b/compiler/rustc_passes/src/dead.rs @@ -226,19 +226,16 @@ impl<'tcx> MarkSymbolVisitor<'tcx> { lhs: &hir::Pat<'_>, res: Res, pats: &[hir::Pat<'_>], - dotdot: Option<usize>, + dotdot: hir::DotDotPos, ) { let variant = match self.typeck_results().node_type(lhs.hir_id).kind() { ty::Adt(adt, _) => adt.variant_of_res(res), _ => span_bug!(lhs.span, "non-ADT in tuple struct pattern"), }; - let first_n = pats.iter().enumerate().take(dotdot.unwrap_or(pats.len())); + let dotdot = dotdot.as_opt_usize().unwrap_or(pats.len()); + let first_n = pats.iter().enumerate().take(dotdot); let missing = variant.fields.len() - pats.len(); - let last_n = pats - .iter() - .enumerate() - .skip(dotdot.unwrap_or(pats.len())) - .map(|(idx, pat)| (idx + missing, pat)); + let last_n = pats.iter().enumerate().skip(dotdot).map(|(idx, pat)| (idx + missing, pat)); for (idx, pat) in first_n.chain(last_n) { if let PatKind::Wild = pat.kind { continue; @@ -368,14 +365,7 @@ impl<'tcx> Visitor<'tcx> for MarkSymbolVisitor<'tcx> { self.maybe_typeck_results = old_maybe_typeck_results; } - fn visit_variant_data( - &mut self, - def: &'tcx hir::VariantData<'tcx>, - _: Symbol, - _: &hir::Generics<'_>, - _: hir::HirId, - _: rustc_span::Span, - ) { + fn visit_variant_data(&mut self, def: &'tcx hir::VariantData<'tcx>) { let tcx = self.tcx; let has_repr_c = self.repr_has_repr_c; let has_repr_simd = self.repr_has_repr_simd; @@ -457,7 +447,7 @@ impl<'tcx> Visitor<'tcx> for MarkSymbolVisitor<'tcx> { } fn visit_ty(&mut self, ty: &'tcx hir::Ty<'tcx>) { - if let TyKind::OpaqueDef(item_id, _) = ty.kind { + if let TyKind::OpaqueDef(item_id, _, _) = ty.kind { let item = self.tcx.hir().item(item_id); intravisit::walk_item(self, item); } |