mirror of
https://github.com/rust-lang/rust.git
synced 2025-11-23 12:07:58 +00:00
We need a different attribute than `rustc_align` because unstable attributes are tied to their feature (we can't have two unstable features use the same unstable attribute). Otherwise this uses all of the same infrastructure as `#[rustc_align]`.
27 lines
591 B
Rust
27 lines
591 B
Rust
//@ run-pass
|
|
#![feature(static_align)]
|
|
|
|
#[rustc_align_static(64)]
|
|
static A: u8 = 0;
|
|
|
|
#[rustc_align_static(64)]
|
|
static B: u8 = 0;
|
|
|
|
#[rustc_align_static(128)]
|
|
#[no_mangle]
|
|
static EXPORTED: u64 = 0;
|
|
|
|
unsafe extern "C" {
|
|
#[rustc_align_static(128)]
|
|
#[link_name = "EXPORTED"]
|
|
static C: u64;
|
|
}
|
|
|
|
fn main() {
|
|
assert!(core::ptr::from_ref(&A).addr().is_multiple_of(64));
|
|
assert!(core::ptr::from_ref(&B).addr().is_multiple_of(64));
|
|
|
|
assert!(core::ptr::from_ref(&EXPORTED).addr().is_multiple_of(128));
|
|
unsafe { assert!(core::ptr::from_ref(&C).addr().is_multiple_of(128)) };
|
|
}
|