Skip to content

Fix using lang features in #[rustc_const_unstable] #129679

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions compiler/rustc_const_eval/src/check_consts/check.rs
Original file line number Diff line number Diff line change
@@ -868,9 +868,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
// Calling an unstable function *always* requires that the corresponding gate
// (or implied gate) be enabled, even if the function has
// `#[rustc_allow_const_fn_unstable(the_gate)]`.
let gate_declared = |gate| {
tcx.features().declared_lib_features.iter().any(|&(sym, _)| sym == gate)
};
let gate_declared = |gate| tcx.features().declared(gate);
let feature_gate_declared = gate_declared(gate);
let implied_gate_declared = implied_by.is_some_and(gate_declared);
if !feature_gate_declared && !implied_gate_declared {
15 changes: 15 additions & 0 deletions tests/ui/stability-attribute/const-stability-lang-feature.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//@ check-pass

#![crate_type = "lib"]
#![feature(staged_api)]
#![unstable(feature = "staged_api", issue = "none")]

#[unstable(feature = "staged_api", issue = "none")]
#[rustc_const_unstable(feature = "staged_api", issue = "none")]
const fn callee() {}

#[unstable(feature = "staged_api", issue = "none")]
#[rustc_const_unstable(feature = "staged_api", issue = "none")]
const fn caller() {
callee();
}