diff options
| author | Michael Goulet <michael@errs.io> | 2025-05-25 14:32:47 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2025-05-25 15:57:24 +0000 |
| commit | a8ae2af9670635a9138429ccba1ffb76787afbb1 (patch) | |
| tree | e8ff212c01c4754e8e043eb8eb4f1af621b81185 /compiler | |
| parent | aa57e46e24a4a08cc336325e92567b40b0c2ba62 (diff) | |
| download | rust-a8ae2af9670635a9138429ccba1ffb76787afbb1.tar.gz rust-a8ae2af9670635a9138429ccba1ffb76787afbb1.zip | |
hir_body_const_context should take LocalDefId
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_middle/src/hir/map.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/mir/pretty.rs | 6 |
2 files changed, 6 insertions, 2 deletions
diff --git a/compiler/rustc_middle/src/hir/map.rs b/compiler/rustc_middle/src/hir/map.rs index fee707f7b4c..9c8f1c9eccf 100644 --- a/compiler/rustc_middle/src/hir/map.rs +++ b/compiler/rustc_middle/src/hir/map.rs @@ -310,7 +310,7 @@ impl<'tcx> TyCtxt<'tcx> { /// This should only be used for determining the context of a body, a return /// value of `Some` does not always suggest that the owner of the body is `const`, /// just that it has to be checked as if it were. - pub fn hir_body_const_context(self, def_id: impl Into<DefId>) -> Option<ConstContext> { + pub fn hir_body_const_context(self, def_id: LocalDefId) -> Option<ConstContext> { let def_id = def_id.into(); let ccx = match self.hir_body_owner_kind(def_id) { BodyOwnerKind::Const { inline } => ConstContext::Const { inline }, diff --git a/compiler/rustc_middle/src/mir/pretty.rs b/compiler/rustc_middle/src/mir/pretty.rs index 57ae7dc55c5..6b262a27500 100644 --- a/compiler/rustc_middle/src/mir/pretty.rs +++ b/compiler/rustc_middle/src/mir/pretty.rs @@ -1624,7 +1624,11 @@ pub fn write_allocations<'tcx>( Some(GlobalAlloc::Static(did)) if !tcx.is_foreign_item(did) => { write!(w, " (static: {}", tcx.def_path_str(did))?; if body.phase <= MirPhase::Runtime(RuntimePhase::PostCleanup) - && tcx.hir_body_const_context(body.source.def_id()).is_some() + && body + .source + .def_id() + .as_local() + .is_some_and(|def_id| tcx.hir_body_const_context(def_id).is_some()) { // Statics may be cyclic and evaluating them too early // in the MIR pipeline may cause cycle errors even though |
