Skip to content

Commit

Permalink
Add horrible workaround for a query panic
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadrieril committed Oct 31, 2024
1 parent 527951b commit b0d1bf7
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions frontend/exporter/src/types/new/full_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ where
Body: IsBody + TypeMappable,
{
let tcx = s.base().tcx;
let def_kind = tcx.def_kind(def_id);
let def_kind = get_def_kind(tcx, def_id);
let kind = {
let state_with_id = with_owner_id(s.base(), (), (), def_id);
def_kind.sinto(&state_with_id)
Expand Down Expand Up @@ -438,9 +438,20 @@ impl<Body: IsBody> FullDef<Body> {
}
}

/// Gets the kind of the definition.
#[cfg(feature = "rustc")]
pub fn get_def_kind<'tcx>(tcx: ty::TyCtxt<'tcx>, def_id: RDefId) -> RDefKind {
if def_id == rustc_span::def_id::CRATE_DEF_ID.to_def_id() {
// Horrible hack: without this, `def_kind` crashes on the crate root. Presumably some table
// isn't properly initialized otherwise.
let _ = tcx.def_span(def_id);
};
tcx.def_kind(def_id)
}

/// Gets the attributes of the definition.
#[cfg(feature = "rustc")]
fn get_def_span<'tcx>(
pub fn get_def_span<'tcx>(
tcx: ty::TyCtxt<'tcx>,
def_id: RDefId,
def_kind: RDefKind,
Expand Down

0 comments on commit b0d1bf7

Please sign in to comment.