diff options
| author | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2018-11-23 15:30:10 +0100 |
|---|---|---|
| committer | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2018-11-30 09:43:41 +0100 |
| commit | 7ec3c10d7e1bfac9e93b0138d2a9703d1f722dff (patch) | |
| tree | 209abaa4fd9047236b9bea198a6866215c0f523d | |
| parent | 59c6c4942ab0f8ebfdfa0be7e2cc9f9a811d7585 (diff) | |
Add tests for mutable borrows
| -rw-r--r-- | src/test/ui/consts/const_let_eq.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/consts/min_const_fn/mutable_borrow.rs | 17 | ||||
| -rw-r--r-- | src/test/ui/consts/min_const_fn/mutable_borrow.stderr | 14 |
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 + |
