Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 0 additions & 2 deletions compiler/rustc_builtin_macros/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 4 additions & 14 deletions compiler/rustc_builtin_macros/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/accepted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion library/compiler-builtins/compiler-builtins/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
1 change: 0 additions & 1 deletion tests/ui/asm/cfg-parse-error.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//@ needs-asm-support
#![feature(asm_cfg)]

use std::arch::asm;

Expand Down
10 changes: 5 additions & 5 deletions tests/ui/asm/cfg-parse-error.stderr
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
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
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
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]
| ^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/asm/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
48 changes: 0 additions & 48 deletions tests/ui/feature-gates/feature-gate-asm_cfg.rs

This file was deleted.

57 changes: 0 additions & 57 deletions tests/ui/feature-gates/feature-gate-asm_cfg.stderr

This file was deleted.

Loading