@@ -86,7 +86,7 @@ pub fn rustc_allow_const_fn_unstable(tcx: TyCtxt<'_>, def_id: DefId, feature_gat
86
86
// functions are subject to more stringent restrictions than "const-unstable" functions: They
87
87
// cannot use unstable features and can only call other "const-stable" functions.
88
88
pub fn is_const_stable_const_fn ( tcx : TyCtxt < ' _ > , def_id : DefId ) -> bool {
89
- use attr:: { ConstStability , Stability , StabilityLevel } ;
89
+ use attr:: { ConstStability , StabilityLevel } ;
90
90
91
91
// A default body marked const is not const-stable because const
92
92
// 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 {
98
98
// Const-stability is only relevant for `const fn`.
99
99
assert ! ( tcx. is_const_fn_raw( def_id) ) ;
100
100
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
+ )
119
106
}
0 commit comments