Skip to content

Commit 08f1073

Browse files
committed
Auto merge of rust-lang#58501 - oli-obk:beta, r=eddyb
[beta] Fix `attempted .def_id() on invalid def: NonMacroAttr(Builtin)` backport of the fix so we can get update the bootstrap compiler to a compiler that has this fix. It's very hard to do development on stage 0/1 since resolve errors often end up with an ICE before outputting any useful diagnostics. cc @rust-lang/compiler @rust-lang/infra I would like to fast-track this backport as it severly hampers @varkor's and my rustc developments. The ICE never happens for successful compiles, only if there are errors. Since it is very minimalistic and can easily be reverted if desired I think/hope we can skip the usual beta nomination + beta accepted steps
2 parents b203178 + 81571bf commit 08f1073

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/librustc_typeck/check/method/suggest.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -750,12 +750,11 @@ fn compute_all_traits<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Vec<DefId>
750750
traits: &mut Vec<DefId>,
751751
external_mods: &mut FxHashSet<DefId>,
752752
def: Def) {
753-
let def_id = def.def_id();
754753
match def {
755-
Def::Trait(..) => {
754+
Def::Trait(def_id) => {
756755
traits.push(def_id);
757756
}
758-
Def::Mod(..) => {
757+
Def::Mod(def_id) => {
759758
if !external_mods.insert(def_id) {
760759
return;
761760
}

src/librustdoc/visit_lib.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,11 @@ impl<'a, 'tcx, 'rcx> LibEmbargoVisitor<'a, 'tcx, 'rcx> {
6060
}
6161

6262
for item in self.cx.tcx.item_children(def_id).iter() {
63-
if self.cx.tcx.def_key(item.def.def_id()).parent.map_or(false, |d| d == def_id.index) ||
64-
item.vis == Visibility::Public {
65-
self.visit_item(item.def);
63+
if let Some(def_id) = item.def.opt_def_id() {
64+
if self.cx.tcx.def_key(def_id).parent.map_or(false, |d| d == def_id.index) ||
65+
item.vis == Visibility::Public {
66+
self.visit_item(item.def);
67+
}
6668
}
6769
}
6870
}

0 commit comments

Comments
 (0)