Skip to content

Commit a8ae2af

Browse files
hir_body_const_context should take LocalDefId
1 parent aa57e46 commit a8ae2af

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

compiler/rustc_middle/src/hir/map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ impl<'tcx> TyCtxt<'tcx> {
310310
/// This should only be used for determining the context of a body, a return
311311
/// value of `Some` does not always suggest that the owner of the body is `const`,
312312
/// just that it has to be checked as if it were.
313-
pub fn hir_body_const_context(self, def_id: impl Into<DefId>) -> Option<ConstContext> {
313+
pub fn hir_body_const_context(self, def_id: LocalDefId) -> Option<ConstContext> {
314314
let def_id = def_id.into();
315315
let ccx = match self.hir_body_owner_kind(def_id) {
316316
BodyOwnerKind::Const { inline } => ConstContext::Const { inline },

compiler/rustc_middle/src/mir/pretty.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1624,7 +1624,11 @@ pub fn write_allocations<'tcx>(
16241624
Some(GlobalAlloc::Static(did)) if !tcx.is_foreign_item(did) => {
16251625
write!(w, " (static: {}", tcx.def_path_str(did))?;
16261626
if body.phase <= MirPhase::Runtime(RuntimePhase::PostCleanup)
1627-
&& tcx.hir_body_const_context(body.source.def_id()).is_some()
1627+
&& body
1628+
.source
1629+
.def_id()
1630+
.as_local()
1631+
.is_some_and(|def_id| tcx.hir_body_const_context(def_id).is_some())
16281632
{
16291633
// Statics may be cyclic and evaluating them too early
16301634
// in the MIR pipeline may cause cycle errors even though

0 commit comments

Comments
 (0)