Prevent promotion of const fn calls in inline consts

This commit is contained in:
Oli Scherer
2023-09-18 15:30:07 +00:00
parent 44e199bf30
commit 9c762b58ba
15 changed files with 41 additions and 23 deletions

View File

@@ -343,7 +343,7 @@ fn inner_mir_for_ctfe(tcx: TyCtxt<'_>, def: LocalDefId) -> Body<'_> {
let body = match tcx.hir().body_const_context(def) {
// consts and statics do not have `optimized_mir`, so we can steal the body instead of
// cloning it.
Some(hir::ConstContext::Const | hir::ConstContext::Static(_)) => body.steal(),
Some(hir::ConstContext::Const { .. } | hir::ConstContext::Static(_)) => body.steal(),
Some(hir::ConstContext::ConstFn) => body.borrow().clone(),
None => bug!("`mir_for_ctfe` called on non-const {def:?}"),
};