diff --git a/compiler/rustc_builtin_macros/messages.ftl b/compiler/rustc_builtin_macros/messages.ftl index cbdd8199d7ba3..335613f876970 100644 --- a/compiler/rustc_builtin_macros/messages.ftl +++ b/compiler/rustc_builtin_macros/messages.ftl @@ -3,8 +3,6 @@ builtin_macros_alloc_must_statics = allocators must be statics builtin_macros_asm_attribute_not_supported = this attribute is not supported on assembly -builtin_macros_asm_cfg = - the `#[cfg(/* ... */)]` and `#[cfg_attr(/* ... */)]` attributes on assembly are unstable builtin_macros_asm_clobber_abi = clobber_abi builtin_macros_asm_clobber_no_reg = asm with `clobber_abi` must specify explicit registers for outputs diff --git a/compiler/rustc_builtin_macros/src/asm.rs b/compiler/rustc_builtin_macros/src/asm.rs index 971b68d14757a..2958686f86cd5 100644 --- a/compiler/rustc_builtin_macros/src/asm.rs +++ b/compiler/rustc_builtin_macros/src/asm.rs @@ -6,14 +6,13 @@ use rustc_expand::base::*; use rustc_index::bit_set::GrowableBitSet; use rustc_parse::parser::asm::*; use rustc_session::lint; -use rustc_session::parse::feature_err; use rustc_span::{ErrorGuaranteed, InnerSpan, Span, Symbol, sym}; use rustc_target::asm::InlineAsmArch; use smallvec::smallvec; use {rustc_ast as ast, rustc_parse_format as parse}; +use crate::errors; use crate::util::{ExprToSpannedString, expr_to_spanned_string}; -use crate::{errors, fluent_generated as fluent}; /// Validated assembly arguments, ready for macro expansion. struct ValidatedAsmArgs { @@ -64,22 +63,13 @@ fn validate_asm_args<'a>( for arg in args { for attr in arg.attributes.0.iter() { - match attr.name() { - Some(sym::cfg | sym::cfg_attr) => { - if !ecx.ecfg.features.asm_cfg() { - let span = attr.span(); - feature_err(ecx.sess, sym::asm_cfg, span, fluent::builtin_macros_asm_cfg) - .emit(); - } - } - _ => { - ecx.dcx().emit_err(errors::AsmAttributeNotSupported { span: attr.span() }); - } + if !matches!(attr.name(), Some(sym::cfg | sym::cfg_attr)) { + ecx.dcx().emit_err(errors::AsmAttributeNotSupported { span: attr.span() }); } } // Skip arguments that are configured out. - if ecx.ecfg.features.asm_cfg() && strip_unconfigured.configure(arg.attributes).is_none() { + if strip_unconfigured.configure(arg.attributes).is_none() { continue; } diff --git a/compiler/rustc_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs index 364a1202b05c2..a17ba6ca63261 100644 --- a/compiler/rustc_feature/src/accepted.rs +++ b/compiler/rustc_feature/src/accepted.rs @@ -60,6 +60,8 @@ declare_features! ( (accepted, adx_target_feature, "1.61.0", Some(44839)), /// Allows explicit discriminants on non-unit enum variants. (accepted, arbitrary_enum_discriminant, "1.66.0", Some(60553)), + /// Allows #[cfg(...)] on inline assembly templates and operands. + (accepted, asm_cfg, "CURRENT_RUSTC_VERSION", Some(140364)), /// Allows using `const` operands in inline assembly. (accepted, asm_const, "1.82.0", Some(93332)), /// Allows using `label` operands in inline assembly. diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 8397cd294e0a9..d0ecc0061edc7 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -382,8 +382,6 @@ declare_features! ( (unstable, arbitrary_self_types, "1.23.0", Some(44874)), /// Allows inherent and trait methods with arbitrary self types that are raw pointers. (unstable, arbitrary_self_types_pointers, "1.83.0", Some(44874)), - /// Allows #[cfg(...)] on inline assembly templates and operands. - (unstable, asm_cfg, "1.89.0", Some(140364)), /// Enables experimental inline assembly support for additional architectures. (unstable, asm_experimental_arch, "1.58.0", Some(93335)), /// Enables experimental register support in inline assembly. diff --git a/library/compiler-builtins/compiler-builtins/src/lib.rs b/library/compiler-builtins/compiler-builtins/src/lib.rs index b111dc0bd18f3..a9dd6e531c5d3 100644 --- a/library/compiler-builtins/compiler-builtins/src/lib.rs +++ b/library/compiler-builtins/compiler-builtins/src/lib.rs @@ -7,7 +7,6 @@ #![feature(compiler_builtins)] #![feature(core_intrinsics)] #![feature(linkage)] -#![feature(asm_cfg)] #![feature(naked_functions)] #![feature(repr_simd)] #![feature(macro_metavar_expr_concat)] diff --git a/tests/ui/asm/cfg-parse-error.rs b/tests/ui/asm/cfg-parse-error.rs index 9b79d16a76dda..0c6b63872a432 100644 --- a/tests/ui/asm/cfg-parse-error.rs +++ b/tests/ui/asm/cfg-parse-error.rs @@ -1,5 +1,4 @@ //@ needs-asm-support -#![feature(asm_cfg)] use std::arch::asm; diff --git a/tests/ui/asm/cfg-parse-error.stderr b/tests/ui/asm/cfg-parse-error.stderr index 8a70d39a43dc6..726dee271108f 100644 --- a/tests/ui/asm/cfg-parse-error.stderr +++ b/tests/ui/asm/cfg-parse-error.stderr @@ -1,5 +1,5 @@ error: expected one of `#`, `clobber_abi`, `const`, `in`, `inlateout`, `inout`, `label`, `lateout`, `options`, `out`, or `sym`, found `""` - --> $DIR/cfg-parse-error.rs:16:13 + --> $DIR/cfg-parse-error.rs:15:13 | LL | a = out(reg) x, | - expected one of 11 possible tokens @@ -7,7 +7,7 @@ LL | "", | ^^ unexpected token error: expected one of `#`, `clobber_abi`, `const`, `in`, `inlateout`, `inout`, `label`, `lateout`, `options`, `out`, or `sym`, found `""` - --> $DIR/cfg-parse-error.rs:26:13 + --> $DIR/cfg-parse-error.rs:25:13 | LL | }, | - expected one of 11 possible tokens @@ -15,19 +15,19 @@ LL | "", | ^^ unexpected token error: expected token: `,` - --> $DIR/cfg-parse-error.rs:41:26 + --> $DIR/cfg-parse-error.rs:40:26 | LL | a = out(reg) x, | ^ expected `,` error: this attribute is not supported on assembly - --> $DIR/cfg-parse-error.rs:47:13 + --> $DIR/cfg-parse-error.rs:46:13 | LL | #[rustfmt::skip] | ^^^^^^^^^^^^^^^^ error: an inner attribute is not permitted in this context - --> $DIR/cfg-parse-error.rs:53:13 + --> $DIR/cfg-parse-error.rs:52:13 | LL | #![rustfmt::skip] | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/asm/cfg.rs b/tests/ui/asm/cfg.rs index bcf86340b9d8a..90b1b3d6ee650 100644 --- a/tests/ui/asm/cfg.rs +++ b/tests/ui/asm/cfg.rs @@ -3,7 +3,7 @@ //@ revisions: reva revb //@ only-x86_64 //@ run-pass -#![feature(asm_cfg, cfg_select)] +#![feature(cfg_select)] use std::arch::{asm, naked_asm}; diff --git a/tests/ui/feature-gates/feature-gate-asm_cfg.rs b/tests/ui/feature-gates/feature-gate-asm_cfg.rs deleted file mode 100644 index ef8bf75b6929d..0000000000000 --- a/tests/ui/feature-gates/feature-gate-asm_cfg.rs +++ /dev/null @@ -1,48 +0,0 @@ -//@ only-x86_64 -#![crate_type = "lib"] - -use std::arch::{asm, global_asm, naked_asm}; - -global_asm!( - "nop", - #[cfg(false)] - //~^ ERROR the `#[cfg(/* ... */)]` and `#[cfg_attr(/* ... */)]` attributes on assembly are unstable - "nop" -); - -#[unsafe(naked)] -#[no_mangle] -extern "C" fn naked() { - naked_asm!( - "mov rax, 5", - #[cfg(false)] - //~^ ERROR the `#[cfg(/* ... */)]` and `#[cfg_attr(/* ... */)]` attributes on assembly are unstable - "mov rax, {a}", - "ret", - #[cfg(false)] - //~^ ERROR the `#[cfg(/* ... */)]` and `#[cfg_attr(/* ... */)]` attributes on assembly are unstable - a = const 10, - ) -} - -fn asm() { - unsafe { - asm!( - "nop", - #[cfg(false)] - //~^ ERROR the `#[cfg(/* ... */)]` and `#[cfg_attr(/* ... */)]` attributes on assembly are unstable - clobber_abi("C"), - clobber_abi("C"), //~ ERROR `C` ABI specified multiple times - ); - } -} - -fn bad_attribute() { - unsafe { - asm!( - #[inline] - //~^ ERROR this attribute is not supported on assembly - "nop" - ) - }; -} diff --git a/tests/ui/feature-gates/feature-gate-asm_cfg.stderr b/tests/ui/feature-gates/feature-gate-asm_cfg.stderr deleted file mode 100644 index e92d1e8c48747..0000000000000 --- a/tests/ui/feature-gates/feature-gate-asm_cfg.stderr +++ /dev/null @@ -1,57 +0,0 @@ -error[E0658]: the `#[cfg(/* ... */)]` and `#[cfg_attr(/* ... */)]` attributes on assembly are unstable - --> $DIR/feature-gate-asm_cfg.rs:8:5 - | -LL | #[cfg(false)] - | ^^^^^^^^^^^^^ - | - = note: see issue #140364 for more information - = help: add `#![feature(asm_cfg)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: the `#[cfg(/* ... */)]` and `#[cfg_attr(/* ... */)]` attributes on assembly are unstable - --> $DIR/feature-gate-asm_cfg.rs:18:9 - | -LL | #[cfg(false)] - | ^^^^^^^^^^^^^ - | - = note: see issue #140364 for more information - = help: add `#![feature(asm_cfg)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: the `#[cfg(/* ... */)]` and `#[cfg_attr(/* ... */)]` attributes on assembly are unstable - --> $DIR/feature-gate-asm_cfg.rs:22:9 - | -LL | #[cfg(false)] - | ^^^^^^^^^^^^^ - | - = note: see issue #140364 for more information - = help: add `#![feature(asm_cfg)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: the `#[cfg(/* ... */)]` and `#[cfg_attr(/* ... */)]` attributes on assembly are unstable - --> $DIR/feature-gate-asm_cfg.rs:32:13 - | -LL | #[cfg(false)] - | ^^^^^^^^^^^^^ - | - = note: see issue #140364 for more information - = help: add `#![feature(asm_cfg)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error: this attribute is not supported on assembly - --> $DIR/feature-gate-asm_cfg.rs:43:13 - | -LL | #[inline] - | ^^^^^^^^^ - -error: `C` ABI specified multiple times - --> $DIR/feature-gate-asm_cfg.rs:35:13 - | -LL | clobber_abi("C"), - | ---------------- previously specified here -LL | clobber_abi("C"), - | ^^^^^^^^^^^^^^^^ - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0658`.