summaryrefslogtreecommitdiffstats
path: root/src/test/ui/fn/dyn-fn-alignment.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/test/ui/fn/dyn-fn-alignment.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/test/ui/fn/dyn-fn-alignment.rs b/src/test/ui/fn/dyn-fn-alignment.rs
new file mode 100644
index 000000000..cedfd1cf2
--- /dev/null
+++ b/src/test/ui/fn/dyn-fn-alignment.rs
@@ -0,0 +1,23 @@
+// run-pass
+
+#![allow(dead_code)]
+#[repr(align(256))]
+struct A {
+ v: u8,
+}
+
+impl A {
+ fn f(&self) -> *const A {
+ self
+ }
+}
+
+fn f2(v: u8) -> Box<dyn FnOnce() -> *const A> {
+ let a = A { v };
+ Box::new(move || a.f())
+}
+
+fn main() {
+ let addr = f2(0)();
+ assert_eq!(addr as usize % 256, 0, "addr: {:?}", addr);
+}