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