mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-05 05:04:24 +00:00
24 lines
338 B
Rust
24 lines
338 B
Rust
|
// 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);
|
||
|
}
|