add rustc_allow_const_fn_unstable attribute
allow_internal_unstable is currently used to side-step feature gate and stability checks. While it was originally only meant to be used only on macros, its use was expanded to const functions. This commit prepares stricter checks for the usage of allow_internal_unstable (only on macros) and introduces the rustc_allow_const_fn_unstable attribute for usage on functions. See rust-lang/rust#69399
This commit is contained in:
parent
554633534c
commit
3948b054dc
@ -210,6 +210,11 @@ declare_features! (
|
||||
/// it is not on path for eventual stabilization).
|
||||
(active, no_niche, "1.42.0", None, None),
|
||||
|
||||
/// Allows using `#[rustc_allow_const_fn_unstable]`.
|
||||
/// This is an attribute on `const fn` for the same
|
||||
/// purpose as `#[allow_internal_unstable]`.
|
||||
(active, rustc_allow_const_fn_unstable, "1.49.0", Some(69399), None),
|
||||
|
||||
// no-tracking-issue-end
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
@ -379,6 +379,10 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
|
||||
allow_internal_unstable, AssumedUsed, template!(Word, List: "feat1, feat2, ..."),
|
||||
"allow_internal_unstable side-steps feature gating and stability checks",
|
||||
),
|
||||
gated!(
|
||||
rustc_allow_const_fn_unstable, AssumedUsed, template!(Word, List: "feat1, feat2, ..."),
|
||||
"rustc_allow_const_fn_unstable side-steps feature gating and stability checks"
|
||||
),
|
||||
gated!(
|
||||
allow_internal_unsafe, Normal, template!(Word),
|
||||
"allow_internal_unsafe side-steps the unsafe_code lint",
|
||||
|
@ -893,6 +893,7 @@ symbols! {
|
||||
rustc,
|
||||
rustc_allocator,
|
||||
rustc_allocator_nounwind,
|
||||
rustc_allow_const_fn_unstable,
|
||||
rustc_args_required_const,
|
||||
rustc_attrs,
|
||||
rustc_builtin_macro,
|
||||
|
@ -0,0 +1,6 @@
|
||||
#![allow(unused_macros)]
|
||||
|
||||
#[rustc_allow_const_fn_unstable()] //~ ERROR rustc_allow_const_fn_unstable side-steps
|
||||
const fn foo() { }
|
||||
|
||||
fn main() {}
|
@ -0,0 +1,12 @@
|
||||
error[E0658]: rustc_allow_const_fn_unstable side-steps feature gating and stability checks
|
||||
--> $DIR/feature-gate-rustc-allow-const-fn-unstable.rs:3:1
|
||||
|
|
||||
LL | #[rustc_allow_const_fn_unstable()]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #69399 <https://github.com/rust-lang/rust/issues/69399> for more information
|
||||
= help: add `#![feature(rustc_allow_const_fn_unstable)]` to the crate attributes to enable
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
Loading…
Reference in New Issue
Block a user