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

@@ -644,7 +644,7 @@ impl<'tcx> Validator<'_, 'tcx> {
// Everywhere else, we require `#[rustc_promotable]` on the callee.
let promote_all_const_fn = matches!(
self.const_kind,
Some(hir::ConstContext::Static(_) | hir::ConstContext::Const)
Some(hir::ConstContext::Static(_) | hir::ConstContext::Const { inline: false })
);
if !promote_all_const_fn {
if let ty::FnDef(def_id, _) = *fn_ty.kind() {