diff options
| author | Jieyou Xu <jieyouxu@outlook.com> | 2025-07-18 00:10:46 +0800 |
|---|---|---|
| committer | Jieyou Xu <jieyouxu@outlook.com> | 2025-07-19 01:42:30 +0800 |
| commit | 69b71e44107b4905ec7ad84ccb3edf4f14b3df69 (patch) | |
| tree | fa801205d444880c9972c2701eef39bafc453b08 /tests/codegen/align-fn.rs | |
| parent | b2e94bf020a99473cf80f05f410af8a5cfc486a6 (diff) | |
| download | rust-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/codegen/align-fn.rs')
| -rw-r--r-- | tests/codegen/align-fn.rs | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/tests/codegen/align-fn.rs b/tests/codegen/align-fn.rs index fd572910c28..cbc24e2ae2e 100644 --- a/tests/codegen/align-fn.rs +++ b/tests/codegen/align-fn.rs @@ -3,11 +3,13 @@ //@ ignore-wasm32 aligning functions is not currently supported on wasm (#143368) #![crate_type = "lib"] +// FIXME(#82232, #143834): temporarily renamed to mitigate `#[align]` nameres ambiguity +#![feature(rustc_attrs)] #![feature(fn_align)] // CHECK: align 16 #[unsafe(no_mangle)] -#[align(16)] +#[rustc_align(16)] pub fn fn_align() {} pub struct A; @@ -15,12 +17,12 @@ pub struct A; impl A { // CHECK: align 16 #[unsafe(no_mangle)] - #[align(16)] + #[rustc_align(16)] pub fn method_align(self) {} // CHECK: align 16 #[unsafe(no_mangle)] - #[align(16)] + #[rustc_align(16)] pub fn associated_fn() {} } @@ -29,18 +31,18 @@ trait T: Sized { fn trait_method(self) {} - #[align(8)] + #[rustc_align(8)] fn trait_method_inherit_low(self); - #[align(32)] + #[rustc_align(32)] fn trait_method_inherit_high(self); - #[align(32)] + #[rustc_align(32)] fn trait_method_inherit_default(self) {} - #[align(4)] - #[align(128)] - #[align(8)] + #[rustc_align(4)] + #[rustc_align(128)] + #[rustc_align(8)] fn inherit_highest(self) {} } @@ -48,27 +50,27 @@ impl T for A { // CHECK-LABEL: trait_fn // CHECK-SAME: align 16 #[unsafe(no_mangle)] - #[align(16)] + #[rustc_align(16)] fn trait_fn() {} // CHECK-LABEL: trait_method // CHECK-SAME: align 16 #[unsafe(no_mangle)] - #[align(16)] + #[rustc_align(16)] fn trait_method(self) {} // The prototype's align is ignored because the align here is higher. // CHECK-LABEL: trait_method_inherit_low // CHECK-SAME: align 16 #[unsafe(no_mangle)] - #[align(16)] + #[rustc_align(16)] fn trait_method_inherit_low(self) {} // The prototype's align is used because it is higher. // CHECK-LABEL: trait_method_inherit_high // CHECK-SAME: align 32 #[unsafe(no_mangle)] - #[align(16)] + #[rustc_align(16)] fn trait_method_inherit_high(self) {} // The prototype's align inherited. @@ -81,8 +83,8 @@ impl T for A { // CHECK-LABEL: inherit_highest // CHECK-SAME: align 128 #[unsafe(no_mangle)] - #[align(32)] - #[align(64)] + #[rustc_align(32)] + #[rustc_align(64)] fn inherit_highest(self) {} } @@ -90,7 +92,7 @@ trait HasDefaultImpl: Sized { // CHECK-LABEL: inherit_from_default_method // CHECK-LABEL: inherit_from_default_method // CHECK-SAME: align 32 - #[align(32)] + #[rustc_align(32)] fn inherit_from_default_method(self) {} } @@ -101,35 +103,35 @@ impl HasDefaultImpl for InstantiateDefaultMethods {} // CHECK-LABEL: align_specified_twice_1 // CHECK-SAME: align 64 #[unsafe(no_mangle)] -#[align(32)] -#[align(64)] +#[rustc_align(32)] +#[rustc_align(64)] pub fn align_specified_twice_1() {} // CHECK-LABEL: align_specified_twice_2 // CHECK-SAME: align 128 #[unsafe(no_mangle)] -#[align(128)] -#[align(32)] +#[rustc_align(128)] +#[rustc_align(32)] pub fn align_specified_twice_2() {} // CHECK-LABEL: align_specified_twice_3 // CHECK-SAME: align 256 #[unsafe(no_mangle)] -#[align(32)] -#[align(256)] +#[rustc_align(32)] +#[rustc_align(256)] pub fn align_specified_twice_3() {} const _: () = { // CHECK-LABEL: align_unmangled // CHECK-SAME: align 256 #[unsafe(no_mangle)] - #[align(32)] - #[align(256)] + #[rustc_align(32)] + #[rustc_align(256)] extern "C" fn align_unmangled() {} }; unsafe extern "C" { - #[align(256)] + #[rustc_align(256)] fn align_unmangled(); } @@ -137,5 +139,5 @@ unsafe extern "C" { // CHECK-LABEL: async_align // CHECK-SAME: align 64 #[unsafe(no_mangle)] -#[align(64)] +#[rustc_align(64)] pub async fn async_align() {} |
