|
1 |
| -use rustc_attr as attr; |
2 | 1 | use rustc_hir as hir;
|
3 | 2 | use rustc_hir::def_id::{DefId, LocalDefId};
|
4 | 3 | use rustc_middle::hir::map::blocks::FnLikeNode;
|
@@ -34,54 +33,6 @@ pub fn is_unstable_const_fn(tcx: TyCtxt<'_>, def_id: DefId) -> Option<Symbol> {
|
34 | 33 | }
|
35 | 34 | }
|
36 | 35 |
|
37 |
| -/// Returns `true` if this function must conform to `min_const_fn` |
38 |
| -pub fn is_min_const_fn(tcx: TyCtxt<'_>, def_id: DefId) -> bool { |
39 |
| - // Bail out if the signature doesn't contain `const` |
40 |
| - if !tcx.is_const_fn_raw(def_id) { |
41 |
| - return false; |
42 |
| - } |
43 |
| - |
44 |
| - if tcx.features().staged_api { |
45 |
| - // In order for a libstd function to be considered min_const_fn |
46 |
| - // it needs to be stable and have no `rustc_const_unstable` attribute. |
47 |
| - match tcx.lookup_const_stability(def_id) { |
48 |
| - // `rustc_const_unstable` functions don't need to conform. |
49 |
| - Some(&attr::ConstStability { ref level, .. }) if level.is_unstable() => false, |
50 |
| - None => { |
51 |
| - if let Some(stab) = tcx.lookup_stability(def_id) { |
52 |
| - if stab.level.is_stable() { |
53 |
| - tcx.sess.delay_span_bug( |
54 |
| - tcx.def_span(def_id), |
55 |
| - "stable const functions must have either `rustc_const_stable` or \ |
56 |
| - `rustc_const_unstable` attribute", |
57 |
| - ); |
58 |
| - // While we errored above, because we don't know if we need to conform, we |
59 |
| - // err on the "safe" side and require min_const_fn. |
60 |
| - true |
61 |
| - } else { |
62 |
| - // Unstable functions need not conform to min_const_fn. |
63 |
| - false |
64 |
| - } |
65 |
| - } else { |
66 |
| - // Internal functions are forced to conform to min_const_fn. |
67 |
| - // Annotate the internal function with a const stability attribute if |
68 |
| - // you need to use unstable features. |
69 |
| - // Note: this is an arbitrary choice that does not affect stability or const |
70 |
| - // safety or anything, it just changes whether we need to annotate some |
71 |
| - // internal functions with `rustc_const_stable` or with `rustc_const_unstable` |
72 |
| - true |
73 |
| - } |
74 |
| - } |
75 |
| - // Everything else needs to conform, because it would be callable from |
76 |
| - // other `min_const_fn` functions. |
77 |
| - _ => true, |
78 |
| - } |
79 |
| - } else { |
80 |
| - // users enabling the `const_fn` feature gate can do what they want |
81 |
| - !tcx.features().const_fn |
82 |
| - } |
83 |
| -} |
84 |
| - |
85 | 36 | pub fn is_parent_const_impl_raw(tcx: TyCtxt<'_>, hir_id: hir::HirId) -> bool {
|
86 | 37 | let parent_id = tcx.hir().get_parent_did(hir_id);
|
87 | 38 | if !parent_id.is_top_level_module() { is_const_impl_raw(tcx, parent_id) } else { false }
|
|
0 commit comments