@@ -86,7 +86,7 @@ pub fn rustc_allow_const_fn_unstable(tcx: TyCtxt<'_>, def_id: DefId, feature_gat
8686// functions are subject to more stringent restrictions than "const-unstable" functions: They
8787// cannot use unstable features and can only call other "const-stable" functions.
8888pub fn is_const_stable_const_fn ( tcx : TyCtxt < ' _ > , def_id : DefId ) -> bool {
89- use attr:: { ConstStability , Stability , StabilityLevel } ;
89+ use attr:: { ConstStability , StabilityLevel } ;
9090
9191 // A default body marked const is not const-stable because const
9292 // trait fns currently cannot be const-stable. We shouldn't
@@ -98,22 +98,9 @@ pub fn is_const_stable_const_fn(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
9898 // Const-stability is only relevant for `const fn`.
9999 assert ! ( tcx. is_const_fn_raw( def_id) ) ;
100100
101- // Functions with `#[rustc_const_unstable]` are const-unstable.
102- match tcx. lookup_const_stability ( def_id) {
103- Some ( ConstStability { level : StabilityLevel :: Unstable { .. } , .. } ) => return false ,
104- Some ( ConstStability { level : StabilityLevel :: Stable { .. } , .. } ) => return true ,
105- None => { }
106- }
107-
108- // Functions with `#[unstable]` are const-unstable.
109- //
110- // FIXME(ecstaticmorse): We should keep const-stability attributes wholly separate from normal stability
111- // attributes. `#[unstable]` should be irrelevant.
112- if let Some ( Stability { level : StabilityLevel :: Unstable { .. } , .. } ) =
113- tcx. lookup_stability ( def_id)
114- {
115- return false ;
116- }
117-
118- true
101+ // A function is only const-stable if it has `#[rustc_const_stable]`.
102+ matches ! (
103+ tcx. lookup_const_stability( def_id) ,
104+ Some ( ConstStability { level: StabilityLevel :: Stable { .. } , .. } )
105+ )
119106}
0 commit comments