Add three point error handling to borrowck

Closes #45988
This commit is contained in:
Santiago Pastorino 2017-12-12 17:29:37 -03:00 committed by Niko Matsakis
parent 6d2987ca03
commit 3a185a510d
24 changed files with 274 additions and 23 deletions

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// compile-flags:-Znll -Zborrowck=mir
// compile-flags:-Znll -Zborrowck=mir -Znll-dump-cause
// Test that a structure which tries to store a pointer to `y` into
// `p` (indirectly) fails to compile.

View file

@ -6,6 +6,9 @@ error[E0597]: `y` does not live long enough
...
37 | }
| - borrowed value only lives until here
38 |
39 | deref(p);
| - borrow later used here
|
= note: borrowed value must be valid for lifetime '_#5r...

View file

@ -22,7 +22,7 @@
// basically checking that the MIR type checker correctly enforces the
// closure signature.
// compile-flags:-Znll -Zborrowck=mir -Zverbose
// compile-flags:-Znll -Zborrowck=mir -Znll-dump-cause -Zverbose
#![feature(rustc_attrs)]

View file

@ -31,6 +31,9 @@ error[E0597]: `y` does not live long enough
38 | //~^ ERROR `y` does not live long enough [E0597]
39 | }
| - borrowed value only lives until here
40 |
41 | deref(p);
| - borrow later used here
|
= note: borrowed value must be valid for lifetime '_#6r...

View file

@ -15,7 +15,7 @@
//
// except that the closure does so via a second closure.
// compile-flags:-Znll -Zborrowck=mir -Zverbose
// compile-flags:-Znll -Zborrowck=mir -Znll-dump-cause -Zverbose
#![feature(rustc_attrs)]

View file

@ -58,6 +58,9 @@ error[E0597]: `y` does not live long enough
...
36 | }
| - borrowed value only lives until here
37 |
38 | deref(p);
| - borrow later used here
|
= note: borrowed value must be valid for lifetime '_#4r...

View file

@ -19,7 +19,7 @@
// `'b`. This relationship is propagated to the closure creator,
// which reports an error.
// compile-flags:-Znll -Zborrowck=mir -Zverbose
// compile-flags:-Znll -Zborrowck=mir -Znll-dump-cause -Zverbose
#![feature(rustc_attrs)]

View file

@ -35,6 +35,9 @@ error[E0597]: `y` does not live long enough
...
36 | }
| - borrowed value only lives until here
37 |
38 | deref(p);
| - borrow later used here
|
= note: borrowed value must be valid for lifetime '_#4r...

View file

@ -13,7 +13,7 @@
// a variety of errors from the older, AST-based machinery (notably
// borrowck), and then we get the NLL error at the end.
// compile-flags:-Znll -Zborrowck=compare
// compile-flags:-Znll -Zborrowck=compare -Znll-dump-cause
struct Map {
}

View file

@ -42,6 +42,9 @@ error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as imm
43 | Some(v) => {
44 | map.set(String::new()); // Both AST and MIR error here
| ^^^ mutable borrow occurs here
...
47 | return v;
| - borrow later used here
error: aborting due to 4 previous errors

View file

@ -8,7 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//compile-flags: -Z emit-end-regions -Zborrowck=mir -Z nll
//compile-flags: -Z emit-end-regions -Zborrowck=mir -Z nll -Znll-dump-cause
#![allow(warnings)]

View file

@ -6,6 +6,9 @@ error[E0506]: cannot assign to `x` because it is borrowed
...
31 | x = 1; //~ ERROR cannot assign to `x` because it is borrowed [E0506]
| ^^^^^ assignment to borrowed `x` occurs here
32 | // FIXME ^ Should not error in the future with implicit dtors, only manually implemented ones
33 | }
| - borrow later used here, when `foo` is dropped
error: aborting due to previous error

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//compile-flags: -Z emit-end-regions -Zborrowck=mir -Z nll
//compile-flags: -Z emit-end-regions -Zborrowck=mir -Znll -Znll-dump-cause
#![allow(warnings)]

View file

@ -6,6 +6,8 @@ error[E0506]: cannot assign to `x` because it is borrowed
...
31 | x = 1; //~ ERROR cannot assign to `x` because it is borrowed [E0506]
| ^^^^^ assignment to borrowed `x` occurs here
32 | }
| - borrow later used here, when `foo` is dropped
error: aborting due to previous error

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//compile-flags: -Z emit-end-regions -Zborrowck=mir -Z nll
//compile-flags: -Z emit-end-regions -Zborrowck=mir -Znll -Znll-dump-cause
#![allow(warnings)]

View file

@ -6,6 +6,9 @@ error[E0506]: cannot assign to `x` because it is borrowed
...
32 | x = 1; //~ ERROR cannot assign to `x` because it is borrowed [E0506]
| ^^^^^ assignment to borrowed `x` occurs here
33 | // FIXME ^ This currently errors and it should not.
34 | }
| - borrow later used here, when `foo` is dropped
error: aborting due to previous error

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//compile-flags: -Z emit-end-regions -Zborrowck=mir -Z nll
//compile-flags: -Z emit-end-regions -Zborrowck=mir -Znll -Znll-dump-cause
#![allow(warnings)]

View file

@ -5,6 +5,8 @@ error[E0506]: cannot assign to `x` because it is borrowed
| ------ borrow of `x` occurs here
26 | x = 1; //~ ERROR cannot assign to `x` because it is borrowed [E0506]
| ^^^^^ assignment to borrowed `x` occurs here
27 | }
| - borrow later used here, when `wrap` is dropped
error: aborting due to previous error