Update test with improved diagnostics

Now, `derived_from_illegal_borrow` is also applied to reborrows, so we
don't show the user a useless error message.
This commit is contained in:
Dylan MacKenzie 2019-11-22 16:14:24 -08:00
parent 66e9f885de
commit 5a3ddcd771
2 changed files with 7 additions and 10 deletions

View File

@ -1,8 +1,11 @@
// Ensure that we point the user to the erroneous borrow but not to any subsequent borrows of that
// initial one.
const _X: i32 = {
let mut a = 5;
let p = &mut a; //~ ERROR references in constants may only refer to immutable values
let p = &mut a; //~ ERROR references in constants may only refer to immutable values
let reborrow = {p}; //~ ERROR references in constants may only refer to immutable values
let reborrow = {p};
let pp = &reborrow;
let ppp = &pp;
***ppp

View File

@ -1,15 +1,9 @@
error[E0017]: references in constants may only refer to immutable values
--> $DIR/const-multi-ref.rs:3:13
--> $DIR/const-multi-ref.rs:6:13
|
LL | let p = &mut a;
| ^^^^^^ constants require immutable values
error[E0017]: references in constants may only refer to immutable values
--> $DIR/const-multi-ref.rs:5:21
|
LL | let reborrow = {p};
| ^ constants require immutable values
error: aborting due to 2 previous errors
error: aborting due to previous error
For more information about this error, try `rustc --explain E0017`.