File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
compiler/rustc_mir/src/transform Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -734,7 +734,14 @@ impl<'tcx> Validator<'_, 'tcx> {
734734 ) -> Result < ( ) , Unpromotable > {
735735 let fn_ty = callee. ty ( self . body , self . tcx ) ;
736736
737- if !self . explicit && self . const_kind . is_none ( ) {
737+ // `const` and `static` use the explicit rules for promotion regardless of the `Candidate`,
738+ // meaning calls to `const fn` can be promoted.
739+ let context_uses_explicit_promotion_rules = matches ! (
740+ self . const_kind,
741+ Some ( hir:: ConstContext :: Static ( _) | hir:: ConstContext :: Const )
742+ ) ;
743+
744+ if !self . explicit && !context_uses_explicit_promotion_rules {
738745 if let ty:: FnDef ( def_id, _) = * fn_ty. kind ( ) {
739746 // Never promote runtime `const fn` calls of
740747 // functions without `#[rustc_promotable]`.
You can’t perform that action at this time.
0 commit comments