about summary refs log tree commit diff
path: root/tests/ui/fn/dyn-fn-alignment.rs
blob: 136b8e6f2da964a86f57c1becd7721a8d2c6cd27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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);
}