2025-07-18 00:10:46 +08:00
|
|
|
// ignore-tidy-linelength
|
|
|
|
|
|
|
|
|
|
// FIXME(#82232, #143834): temporarily renamed to mitigate `#[align]` nameres ambiguity
|
|
|
|
|
#![feature(rustc_attrs)]
|
2025-02-09 22:50:11 +01:00
|
|
|
#![feature(fn_align)]
|
2025-07-18 00:10:46 +08:00
|
|
|
|
2025-02-09 22:50:11 +01:00
|
|
|
#![crate_type = "lib"]
|
|
|
|
|
|
|
|
|
|
trait MyTrait {
|
2025-07-18 00:10:46 +08:00
|
|
|
#[rustc_align] //~ ERROR malformed `rustc_align` attribute input
|
2025-06-19 12:40:50 +02:00
|
|
|
fn myfun1();
|
|
|
|
|
|
2025-07-18 00:10:46 +08:00
|
|
|
#[rustc_align(1, 2)] //~ ERROR malformed `rustc_align` attribute input
|
2025-06-19 12:40:50 +02:00
|
|
|
fn myfun2();
|
2025-02-09 22:50:11 +01:00
|
|
|
}
|
2025-06-09 20:08:52 +02:00
|
|
|
|
2025-07-18 00:10:46 +08:00
|
|
|
#[rustc_align = 16] //~ ERROR malformed `rustc_align` attribute input
|
2025-06-09 20:08:52 +02:00
|
|
|
fn f1() {}
|
|
|
|
|
|
2025-07-18 00:10:46 +08:00
|
|
|
#[rustc_align("hello")] //~ ERROR invalid alignment value: not an unsuffixed integer
|
2025-06-09 20:08:52 +02:00
|
|
|
fn f2() {}
|
|
|
|
|
|
2025-07-18 00:10:46 +08:00
|
|
|
#[rustc_align(0)] //~ ERROR invalid alignment value: not a power of two
|
2025-06-09 20:08:52 +02:00
|
|
|
fn f3() {}
|
|
|
|
|
|
2025-08-09 20:41:01 +02:00
|
|
|
#[repr(align(16))] //~ ERROR `#[repr(align(...))]` is not supported on functions
|
2025-06-09 20:08:52 +02:00
|
|
|
fn f4() {}
|
|
|
|
|
|
2025-07-31 15:38:44 +02:00
|
|
|
#[rustc_align(-1)] //~ ERROR expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `-`
|
2025-07-01 16:13:37 -04:00
|
|
|
fn f5() {}
|
|
|
|
|
|
2025-07-18 00:10:46 +08:00
|
|
|
#[rustc_align(3)] //~ ERROR invalid alignment value: not a power of two
|
2025-07-01 16:13:37 -04:00
|
|
|
fn f6() {}
|
|
|
|
|
|
2025-07-18 00:10:46 +08:00
|
|
|
#[rustc_align(4usize)] //~ ERROR invalid alignment value: not an unsuffixed integer [E0589]
|
2025-07-01 16:13:37 -04:00
|
|
|
//~^ ERROR suffixed literals are not allowed in attributes
|
|
|
|
|
fn f7() {}
|
|
|
|
|
|
2025-07-18 00:10:46 +08:00
|
|
|
#[rustc_align(16)]
|
|
|
|
|
#[rustc_align(3)] //~ ERROR invalid alignment value: not a power of two
|
|
|
|
|
#[rustc_align(16)]
|
2025-07-01 16:13:37 -04:00
|
|
|
fn f8() {}
|
|
|
|
|
|
2025-08-09 20:41:01 +02:00
|
|
|
#[rustc_align(16)] //~ ERROR attribute cannot be used on
|
2025-06-09 20:08:52 +02:00
|
|
|
struct S1;
|
2025-06-29 12:50:21 -04:00
|
|
|
|
2025-08-09 20:41:01 +02:00
|
|
|
#[rustc_align(32)] //~ ERROR attribute cannot be used on
|
2025-06-29 12:50:21 -04:00
|
|
|
const FOO: i32 = 42;
|
|
|
|
|
|
2025-08-09 20:41:01 +02:00
|
|
|
#[rustc_align(32)] //~ ERROR attribute cannot be used on
|
2025-06-29 12:50:21 -04:00
|
|
|
mod test {}
|
|
|
|
|
|
2025-08-09 20:41:01 +02:00
|
|
|
#[rustc_align(32)] //~ ERROR attribute cannot be used on
|
2025-06-29 12:50:21 -04:00
|
|
|
use ::std::iter;
|