about summary refs log tree commit diff
path: root/tests/ui/asm
diff options
context:
space:
mode:
authorJieyou Xu <jieyouxu@outlook.com>2025-07-18 00:10:46 +0800
committerJieyou Xu <jieyouxu@outlook.com>2025-07-19 01:42:30 +0800
commit69b71e44107b4905ec7ad84ccb3edf4f14b3df69 (patch)
treefa801205d444880c9972c2701eef39bafc453b08 /tests/ui/asm
parentb2e94bf020a99473cf80f05f410af8a5cfc486a6 (diff)
downloadrust-69b71e44107b4905ec7ad84ccb3edf4f14b3df69.tar.gz
rust-69b71e44107b4905ec7ad84ccb3edf4f14b3df69.zip
Mitigate `#[align]` name resolution ambiguity regression with a rename
From `#[align]` -> `#[rustc_align]`. Attributes starting with `rustc`
are always perma-unstable and feature-gated by `feature(rustc_attrs)`.

See regression RUST-143834.

For the underlying problem where even introducing new feature-gated
unstable built-in attributes can break user code such as

```rs
macro_rules! align {
    () => {
        /* .. */
    };
}

pub(crate) use align; // `use` here becomes ambiguous
```

refer to RUST-134963.

Since the `#[align]` attribute is still feature-gated by
`feature(fn_align)`, we can rename it as a mitigation. Note that
`#[rustc_align]` will obviously mean that current unstable user code
using `feature(fn_aling)` will need additionally `feature(rustc_attrs)`,
but this is a short-term mitigation to buy time, and is expected to be
changed to a better name with less collision potential.

See
<https://rust-lang.zulipchat.com/#narrow/channel/238009-t-compiler.2Fmeetings/topic/.5Bweekly.5D.202025-07-17/near/529290371>
where mitigation options were considered.
Diffstat (limited to 'tests/ui/asm')
-rw-r--r--tests/ui/asm/naked-with-invalid-repr-attr.rs6
-rw-r--r--tests/ui/asm/naked-with-invalid-repr-attr.stderr12
2 files changed, 11 insertions, 7 deletions
diff --git a/tests/ui/asm/naked-with-invalid-repr-attr.rs b/tests/ui/asm/naked-with-invalid-repr-attr.rs
index bfbbf29a69e..4620d007e4e 100644
--- a/tests/ui/asm/naked-with-invalid-repr-attr.rs
+++ b/tests/ui/asm/naked-with-invalid-repr-attr.rs
@@ -1,5 +1,9 @@
 //@ needs-asm-support
+
+// FIXME(#82232, #143834): temporarily renamed to mitigate `#[align]` nameres ambiguity
+#![feature(rustc_attrs)]
 #![feature(fn_align)]
+
 #![crate_type = "lib"]
 use std::arch::naked_asm;
 
@@ -21,7 +25,7 @@ extern "C" fn example2() {
 
 #[repr(C)]
 //~^ ERROR attribute should be applied to a struct, enum, or union [E0517]
-#[align(16)]
+#[rustc_align(16)]
 #[unsafe(naked)]
 extern "C" fn example3() {
     //~^ NOTE not a struct, enum, or union
diff --git a/tests/ui/asm/naked-with-invalid-repr-attr.stderr b/tests/ui/asm/naked-with-invalid-repr-attr.stderr
index 4eb4a4e5a04..8530495be66 100644
--- a/tests/ui/asm/naked-with-invalid-repr-attr.stderr
+++ b/tests/ui/asm/naked-with-invalid-repr-attr.stderr
@@ -1,5 +1,5 @@
 error[E0517]: attribute should be applied to a struct, enum, or union
-  --> $DIR/naked-with-invalid-repr-attr.rs:6:8
+  --> $DIR/naked-with-invalid-repr-attr.rs:10:8
    |
 LL |   #[repr(C)]
    |          ^
@@ -11,7 +11,7 @@ LL | | }
    | |_- not a struct, enum, or union
 
 error[E0517]: attribute should be applied to a struct, enum, or union
-  --> $DIR/naked-with-invalid-repr-attr.rs:14:8
+  --> $DIR/naked-with-invalid-repr-attr.rs:18:8
    |
 LL |   #[repr(transparent)]
    |          ^^^^^^^^^^^
@@ -23,7 +23,7 @@ LL | | }
    | |_- not a struct, enum, or union
 
 error[E0517]: attribute should be applied to a struct, enum, or union
-  --> $DIR/naked-with-invalid-repr-attr.rs:22:8
+  --> $DIR/naked-with-invalid-repr-attr.rs:26:8
    |
 LL |   #[repr(C)]
    |          ^
@@ -35,7 +35,7 @@ LL | | }
    | |_- not a struct, enum, or union
 
 error[E0517]: attribute should be applied to a struct, enum, or union
-  --> $DIR/naked-with-invalid-repr-attr.rs:32:8
+  --> $DIR/naked-with-invalid-repr-attr.rs:36:8
    |
 LL |   #[repr(C, packed)]
    |          ^
@@ -48,7 +48,7 @@ LL | | }
    | |_- not a struct, enum, or union
 
 error[E0517]: attribute should be applied to a struct or union
-  --> $DIR/naked-with-invalid-repr-attr.rs:32:11
+  --> $DIR/naked-with-invalid-repr-attr.rs:36:11
    |
 LL |   #[repr(C, packed)]
    |             ^^^^^^
@@ -61,7 +61,7 @@ LL | | }
    | |_- not a struct or union
 
 error[E0517]: attribute should be applied to an enum
-  --> $DIR/naked-with-invalid-repr-attr.rs:42:8
+  --> $DIR/naked-with-invalid-repr-attr.rs:46:8
    |
 LL |   #[repr(u8)]
    |          ^^