about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorFolkert de Vries <folkert@folkertdev.nl>2025-06-07 22:56:22 +0200
committerFolkert de Vries <folkert@folkertdev.nl>2025-09-09 21:54:54 +0200
commitcbacd00f106778830803ad2e2364518f06ff9078 (patch)
tree4e17ddefcf9c27f5d7bacf37f7f5c57b81ce1679 /src
parentc559c4a741836c4ffa8e4f60cb9fe7e92af5298e (diff)
downloadrust-cbacd00f106778830803ad2e2364518f06ff9078.tar.gz
rust-cbacd00f106778830803ad2e2364518f06ff9078.zip
allow `#[rustc_align_static(N)]` on `static`s
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]`.
Diffstat (limited to 'src')
-rw-r--r--src/tools/miri/tests/pass/static_align.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/tools/miri/tests/pass/static_align.rs b/src/tools/miri/tests/pass/static_align.rs
new file mode 100644
index 00000000000..f292f028568
--- /dev/null
+++ b/src/tools/miri/tests/pass/static_align.rs
@@ -0,0 +1,14 @@
+#![feature(static_align)]
+
+// When a static uses `align(N)`, its address should be a multiple of `N`.
+
+#[rustc_align_static(256)]
+static FOO: u64 = 0;
+
+#[rustc_align_static(512)]
+static BAR: u64 = 0;
+
+fn main() {
+    assert!(core::ptr::from_ref(&FOO).addr().is_multiple_of(256));
+    assert!(core::ptr::from_ref(&BAR).addr().is_multiple_of(512));
+}