@@ -6,23 +6,6 @@ use rustc_middle::ty::TyCtxt;
66use rustc_span:: symbol:: Symbol ;
77use rustc_target:: spec:: abi:: Abi ;
88
9- /// Whether the `def_id` counts as const fn in your current crate, considering all active
10- /// feature gates
11- pub fn is_const_fn ( tcx : TyCtxt < ' _ > , def_id : DefId ) -> bool {
12- tcx. is_const_fn_raw ( def_id)
13- && match is_unstable_const_fn ( tcx, def_id) {
14- Some ( feature_name) => {
15- // has a `rustc_const_unstable` attribute, check whether the user enabled the
16- // corresponding feature gate.
17- tcx. features ( ) . declared_lib_features . iter ( ) . any ( |& ( sym, _) | sym == feature_name)
18- }
19- // functions without const stability are either stable user written
20- // const fn or the user is using feature gates and we thus don't
21- // care what they do
22- None => true ,
23- }
24- }
25-
269/// Whether the `def_id` is an unstable const fn and what feature gate is necessary to enable it
2710pub fn is_unstable_const_fn ( tcx : TyCtxt < ' _ > , def_id : DefId ) -> Option < Symbol > {
2811 if tcx. is_const_fn_raw ( def_id) {
@@ -77,7 +60,7 @@ fn is_const_fn_raw(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
7760}
7861
7962fn is_promotable_const_fn ( tcx : TyCtxt < ' _ > , def_id : DefId ) -> bool {
80- is_const_fn ( tcx , def_id)
63+ tcx . is_const_fn ( def_id)
8164 && match tcx. lookup_const_stability ( def_id) {
8265 Some ( stab) => {
8366 if cfg ! ( debug_assertions) && stab. promotable {
0 commit comments