about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/test/ui/consts/const_let_eq.rs2
-rw-r--r--src/test/ui/consts/min_const_fn/mutable_borrow.rs17
-rw-r--r--src/test/ui/consts/min_const_fn/mutable_borrow.stderr14
3 files changed, 32 insertions, 1 deletions
diff --git a/src/test/ui/consts/const_let_eq.rs b/src/test/ui/consts/const_let_eq.rs
index 434aeaac5fd..a2364c392f2 100644
--- a/src/test/ui/consts/const_let_eq.rs
+++ b/src/test/ui/consts/const_let_eq.rs
@@ -465,4 +465,4 @@ fn main() {
     test!(AND, bit_and_assign(W(0b1011_1111_1111_1111_1111)), 0b0011_1100_1101_0100);
     test!(OR, bit_or_assign(W(0b1011_0000_0000_0000)), 0b1111_0011_0101_1001);
     test!(XOR, bit_xor_assign(W(0b0000_0000_0000_0000)), 0b1100_0011_1001_0011);
-}
\ No newline at end of file
+}
diff --git a/src/test/ui/consts/min_const_fn/mutable_borrow.rs b/src/test/ui/consts/min_const_fn/mutable_borrow.rs
new file mode 100644
index 00000000000..85f9a154c84
--- /dev/null
+++ b/src/test/ui/consts/min_const_fn/mutable_borrow.rs
@@ -0,0 +1,17 @@
+const fn mutable_ref_in_const() -> u8 {
+    let mut a = 0;
+    let b = &mut a; //~ ERROR mutable references in const fn are unstable
+    *b
+}
+
+struct X;
+
+impl X {
+    const fn inherent_mutable_ref_in_const() -> u8 {
+        let mut a = 0;
+        let b = &mut a; //~ ERROR mutable references in const fn are unstable
+        *b
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/consts/min_const_fn/mutable_borrow.stderr b/src/test/ui/consts/min_const_fn/mutable_borrow.stderr
new file mode 100644
index 00000000000..7414fa94bfb
--- /dev/null
+++ b/src/test/ui/consts/min_const_fn/mutable_borrow.stderr
@@ -0,0 +1,14 @@
+error: mutable references in const fn are unstable
+  --> $DIR/mutable_borrow.rs:3:9
+   |
+LL |     let b = &mut a; //~ ERROR mutable references in const fn are unstable
+   |         ^
+
+error: mutable references in const fn are unstable
+  --> $DIR/mutable_borrow.rs:12:13
+   |
+LL |         let b = &mut a; //~ ERROR mutable references in const fn are unstable
+   |             ^
+
+error: aborting due to 2 previous errors
+