Rollup merge of #63565 - Centril:deny-nll-migrate-mode, r=matthewjasper
Rust 2018: NLL migrate mode => hard error As per decision on a language team meeting as described in https://github.com/rust-lang/rust/pull/63565#issuecomment-528563744, we refuse to downgrade NLL errors, that AST borrowck accepts, into warnings and keep them as hard errors. cc @rust-lang/lang cc @rust-lang/wg-compiler-nll
This commit is contained in:
commit
4f61eac630
4 changed files with 17 additions and 13 deletions
|
|
@ -1,15 +1,14 @@
|
|||
warning[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-migrate-to-nll.rs:28:21
|
||||
error[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-migrate-to-nll.rs:29:21
|
||||
|
|
||||
LL | let x = &mut block;
|
||||
| ---------- mutable borrow occurs here
|
||||
LL | let p: &'a u8 = &*block.current;
|
||||
| ^^^^^^^^^^^^^^^ immutable borrow occurs here
|
||||
LL | // (use `x` and `p` so enabling NLL doesn't assign overly short lifetimes)
|
||||
...
|
||||
LL | drop(x);
|
||||
| - mutable borrow later used here
|
||||
|
|
||||
= warning: this error has been downgraded to a warning for backwards compatibility with previous releases
|
||||
= warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future
|
||||
= note: for more information, try `rustc --explain E0729`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0502`.
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
//
|
||||
// Therefore, for backwards-compatiblity, under borrowck=migrate the
|
||||
// NLL checks will be emitted as *warnings*.
|
||||
//
|
||||
// In Rust 2018, no errors will be downgraded to warnings.
|
||||
|
||||
// NLL mode makes this compile-fail; we cannot currently encode a
|
||||
// test that is run-pass or compile-fail based on compare-mode. So
|
||||
|
|
@ -16,7 +18,6 @@
|
|||
//[zflag]compile-flags: -Z borrowck=migrate
|
||||
//[edition]edition:2018
|
||||
//[zflag] run-pass
|
||||
//[edition] run-pass
|
||||
|
||||
pub struct Block<'a> {
|
||||
current: &'a u8,
|
||||
|
|
@ -26,6 +27,7 @@ pub struct Block<'a> {
|
|||
fn bump<'a>(mut block: &mut Block<'a>) {
|
||||
let x = &mut block;
|
||||
let p: &'a u8 = &*block.current;
|
||||
//[edition]~^ ERROR cannot borrow `*block.current` as immutable
|
||||
// (use `x` and `p` so enabling NLL doesn't assign overly short lifetimes)
|
||||
drop(x);
|
||||
drop(p);
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
warning[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-migrate-to-nll.rs:28:21
|
||||
--> $DIR/borrowck-migrate-to-nll.rs:29:21
|
||||
|
|
||||
LL | let x = &mut block;
|
||||
| ---------- mutable borrow occurs here
|
||||
LL | let p: &'a u8 = &*block.current;
|
||||
| ^^^^^^^^^^^^^^^ immutable borrow occurs here
|
||||
LL | // (use `x` and `p` so enabling NLL doesn't assign overly short lifetimes)
|
||||
...
|
||||
LL | drop(x);
|
||||
| - mutable borrow later used here
|
||||
|
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue