Add tests for mutable borrows
This commit is contained in:
parent
59c6c4942a
commit
7ec3c10d7e
3 changed files with 32 additions and 1 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
17
src/test/ui/consts/min_const_fn/mutable_borrow.rs
Normal file
17
src/test/ui/consts/min_const_fn/mutable_borrow.rs
Normal file
|
|
@ -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() {}
|
||||
14
src/test/ui/consts/min_const_fn/mutable_borrow.stderr
Normal file
14
src/test/ui/consts/min_const_fn/mutable_borrow.stderr
Normal file
|
|
@ -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
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue