This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +22
-7
lines changed
rustc_const_eval/src/check_consts
tests/ui/consts/min_const_fn Expand file tree Collapse file tree 3 files changed +22
-7
lines changed Original file line number Diff line number Diff line change @@ -868,9 +868,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
868868 // Calling an unstable function *always* requires that the corresponding gate
869869 // (or implied gate) be enabled, even if the function has
870870 // `#[rustc_allow_const_fn_unstable(the_gate)]`.
871- let gate_declared = |gate| {
872- tcx. features ( ) . declared_lib_features . iter ( ) . any ( |& ( sym, _) | sym == gate)
873- } ;
871+ let gate_declared = |gate| tcx. features ( ) . declared ( gate) ;
874872 let feature_gate_declared = gate_declared ( gate) ;
875873 let implied_gate_declared = implied_by. is_some_and ( gate_declared) ;
876874 if !feature_gate_declared && !implied_gate_declared {
Original file line number Diff line number Diff line change @@ -3089,10 +3089,7 @@ impl<'tcx> TyCtxt<'tcx> {
30893089 Some ( stability) if stability. is_const_unstable ( ) => {
30903090 // has a `rustc_const_unstable` attribute, check whether the user enabled the
30913091 // corresponding feature gate.
3092- self . features ( )
3093- . declared_lib_features
3094- . iter ( )
3095- . any ( |& ( sym, _) | sym == stability. feature )
3092+ self . features ( ) . declared ( stability. feature )
30963093 }
30973094 // functions without const stability are either stable user written
30983095 // const fn or the user is using feature gates and we thus don't
Original file line number Diff line number Diff line change 1+ //! Ensure that we can use a language feature with a `const fn`:
2+ //! enabling the feature gate actually lets us call the function.
3+ //@ check-pass
4+
5+ #![ feature( staged_api, abi_unadjusted) ]
6+ #![ stable( feature = "rust_test" , since = "1.0.0" ) ]
7+
8+ #[ unstable( feature = "abi_unadjusted" , issue = "42" ) ]
9+ #[ rustc_const_unstable( feature = "abi_unadjusted" , issue = "42" ) ]
10+ const fn my_fun ( ) { }
11+
12+ #[ unstable( feature = "abi_unadjusted" , issue = "42" ) ]
13+ #[ rustc_const_unstable( feature = "abi_unadjusted" , issue = "42" ) ]
14+ const fn my_fun2 ( ) {
15+ my_fun ( )
16+ }
17+
18+ fn main ( ) {
19+ const { my_fun2 ( ) } ;
20+ }
You can’t perform that action at this time.
0 commit comments