Improved closure errors.
This commit is contained in:
parent
24c5751197
commit
571eec627c
11 changed files with 299 additions and 131 deletions
|
|
@ -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));
|
||||
| - ^^^^^^^^^^^ assignment 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
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
| - ^^^^^^^^^^^ assignment 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
|
||||
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
| - ^^^^^^^^^^^ assignment 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
|
||||
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
| - ^^^^^^^^^^^ assignment 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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
| ^^^^^^^^^^^ assignment 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
|
||||
| ^^^^^^^^^^^ assignment 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);
|
||||
| ^^^^^^^^^^^ assignment requires that `'1` must outlive `'2`
|
||||
| ^^^^^^^^^^^ `x` escapes the closure body here
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue