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/ui/attributes/malformed-fn-align.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/ui/attributes/malformed-fn-align.rs')
| -rw-r--r-- | tests/ui/attributes/malformed-fn-align.rs | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/tests/ui/attributes/malformed-fn-align.rs b/tests/ui/attributes/malformed-fn-align.rs index e06e6116842..cf143b28e54 100644 --- a/tests/ui/attributes/malformed-fn-align.rs +++ b/tests/ui/attributes/malformed-fn-align.rs @@ -1,49 +1,54 @@ +// ignore-tidy-linelength + +// FIXME(#82232, #143834): temporarily renamed to mitigate `#[align]` nameres ambiguity +#![feature(rustc_attrs)] #![feature(fn_align)] + #![crate_type = "lib"] trait MyTrait { - #[align] //~ ERROR malformed `align` attribute input + #[rustc_align] //~ ERROR malformed `rustc_align` attribute input fn myfun1(); - #[align(1, 2)] //~ ERROR malformed `align` attribute input + #[rustc_align(1, 2)] //~ ERROR malformed `rustc_align` attribute input fn myfun2(); } -#[align = 16] //~ ERROR malformed `align` attribute input +#[rustc_align = 16] //~ ERROR malformed `rustc_align` attribute input fn f1() {} -#[align("hello")] //~ ERROR invalid alignment value: not an unsuffixed integer +#[rustc_align("hello")] //~ ERROR invalid alignment value: not an unsuffixed integer fn f2() {} -#[align(0)] //~ ERROR invalid alignment value: not a power of two +#[rustc_align(0)] //~ ERROR invalid alignment value: not a power of two fn f3() {} #[repr(align(16))] //~ ERROR `#[repr(align(...))]` is not supported on function items fn f4() {} -#[align(-1)] //~ ERROR expected unsuffixed literal, found `-` +#[rustc_align(-1)] //~ ERROR expected unsuffixed literal, found `-` fn f5() {} -#[align(3)] //~ ERROR invalid alignment value: not a power of two +#[rustc_align(3)] //~ ERROR invalid alignment value: not a power of two fn f6() {} -#[align(4usize)] //~ ERROR invalid alignment value: not an unsuffixed integer [E0589] +#[rustc_align(4usize)] //~ ERROR invalid alignment value: not an unsuffixed integer [E0589] //~^ ERROR suffixed literals are not allowed in attributes fn f7() {} -#[align(16)] -#[align(3)] //~ ERROR invalid alignment value: not a power of two -#[align(16)] +#[rustc_align(16)] +#[rustc_align(3)] //~ ERROR invalid alignment value: not a power of two +#[rustc_align(16)] fn f8() {} -#[align(16)] //~ ERROR `#[align(...)]` is not supported on struct items +#[rustc_align(16)] //~ ERROR `#[rustc_align(...)]` is not supported on struct items struct S1; -#[align(32)] //~ ERROR `#[align(...)]` should be applied to a function item +#[rustc_align(32)] //~ ERROR `#[rustc_align(...)]` should be applied to a function item const FOO: i32 = 42; -#[align(32)] //~ ERROR `#[align(...)]` should be applied to a function item +#[rustc_align(32)] //~ ERROR `#[rustc_align(...)]` should be applied to a function item mod test {} -#[align(32)] //~ ERROR `#[align(...)]` should be applied to a function item +#[rustc_align(32)] //~ ERROR `#[rustc_align(...)]` should be applied to a function item use ::std::iter; |
