hir_body_const_context should take LocalDefId
This commit is contained in:
parent
aa57e46e24
commit
a8ae2af967
2 changed files with 6 additions and 2 deletions
|
|
@ -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 },
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue