diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index aa6f73b29b4b5..b3248018b5529 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -752,12 +752,11 @@ fn compute_all_traits<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Vec traits: &mut Vec, external_mods: &mut FxHashSet, def: Def) { - let def_id = def.def_id(); match def { - Def::Trait(..) => { + Def::Trait(def_id) => { traits.push(def_id); } - Def::Mod(..) => { + Def::Mod(def_id) => { if !external_mods.insert(def_id) { return; } diff --git a/src/librustdoc/visit_lib.rs b/src/librustdoc/visit_lib.rs index 7413a917f0563..bd5cae861e93b 100644 --- a/src/librustdoc/visit_lib.rs +++ b/src/librustdoc/visit_lib.rs @@ -60,9 +60,11 @@ impl<'a, 'tcx, 'rcx> LibEmbargoVisitor<'a, 'tcx, 'rcx> { } for item in self.cx.tcx.item_children(def_id).iter() { - if self.cx.tcx.def_key(item.def.def_id()).parent.map_or(false, |d| d == def_id.index) || - item.vis == Visibility::Public { - self.visit_item(item.def); + if let Some(def_id) = item.def.opt_def_id() { + if self.cx.tcx.def_key(def_id).parent.map_or(false, |d| d == def_id.index) || + item.vis == Visibility::Public { + self.visit_item(item.def); + } } } }