summaryrefslogtreecommitdiffstats
path: root/src/test/ui/consts/const-mut-refs/const_mut_address_of.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/consts/const-mut-refs/const_mut_address_of.rs')
-rw-r--r--src/test/ui/consts/const-mut-refs/const_mut_address_of.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/test/ui/consts/const-mut-refs/const_mut_address_of.rs b/src/test/ui/consts/const-mut-refs/const_mut_address_of.rs
new file mode 100644
index 000000000..03b2f9e3c
--- /dev/null
+++ b/src/test/ui/consts/const-mut-refs/const_mut_address_of.rs
@@ -0,0 +1,28 @@
+// check-pass
+#![feature(const_mut_refs)]
+#![feature(raw_ref_op)]
+
+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() {}