1
Fork 0

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

@ -167,7 +167,7 @@ impl<'mir, 'tcx> Qualifs<'mir, 'tcx> {
false
}
hir::ConstContext::Const | hir::ConstContext::Static(_) => {
hir::ConstContext::Const { .. } | hir::ConstContext::Static(_) => {
let mut cursor = FlowSensitiveAnalysis::new(CustomEq, ccx)
.into_engine(ccx.tcx, &ccx.body)
.iterate_to_fixpoint()

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() {