Skip to content

Commit f53fc41

Browse files
jhprattoli-obk
authored andcommitted
Fall back to being const-unstable when undeclared
1 parent 6913c74 commit f53fc41

File tree

1 file changed

+6
-19
lines changed
  • compiler/rustc_const_eval/src/transform/check_consts

1 file changed

+6
-19
lines changed

compiler/rustc_const_eval/src/transform/check_consts/mod.rs

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ pub fn rustc_allow_const_fn_unstable(
8484
// functions are subject to more stringent restrictions than "const-unstable" functions: They
8585
// cannot use unstable features and can only call other "const-stable" functions.
8686
pub fn is_const_stable_const_fn(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
87-
use attr::{ConstStability, Stability, StabilityLevel};
87+
use attr::{ConstStability, StabilityLevel};
8888

8989
// A default body marked const is not const-stable because const
9090
// 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 {
9696
// Const-stability is only relevant for `const fn`.
9797
assert!(tcx.is_const_fn_raw(def_id));
9898

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+
)
117104
}

0 commit comments

Comments
 (0)