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.
(cherry picked from commit 69b71e4410)
72 lines
1.3 KiB
Rust
72 lines
1.3 KiB
Rust
//@ compile-flags: -C no-prepopulate-passes -Z mir-opt-level=0
|
|
|
|
#![crate_type = "lib"]
|
|
// FIXME(#82232, #143834): temporarily renamed to mitigate `#[align]` nameres ambiguity
|
|
#![feature(rustc_attrs)]
|
|
#![feature(fn_align)]
|
|
|
|
// CHECK: align 16
|
|
#[no_mangle]
|
|
#[rustc_align(16)]
|
|
pub fn fn_align() {}
|
|
|
|
pub struct A;
|
|
|
|
impl A {
|
|
// CHECK: align 16
|
|
#[no_mangle]
|
|
#[rustc_align(16)]
|
|
pub fn method_align(self) {}
|
|
|
|
// CHECK: align 16
|
|
#[no_mangle]
|
|
#[rustc_align(16)]
|
|
pub fn associated_fn() {}
|
|
}
|
|
|
|
trait T: Sized {
|
|
fn trait_fn() {}
|
|
|
|
// CHECK: align 32
|
|
#[rustc_align(32)]
|
|
fn trait_method(self) {}
|
|
}
|
|
|
|
impl T for A {
|
|
// CHECK: align 16
|
|
#[no_mangle]
|
|
#[rustc_align(16)]
|
|
fn trait_fn() {}
|
|
|
|
// CHECK: align 16
|
|
#[no_mangle]
|
|
#[rustc_align(16)]
|
|
fn trait_method(self) {}
|
|
}
|
|
|
|
impl T for () {}
|
|
|
|
pub fn foo() {
|
|
().trait_method();
|
|
}
|
|
|
|
// CHECK-LABEL: align_specified_twice_1
|
|
// CHECK-SAME: align 64
|
|
#[no_mangle]
|
|
#[rustc_align(32)]
|
|
#[rustc_align(64)]
|
|
pub fn align_specified_twice_1() {}
|
|
|
|
// CHECK-LABEL: align_specified_twice_2
|
|
// CHECK-SAME: align 128
|
|
#[no_mangle]
|
|
#[rustc_align(128)]
|
|
#[rustc_align(32)]
|
|
pub fn align_specified_twice_2() {}
|
|
|
|
// CHECK-LABEL: align_specified_twice_3
|
|
// CHECK-SAME: align 256
|
|
#[no_mangle]
|
|
#[rustc_align(32)]
|
|
#[rustc_align(256)]
|
|
pub fn align_specified_twice_3() {}
|