rust/tests/ui/consts/const-mut-refs/const_mut_address_of.rs
2024-08-18 19:46:53 +02:00

28 lines
341 B
Rust

//@ check-pass
#![feature(const_mut_refs)]
struct Foo {
x: usize
}
const fn foo() -> Foo {
Foo { x: 0 }
}
impl Foo {
const fn bar(&mut self) -> *mut usize {
&raw mut self.x
}
}
const fn baz(foo: &mut Foo)-> *mut usize {
&raw mut foo.x
}
const _: () = {
foo().bar();
baz(&mut foo());
};
fn main() {}