Auto merge of #52572 - davidtwco:issue-51027, r=nikomatsakis

NLL diagnostics replaced nice closure errors w/ indecipherable free region errors

Fixes #51027.

r? @nikomatsakis
This commit is contained in:
bors 2018-07-22 16:48:09 +00:00
commit 32772fddd5
19 changed files with 367 additions and 157 deletions

View file

@ -4,15 +4,15 @@ warning: not reporting region error due to nll
LL | give_any(|y| x = Some(y));
| ^
error: unsatisfied lifetime constraints
error: borrowed data escapes outside of closure
--> $DIR/issue-45983.rs:17:18
|
LL | let x = None;
| - lifetime `'2` appears in the type of `x`
| - `x` is declared here, outside of the closure body
LL | give_any(|y| x = Some(y));
| - ^^^^^^^^^^^ free region requires that `'1` must outlive `'2`
| - ^^^^^^^^^^^ `y` escapes the closure body here
| |
| lifetime `'1` appears in this argument
| `y` is a reference that is only valid in the closure body
error[E0594]: cannot assign to `x`, as it is not declared as mutable
--> $DIR/issue-45983.rs:17:18

View file

@ -4,17 +4,17 @@ warning: not reporting region error due to nll
LL | let mut lines_to_use: Vec<&CrateId> = Vec::new();
| ^
error: unsatisfied lifetime constraints
error: borrowed data escapes outside of closure
--> $DIR/issue-7573.rs:32:9
|
LL | let mut lines_to_use: Vec<&CrateId> = Vec::new();
| ---------------- lifetime `'2` appears in the type of `lines_to_use`
| ---------------- `lines_to_use` is declared here, outside of the closure body
LL | //~^ NOTE cannot infer an appropriate lifetime
LL | let push_id = |installed_id: &CrateId| {
| - let's call the lifetime of this reference `'1`
| ------------ `installed_id` is a reference that is only valid in the closure body
...
LL | lines_to_use.push(installed_id);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `installed_id` escapes the closure body here
error: aborting due to previous error

View file

@ -4,15 +4,15 @@ warning: not reporting region error due to nll
LL | with_int(|y| x = Some(y));
| ^
error: unsatisfied lifetime constraints
error: borrowed data escapes outside of closure
--> $DIR/regions-escape-bound-fn-2.rs:18:18
|
LL | let mut x = None;
| ----- lifetime `'2` appears in the type of `x`
| ----- `x` is declared here, outside of the closure body
LL | with_int(|y| x = Some(y));
| - ^^^^^^^^^^^ free region requires that `'1` must outlive `'2`
| - ^^^^^^^^^^^ `y` escapes the closure body here
| |
| lifetime `'1` appears in this argument
| `y` is a reference that is only valid in the closure body
error: aborting due to previous error

View file

@ -4,15 +4,15 @@ warning: not reporting region error due to nll
LL | with_int(|y| x = Some(y));
| ^^^^^^^
error: unsatisfied lifetime constraints
error: borrowed data escapes outside of closure
--> $DIR/regions-escape-bound-fn.rs:18:18
|
LL | let mut x: Option<&isize> = None;
| ----- lifetime `'2` appears in the type of `x`
| ----- `x` is declared here, outside of the closure body
LL | with_int(|y| x = Some(y));
| - ^^^^^^^^^^^ free region requires that `'1` must outlive `'2`
| - ^^^^^^^^^^^ `y` escapes the closure body here
| |
| lifetime `'1` appears in this argument
| `y` is a reference that is only valid in the closure body
error: aborting due to previous error

View file

@ -4,15 +4,15 @@ warning: not reporting region error due to nll
LL | with_int(&mut |y| x = Some(y));
| ^^^^^^^
error: unsatisfied lifetime constraints
error: borrowed data escapes outside of closure
--> $DIR/regions-escape-unboxed-closure.rs:16:23
|
LL | let mut x: Option<&isize> = None;
| ----- lifetime `'2` appears in the type of `x`
| ----- `x` is declared here, outside of the closure body
LL | with_int(&mut |y| x = Some(y));
| - ^^^^^^^^^^^ free region requires that `'1` must outlive `'2`
| - ^^^^^^^^^^^ `y` escapes the closure body here
| |
| lifetime `'1` appears in this argument
| `y` is a reference that is only valid in the closure body
error: aborting due to previous error

View file

@ -22,37 +22,37 @@ warning: not reporting region error due to nll
LL | f = Some(x);
| ^^^^^^^
error: unsatisfied lifetime constraints
error: borrowed data escapes outside of closure
--> $DIR/expect-region-supply-region.rs:28:9
|
LL | let mut f: Option<&u32> = None;
| ----- lifetime `'2` appears in the type of `f`
| ----- `f` is declared here, outside of the closure body
LL | closure_expecting_bound(|x| {
| - lifetime `'1` appears in this argument
| - `x` is a reference that is only valid in the closure body
LL | f = Some(x); //~ ERROR borrowed data cannot be stored outside of its closure
| ^^^^^^^^^^^ free region requires that `'1` must outlive `'2`
| ^^^^^^^^^^^ `x` escapes the closure body here
error: unsatisfied lifetime constraints
error: borrowed data escapes outside of closure
--> $DIR/expect-region-supply-region.rs:38:9
|
LL | let mut f: Option<&u32> = None;
| ----- lifetime `'2` appears in the type of `f`
| ----- `f` is declared here, outside of the closure body
LL | closure_expecting_bound(|x: &u32| {
| - let's call the lifetime of this reference `'1`
| - `x` is a reference that is only valid in the closure body
LL | f = Some(x); //~ ERROR borrowed data cannot be stored outside of its closure
| ^^^^^^^^^^^ free region requires that `'1` must outlive `'2`
| ^^^^^^^^^^^ `x` escapes the closure body here
error: unsatisfied lifetime constraints
error: borrowed data escapes outside of closure
--> $DIR/expect-region-supply-region.rs:52:9
|
LL | let mut f: Option<&u32> = None;
| ----- lifetime `'2` appears in the type of `f`
| ----- `f` is declared here, outside of the closure body
...
LL | closure_expecting_bound(|x: &'x u32| {
| - let's call the lifetime of this reference `'1`
| - `x` is a reference that is only valid in the closure body
...
LL | f = Some(x);
| ^^^^^^^^^^^ free region requires that `'1` must outlive `'2`
| ^^^^^^^^^^^ `x` escapes the closure body here
error: aborting due to 3 previous errors

View file

@ -4,11 +4,13 @@ warning: not reporting region error due to nll
LL | static_val(x); //~ ERROR cannot infer
| ^
error: unsatisfied lifetime constraints
error: borrowed data escapes outside of closure
--> $DIR/dyn-trait.rs:32:5
|
LL | fn with_dyn_debug_static<'a>(x: Box<dyn Debug + 'a>) {
| - `x` is a reference that is only valid in the closure body
LL | static_val(x); //~ ERROR cannot infer
| ^^^^^^^^^^^^^ argument requires that `'a` must outlive `'static`
| ^^^^^^^^^^^^^ `x` escapes the closure body here
error: aborting due to previous error

View file

@ -10,13 +10,13 @@ warning: not reporting region error due to nll
LL | self.a(); //~ ERROR cannot infer
| ^
error: unsatisfied lifetime constraints
error: borrowed data escapes outside of closure
--> $DIR/issue-16683.rs:14:9
|
LL | fn b(&self) {
| - let's call the lifetime of this reference `'1`
| ----- `self` is a reference that is only valid in the closure body
LL | self.a(); //~ ERROR cannot infer
| ^^^^^^^^ argument requires that `'1` must outlive `'a`
| ^^^^^^^^ `self` escapes the closure body here
error: aborting due to previous error

View file

@ -10,13 +10,13 @@ warning: not reporting region error due to nll
LL | self.foo();
| ^^^
error: unsatisfied lifetime constraints
error: borrowed data escapes outside of closure
--> $DIR/issue-17758.rs:17:9
|
LL | fn bar(&self) {
| - let's call the lifetime of this reference `'1`
| ----- `self` is a reference that is only valid in the closure body
LL | self.foo();
| ^^^^^^^^^^ argument requires that `'1` must outlive `'a`
| ^^^^^^^^^^ `self` escapes the closure body here
error: aborting due to previous error

View file

@ -4,16 +4,16 @@ warning: not reporting region error due to nll
LL | foo(cell, |cell_a, cell_x| {
| ^^^
error: unsatisfied lifetime constraints
error: borrowed data escapes outside of closure
--> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:33:20
|
LL | foo(cell, |cell_a, cell_x| {
| ------ ------ lifetime `'1` appears in this argument
| ------ ------ `cell_x` is a reference that is only valid in the closure body
| |
| lifetime `'2` appears in this argument
| `cell_a` is declared here, outside of the closure body
LL | //~^ WARNING not reporting region error due to nll
LL | cell_a.set(cell_x.get()); // forces 'x: 'a, error in closure
| ^^^^^^^^^^^^ argument requires that `'1` must outlive `'2`
| ^^^^^^^^^^^^ `cell_x` escapes the closure body here
note: No external requirements
--> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:31:15

View file

@ -23,16 +23,18 @@ LL | | });
= note: number of external vids: 2
= note: where '_#1r: '_#0r
error: unsatisfied lifetime constraints
error: borrowed data escapes outside of closure
--> $DIR/propagate-approximated-shorter-to-static-no-bound.rs:45:5
|
LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
| ------ `cell_a` is a reference that is only valid in the closure body
LL | / establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {
LL | | //~^ ERROR
LL | |
LL | | // Only works if 'x: 'y:
LL | | demand_y(x, y, x.get()) //~ WARNING not reporting region error due to nll
LL | | });
| |______^ argument requires that `'a` must outlive `'static`
| |______^ `cell_a` escapes the closure body here
note: No external requirements
--> $DIR/propagate-approximated-shorter-to-static-no-bound.rs:44:1

View file

@ -23,16 +23,18 @@ LL | | });
= note: number of external vids: 3
= note: where '_#1r: '_#0r
error: unsatisfied lifetime constraints
error: borrowed data escapes outside of closure
--> $DIR/propagate-approximated-shorter-to-static-wrong-bound.rs:48:5
|
LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
| ------ `cell_a` is a reference that is only valid in the closure body
LL | / establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
LL | | //~^ ERROR
LL | | // Only works if 'x: 'y:
LL | | demand_y(x, y, x.get())
LL | | //~^ WARNING not reporting region error due to nll
LL | | });
| |______^ argument requires that `'a` must outlive `'static`
| |______^ `cell_a` escapes the closure body here
note: No external requirements
--> $DIR/propagate-approximated-shorter-to-static-wrong-bound.rs:47:1

View file

@ -1,8 +1,11 @@
error: unsatisfied lifetime constraints
error: borrowed data escapes outside of closure
--> $DIR/issue-50716.rs:25:14
|
LL | fn foo<'a, T: 'static>(s: Box<<&'a T as A>::X>)
| - `s` is a reference that is only valid in the closure body
...
LL | let _x = *s; //~ ERROR
| ^^ assignment requires that `'a` must outlive `'static`
| ^^ `s` escapes the closure body here
error: aborting due to previous error