@@ -40,19 +40,24 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
40
40
41
41
/// Returns true if this function must conform to `min_const_fn`
42
42
pub fn is_min_const_fn ( self , def_id : DefId ) -> bool {
43
- if self . features ( ) . staged_api {
44
- // some intrinsics are waved through if called inside the
45
- // standard library. Users never need to call them directly
46
- if let abi:: Abi :: RustIntrinsic = self . fn_sig ( def_id) . abi ( ) {
47
- assert ! ( !self . is_const_fn( def_id) ) ;
48
- match & self . item_name ( def_id) . as_str ( ) [ ..] {
49
- | "size_of"
50
- | "min_align_of"
51
- | "needs_drop"
52
- => return true ,
53
- _ => { } ,
54
- }
43
+ // some intrinsics are waved through if called inside the
44
+ // standard library. Users never need to call them directly
45
+ if let abi:: Abi :: RustIntrinsic = self . fn_sig ( def_id) . abi ( ) {
46
+ match & self . item_name ( def_id) . as_str ( ) [ ..] {
47
+ | "size_of"
48
+ | "min_align_of"
49
+ | "needs_drop"
50
+ => return true ,
51
+ _ => { } ,
55
52
}
53
+ }
54
+
55
+ // Bail out if the signature doesn't contain `const`
56
+ if !self . is_const_fn_raw ( def_id) {
57
+ return false ;
58
+ }
59
+
60
+ if self . features ( ) . staged_api {
56
61
// in order for a libstd function to be considered min_const_fn
57
62
// it needs to be stable and have no `rustc_const_unstable` attribute
58
63
self . is_const_fn_raw ( def_id) && match self . lookup_stability ( def_id) {
@@ -66,7 +71,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
66
71
}
67
72
} else {
68
73
// users enabling the `const_fn` feature gate can do what they want
69
- self . is_const_fn_raw ( def_id ) && !self . features ( ) . const_fn
74
+ !self . features ( ) . const_fn
70
75
}
71
76
}
72
77
}
0 commit comments