summaryrefslogtreecommitdiffstats
path: root/tests/ui/borrowck/borrow-raw-address-of-borrowed.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/borrowck/borrow-raw-address-of-borrowed.rs')
-rw-r--r--tests/ui/borrowck/borrow-raw-address-of-borrowed.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/ui/borrowck/borrow-raw-address-of-borrowed.rs b/tests/ui/borrowck/borrow-raw-address-of-borrowed.rs
new file mode 100644
index 000000000..f25fd7f66
--- /dev/null
+++ b/tests/ui/borrowck/borrow-raw-address-of-borrowed.rs
@@ -0,0 +1,22 @@
+#![feature(raw_ref_op)]
+
+fn address_of_shared() {
+ let mut x = 0;
+ let y = &x;
+
+ let q = &raw mut x; //~ ERROR cannot borrow
+
+ drop(y);
+}
+
+fn address_of_mutably_borrowed() {
+ let mut x = 0;
+ let y = &mut x;
+
+ let p = &raw const x; //~ ERROR cannot borrow
+ let q = &raw mut x; //~ ERROR cannot borrow
+
+ drop(y);
+}
+
+fn main() {}