Update tests for new spans for nll errors involving closures

This commit is contained in:
Matthew Jasper 2018-08-01 21:02:10 +01:00
parent 5639e2173b
commit 12af36a5c4
22 changed files with 184 additions and 130 deletions

View File

@ -77,11 +77,11 @@ error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir)
--> $DIR/borrowck-closures-two-mut.rs:24:24 --> $DIR/borrowck-closures-two-mut.rs:24:24
| |
LL | let c1 = to_fn_mut(|| x = 4); LL | let c1 = to_fn_mut(|| x = 4);
| -- - previous borrow occurs due to use of `x` in closure | -- - first borrow occurs due to use of `x` in closure
| | | |
| first mutable borrow occurs here | first mutable borrow occurs here
LL | let c2 = to_fn_mut(|| x = 5); //~ ERROR cannot borrow `x` as mutable more than once LL | let c2 = to_fn_mut(|| x = 5); //~ ERROR cannot borrow `x` as mutable more than once
| ^^ - borrow occurs due to use of `x` in closure | ^^ - second borrow occurs due to use of `x` in closure
| | | |
| second mutable borrow occurs here | second mutable borrow occurs here
LL | //~| ERROR cannot borrow `x` as mutable more than once LL | //~| ERROR cannot borrow `x` as mutable more than once
@ -92,11 +92,11 @@ error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir)
--> $DIR/borrowck-closures-two-mut.rs:36:24 --> $DIR/borrowck-closures-two-mut.rs:36:24
| |
LL | let c1 = to_fn_mut(|| set(&mut x)); LL | let c1 = to_fn_mut(|| set(&mut x));
| -- - previous borrow occurs due to use of `x` in closure | -- - first borrow occurs due to use of `x` in closure
| | | |
| first mutable borrow occurs here | first mutable borrow occurs here
LL | let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once LL | let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once
| ^^ - borrow occurs due to use of `x` in closure | ^^ - second borrow occurs due to use of `x` in closure
| | | |
| second mutable borrow occurs here | second mutable borrow occurs here
LL | //~| ERROR cannot borrow `x` as mutable more than once LL | //~| ERROR cannot borrow `x` as mutable more than once
@ -107,11 +107,11 @@ error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir)
--> $DIR/borrowck-closures-two-mut.rs:44:24 --> $DIR/borrowck-closures-two-mut.rs:44:24
| |
LL | let c1 = to_fn_mut(|| x = 5); LL | let c1 = to_fn_mut(|| x = 5);
| -- - previous borrow occurs due to use of `x` in closure | -- - first borrow occurs due to use of `x` in closure
| | | |
| first mutable borrow occurs here | first mutable borrow occurs here
LL | let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once LL | let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once
| ^^ - borrow occurs due to use of `x` in closure | ^^ - second borrow occurs due to use of `x` in closure
| | | |
| second mutable borrow occurs here | second mutable borrow occurs here
LL | //~| ERROR cannot borrow `x` as mutable more than once LL | //~| ERROR cannot borrow `x` as mutable more than once
@ -122,11 +122,11 @@ error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir)
--> $DIR/borrowck-closures-two-mut.rs:52:24 --> $DIR/borrowck-closures-two-mut.rs:52:24
| |
LL | let c1 = to_fn_mut(|| x = 5); LL | let c1 = to_fn_mut(|| x = 5);
| -- - previous borrow occurs due to use of `x` in closure | -- - first borrow occurs due to use of `x` in closure
| | | |
| first mutable borrow occurs here | first mutable borrow occurs here
LL | let c2 = to_fn_mut(|| { let _y = to_fn_mut(|| set(&mut x)); }); // (nested closure) LL | let c2 = to_fn_mut(|| { let _y = to_fn_mut(|| set(&mut x)); }); // (nested closure)
| ^^ - borrow occurs due to use of `x` in closure | ^^ - second borrow occurs due to use of `x` in closure
| | | |
| second mutable borrow occurs here | second mutable borrow occurs here
... ...
@ -137,11 +137,11 @@ error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir)
--> $DIR/borrowck-closures-two-mut.rs:65:24 --> $DIR/borrowck-closures-two-mut.rs:65:24
| |
LL | let c1 = to_fn_mut(|| set(&mut *x.f)); LL | let c1 = to_fn_mut(|| set(&mut *x.f));
| -- - previous borrow occurs due to use of `x` in closure | -- - first borrow occurs due to use of `x` in closure
| | | |
| first mutable borrow occurs here | first mutable borrow occurs here
LL | let c2 = to_fn_mut(|| set(&mut *x.f)); LL | let c2 = to_fn_mut(|| set(&mut *x.f));
| ^^ - borrow occurs due to use of `x` in closure | ^^ - second borrow occurs due to use of `x` in closure
| | | |
| second mutable borrow occurs here | second mutable borrow occurs here
... ...

View File

@ -1,8 +1,10 @@
error[E0597]: `books` does not live long enough error[E0597]: `books` does not live long enough
--> $DIR/borrowck-escaping-closure-error-1.rs:23:11 --> $DIR/borrowck-escaping-closure-error-1.rs:23:14
| |
LL | spawn(|| books.push(4)); LL | spawn(|| books.push(4));
| ^^^^^^^^^^^^^^^^ borrowed value does not live long enough | -- ^^^^^ borrowed value does not live long enough
| |
| value captured here
LL | //~^ ERROR E0373 LL | //~^ ERROR E0373
LL | } LL | }
| - `books` dropped here while still borrowed | - `books` dropped here while still borrowed

View File

@ -1,8 +1,10 @@
error[E0597]: `books` does not live long enough error[E0597]: `books` does not live long enough
--> $DIR/borrowck-escaping-closure-error-2.rs:21:14 --> $DIR/borrowck-escaping-closure-error-2.rs:21:17
| |
LL | Box::new(|| books.push(4)) LL | Box::new(|| books.push(4))
| ^^^^^^^^^^^^^^^^ borrowed value does not live long enough | -- ^^^^^ borrowed value does not live long enough
| |
| value captured here
LL | //~^ ERROR E0373 LL | //~^ ERROR E0373
LL | } LL | }
| - `books` dropped here while still borrowed | - `books` dropped here while still borrowed

View File

@ -1,17 +1,16 @@
error[E0505]: cannot move out of `fancy_num` because it is borrowed error[E0505]: cannot move out of `fancy_num` because it is borrowed
--> $DIR/E0504.rs:19:13 --> $DIR/E0504.rs:19:13
| |
LL | let fancy_ref = &fancy_num; LL | let fancy_ref = &fancy_num;
| ---------- borrow of `fancy_num` occurs here | ---------- borrow of `fancy_num` occurs here
LL | LL |
LL | let x = move || { LL | let x = move || {
| _____________^ | ^^^^^^^ move out of `fancy_num` occurs here
LL | | println!("child function: {}", fancy_num.num); //~ ERROR E0504 LL | println!("child function: {}", fancy_num.num); //~ ERROR E0504
LL | | }; | --------- move occurs due to use in closure
| |_____^ move out of `fancy_num` occurs here
... ...
LL | println!("main function: {}", fancy_ref.num); LL | println!("main function: {}", fancy_ref.num);
| ------------- borrow later used here | ------------- borrow later used here
error: aborting due to previous error error: aborting due to previous error

View File

@ -5,7 +5,7 @@ LL | let mut test = |foo: &Foo| {
| ----------- mutable borrow occurs here | ----------- mutable borrow occurs here
LL | println!("access {}", foo.x); LL | println!("access {}", foo.x);
LL | ptr = box Foo { x: ptr.x + 1 }; LL | ptr = box Foo { x: ptr.x + 1 };
| --- previous borrow occurs due to use of `ptr` in closure | --- first borrow occurs due to use of `ptr` in closure
... ...
LL | test(&*ptr); LL | test(&*ptr);
| -----^^^^^- | -----^^^^^-

View File

@ -2,7 +2,9 @@ error[E0505]: cannot move out of `v` because it is borrowed
--> $DIR/issue-11873.rs:14:14 --> $DIR/issue-11873.rs:14:14
| |
LL | let mut f = || v.push(2); LL | let mut f = || v.push(2);
| ------------ borrow of `v` occurs here | -- - borrow occurs due to use in closure
| |
| borrow of `v` occurs here
LL | let _w = v; //~ ERROR: cannot move out of `v` LL | let _w = v; //~ ERROR: cannot move out of `v`
| ^ move out of `v` occurs here | ^ move out of `v` occurs here
LL | LL |

View File

@ -2,11 +2,11 @@ error[E0499]: cannot borrow `y` as mutable more than once at a time
--> $DIR/issue-18783.rs:17:21 --> $DIR/issue-18783.rs:17:21
| |
LL | c.push(Box::new(|| y = 0)); LL | c.push(Box::new(|| y = 0));
| -- - previous borrow occurs due to use of `y` in closure | -- - first borrow occurs due to use of `y` in closure
| | | |
| first mutable borrow occurs here | first mutable borrow occurs here
LL | c.push(Box::new(|| y = 0)); LL | c.push(Box::new(|| y = 0));
| ^^ - borrow occurs due to use of `y` in closure | ^^ - second borrow occurs due to use of `y` in closure
| | | |
| second mutable borrow occurs here | second mutable borrow occurs here
LL | //~^ ERROR cannot borrow `y` as mutable more than once at a time LL | //~^ ERROR cannot borrow `y` as mutable more than once at a time
@ -17,11 +17,11 @@ error[E0499]: cannot borrow `y` as mutable more than once at a time
--> $DIR/issue-18783.rs:26:29 --> $DIR/issue-18783.rs:26:29
| |
LL | Push::push(&c, Box::new(|| y = 0)); LL | Push::push(&c, Box::new(|| y = 0));
| -- - previous borrow occurs due to use of `y` in closure | -- - first borrow occurs due to use of `y` in closure
| | | |
| first mutable borrow occurs here | first mutable borrow occurs here
LL | Push::push(&c, Box::new(|| y = 0)); LL | Push::push(&c, Box::new(|| y = 0));
| ^^ - borrow occurs due to use of `y` in closure | ^^ - second borrow occurs due to use of `y` in closure
| | | |
| second mutable borrow occurs here | second mutable borrow occurs here
LL | //~^ ERROR cannot borrow `y` as mutable more than once at a time LL | //~^ ERROR cannot borrow `y` as mutable more than once at a time

View File

@ -2,7 +2,9 @@ error[E0382]: use of moved value: `x`
--> $DIR/issue-24357.rs:16:12 --> $DIR/issue-24357.rs:16:12
| |
LL | let f = move || { let y = x; }; LL | let f = move || { let y = x; };
| ---------------------- value moved here | ------- - variable moved due to use in closure
| |
| value moved into closure here
LL | //~^ NOTE value moved (into closure) here LL | //~^ NOTE value moved (into closure) here
LL | let z = x; LL | let z = x;
| ^ value used here after move | ^ value used here after move

View File

@ -1,11 +1,13 @@
error[E0505]: cannot move out of `b` because it is borrowed error[E0505]: cannot move out of `b` because it is borrowed
--> $DIR/issue-27282-move-match-input-into-guard.rs:26:16 --> $DIR/issue-27282-move-match-input-into-guard.rs:26:17
| |
LL | match b { LL | match b {
| - borrow of `b` occurs here | - borrow of `b` occurs here
LL | &mut false => {}, LL | &mut false => {},
LL | _ if { (|| { let bar = b; *bar = false; })(); LL | _ if { (|| { let bar = b; *bar = false; })();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ move out of `b` occurs here | ^^ - move occurs due to use in closure
| |
| move out of `b` occurs here
... ...
LL | &mut true => { println!("You might think we should get here"); }, LL | &mut true => { println!("You might think we should get here"); },
| --------- borrow later used here | --------- borrow later used here
@ -14,7 +16,9 @@ error[E0382]: use of moved value: `*b`
--> $DIR/issue-27282-move-match-input-into-guard.rs:29:14 --> $DIR/issue-27282-move-match-input-into-guard.rs:29:14
| |
LL | _ if { (|| { let bar = b; *bar = false; })(); LL | _ if { (|| { let bar = b; *bar = false; })();
| ----------------------------------- value moved here | -- - variable moved due to use in closure
| |
| value moved into closure here
... ...
LL | &mut true => { println!("You might think we should get here"); }, LL | &mut true => { println!("You might think we should get here"); },
| ^^^^ value used here after move | ^^^^ value used here after move

View File

@ -5,7 +5,7 @@ LL | match x {
| - borrow occurs here | - borrow occurs here
... ...
LL | (|| { *x = None; drop(force_fn_once); })(); LL | (|| { *x = None; drop(force_fn_once); })();
| ^^ - borrow occurs due to use of `x` in closure | ^^ - second borrow occurs due to use of `x` in closure
| | | |
| closure construction occurs here | closure construction occurs here
... ...

View File

@ -5,7 +5,7 @@ LL | match x {
| - borrow occurs here | - borrow occurs here
... ...
LL | (|| { *x = None; drop(force_fn_once); })(); LL | (|| { *x = None; drop(force_fn_once); })();
| ^^ - borrow occurs due to use of `x` in closure | ^^ - second borrow occurs due to use of `x` in closure
| | | |
| closure construction occurs here | closure construction occurs here
... ...

View File

@ -5,10 +5,12 @@ LL | id(Box::new(|| *v))
| ^^ cannot move out of captured variable in an `FnMut` closure | ^^ cannot move out of captured variable in an `FnMut` closure
error[E0597]: `v` does not live long enough error[E0597]: `v` does not live long enough
--> $DIR/issue-4335.rs:16:17 --> $DIR/issue-4335.rs:16:21
| |
LL | id(Box::new(|| *v)) LL | id(Box::new(|| *v))
| ^^^^^ borrowed value does not live long enough | -- ^ borrowed value does not live long enough
| |
| value captured here
... ...
LL | } LL | }
| - `v` dropped here while still borrowed | - `v` dropped here while still borrowed

View File

@ -2,7 +2,9 @@ error[E0505]: cannot move out of `x` because it is borrowed
--> $DIR/issue-6801.rs:29:13 --> $DIR/issue-6801.rs:29:13
| |
LL | let sq = || { *x * *x }; LL | let sq = || { *x * *x };
| -------------- borrow of `x` occurs here | -- - borrow occurs due to use in closure
| |
| borrow of `x` occurs here
LL | LL |
LL | twice(x); //~ ERROR: cannot move out of LL | twice(x); //~ ERROR: cannot move out of
| ^ move out of `x` occurs here | ^ move out of `x` occurs here

View File

@ -13,7 +13,7 @@
#![allow(unused)] #![allow(unused)]
#![feature(nll)] #![feature(nll)]
// Should have one error per assigment // Should have one error per assignment
fn one_closure(x: i32) { fn one_closure(x: i32) {
|| ||

View File

@ -27,8 +27,8 @@ fn test() {
{ {
let y = 22; let y = 22;
let mut closure = || { //~ ERROR `y` does not live long enough [E0597] let mut closure = || {
let mut closure1 = || p = &y; let mut closure1 = || p = &y; //~ ERROR `y` does not live long enough [E0597]
closure1(); closure1();
}; };

View File

@ -1,7 +1,7 @@
note: External requirements note: External requirements
--> $DIR/escape-upvar-nested.rs:31:32 --> $DIR/escape-upvar-nested.rs:31:32
| |
LL | let mut closure1 = || p = &y; LL | let mut closure1 = || p = &y; //~ ERROR `y` does not live long enough [E0597]
| ^^^^^^^^^ | ^^^^^^^^^
| |
= note: defining type: DefId(0/1:10 ~ escape_upvar_nested[317d]::test[0]::{{closure}}[0]::{{closure}}[0]) with closure substs [ = note: defining type: DefId(0/1:10 ~ escape_upvar_nested[317d]::test[0]::{{closure}}[0]::{{closure}}[0]) with closure substs [
@ -16,9 +16,9 @@ LL | let mut closure1 = || p = &y;
note: External requirements note: External requirements
--> $DIR/escape-upvar-nested.rs:30:27 --> $DIR/escape-upvar-nested.rs:30:27
| |
LL | let mut closure = || { //~ ERROR `y` does not live long enough [E0597] LL | let mut closure = || {
| ___________________________^ | ___________________________^
LL | | let mut closure1 = || p = &y; LL | | let mut closure1 = || p = &y; //~ ERROR `y` does not live long enough [E0597]
LL | | closure1(); LL | | closure1();
LL | | }; LL | | };
| |_________^ | |_________^
@ -47,20 +47,18 @@ LL | | }
= note: defining type: DefId(0/0:3 ~ escape_upvar_nested[317d]::test[0]) with substs [] = note: defining type: DefId(0/0:3 ~ escape_upvar_nested[317d]::test[0]) with substs []
error[E0597]: `y` does not live long enough error[E0597]: `y` does not live long enough
--> $DIR/escape-upvar-nested.rs:30:27 --> $DIR/escape-upvar-nested.rs:31:40
| |
LL | let mut closure = || { //~ ERROR `y` does not live long enough [E0597] LL | let mut closure = || {
| ___________________________^ | -- value captured here
LL | | let mut closure1 = || p = &y; LL | let mut closure1 = || p = &y; //~ ERROR `y` does not live long enough [E0597]
LL | | closure1(); | ^ borrowed value does not live long enough
LL | | };
| |_________^ borrowed value does not live long enough
... ...
LL | } LL | }
| - `y` dropped here while still borrowed | - `y` dropped here while still borrowed
LL | LL |
LL | deref(p); LL | deref(p);
| - borrow later used here | - borrow later used here
error: aborting due to previous error error: aborting due to previous error

View File

@ -28,10 +28,12 @@ LL | | }
= note: defining type: DefId(0/0:3 ~ escape_upvar_ref[317d]::test[0]) with substs [] = note: defining type: DefId(0/0:3 ~ escape_upvar_ref[317d]::test[0]) with substs []
error[E0597]: `y` does not live long enough error[E0597]: `y` does not live long enough
--> $DIR/escape-upvar-ref.rs:33:27 --> $DIR/escape-upvar-ref.rs:33:35
| |
LL | let mut closure = || p = &y; LL | let mut closure = || p = &y;
| ^^^^^^^^^ borrowed value does not live long enough | -- ^ borrowed value does not live long enough
| |
| value captured here
... ...
LL | } LL | }
| - `y` dropped here while still borrowed | - `y` dropped here while still borrowed

View File

@ -8,7 +8,7 @@ LL | self.thing.bar(|| {
| || | ||
LL | || //~^ ERROR cannot borrow `self.thing` as mutable because it is also borrowed as immutable [E0502] LL | || //~^ ERROR cannot borrow `self.thing` as mutable because it is also borrowed as immutable [E0502]
LL | || &self.number; LL | || &self.number;
| || ---- previous borrow occurs due to use of `self` in closure | || ---- first borrow occurs due to use of `self` in closure
LL | || }); LL | || });
| || ^ | || ^
| ||__________| | ||__________|

View File

@ -1,44 +1,54 @@
error[E0597]: `x` does not live long enough error[E0597]: `x` does not live long enough
--> $DIR/region-borrow-params-issue-29793-small.rs:19:17 --> $DIR/region-borrow-params-issue-29793-small.rs:19:34
| |
LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough | --------- ^ borrowed value does not live long enough
| |
| value captured here
... ...
LL | }; LL | };
| - `x` dropped here while still borrowed | - `x` dropped here while still borrowed
error[E0597]: `y` does not live long enough error[E0597]: `y` does not live long enough
--> $DIR/region-borrow-params-issue-29793-small.rs:19:17 --> $DIR/region-borrow-params-issue-29793-small.rs:19:45
| |
LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough | --------- ^ borrowed value does not live long enough
| |
| value captured here
... ...
LL | }; LL | };
| - `y` dropped here while still borrowed | - `y` dropped here while still borrowed
error[E0597]: `x` does not live long enough error[E0597]: `x` does not live long enough
--> $DIR/region-borrow-params-issue-29793-small.rs:34:17 --> $DIR/region-borrow-params-issue-29793-small.rs:34:34
| |
LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough | --------- ^ borrowed value does not live long enough
| |
| value captured here
... ...
LL | }; LL | };
| - `x` dropped here while still borrowed | - `x` dropped here while still borrowed
error[E0597]: `y` does not live long enough error[E0597]: `y` does not live long enough
--> $DIR/region-borrow-params-issue-29793-small.rs:34:17 --> $DIR/region-borrow-params-issue-29793-small.rs:34:45
| |
LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough | --------- ^ borrowed value does not live long enough
| |
| value captured here
... ...
LL | }; LL | };
| - `y` dropped here while still borrowed | - `y` dropped here while still borrowed
error[E0597]: `x` does not live long enough error[E0597]: `x` does not live long enough
--> $DIR/region-borrow-params-issue-29793-small.rs:65:17 --> $DIR/region-borrow-params-issue-29793-small.rs:65:34
| |
LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough | --------- ^ borrowed value does not live long enough
| |
| value captured here
... ...
LL | }; LL | };
| - `x` dropped here while still borrowed | - `x` dropped here while still borrowed
@ -50,10 +60,12 @@ LL | fn g<'a>(x: usize, y:usize) -> Box<Fn(bool) -> usize + 'a> {
| ^^ | ^^
error[E0597]: `y` does not live long enough error[E0597]: `y` does not live long enough
--> $DIR/region-borrow-params-issue-29793-small.rs:65:17 --> $DIR/region-borrow-params-issue-29793-small.rs:65:45
| |
LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough | --------- ^ borrowed value does not live long enough
| |
| value captured here
... ...
LL | }; LL | };
| - `y` dropped here while still borrowed | - `y` dropped here while still borrowed
@ -65,10 +77,12 @@ LL | fn g<'a>(x: usize, y:usize) -> Box<Fn(bool) -> usize + 'a> {
| ^^ | ^^
error[E0597]: `x` does not live long enough error[E0597]: `x` does not live long enough
--> $DIR/region-borrow-params-issue-29793-small.rs:76:17 --> $DIR/region-borrow-params-issue-29793-small.rs:76:34
| |
LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough | --------- ^ borrowed value does not live long enough
| |
| value captured here
... ...
LL | }; LL | };
| - `x` dropped here while still borrowed | - `x` dropped here while still borrowed
@ -80,10 +94,12 @@ LL | fn g<'a>(x: usize, y:usize) -> Box<Fn(bool) -> usize + 'a> {
| ^^ | ^^
error[E0597]: `y` does not live long enough error[E0597]: `y` does not live long enough
--> $DIR/region-borrow-params-issue-29793-small.rs:76:17 --> $DIR/region-borrow-params-issue-29793-small.rs:76:45
| |
LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough | --------- ^ borrowed value does not live long enough
| |
| value captured here
... ...
LL | }; LL | };
| - `y` dropped here while still borrowed | - `y` dropped here while still borrowed
@ -95,10 +111,12 @@ LL | fn g<'a>(x: usize, y:usize) -> Box<Fn(bool) -> usize + 'a> {
| ^^ | ^^
error[E0597]: `x` does not live long enough error[E0597]: `x` does not live long enough
--> $DIR/region-borrow-params-issue-29793-small.rs:100:21 --> $DIR/region-borrow-params-issue-29793-small.rs:100:38
| |
LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough | --------- ^ borrowed value does not live long enough
| |
| value captured here
... ...
LL | } LL | }
| - `x` dropped here while still borrowed | - `x` dropped here while still borrowed
@ -110,10 +128,12 @@ LL | fn g<'a>(&self, x: usize, y:usize) -> Box<Fn(bool) -> usize + 'a> {
| ^^ | ^^
error[E0597]: `y` does not live long enough error[E0597]: `y` does not live long enough
--> $DIR/region-borrow-params-issue-29793-small.rs:100:21 --> $DIR/region-borrow-params-issue-29793-small.rs:100:49
| |
LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough | --------- ^ borrowed value does not live long enough
| |
| value captured here
... ...
LL | } LL | }
| - `y` dropped here while still borrowed | - `y` dropped here while still borrowed
@ -125,10 +145,12 @@ LL | fn g<'a>(&self, x: usize, y:usize) -> Box<Fn(bool) -> usize + 'a> {
| ^^ | ^^
error[E0597]: `x` does not live long enough error[E0597]: `x` does not live long enough
--> $DIR/region-borrow-params-issue-29793-small.rs:114:21 --> $DIR/region-borrow-params-issue-29793-small.rs:114:38
| |
LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough | --------- ^ borrowed value does not live long enough
| |
| value captured here
... ...
LL | } LL | }
| - `x` dropped here while still borrowed | - `x` dropped here while still borrowed
@ -140,10 +162,12 @@ LL | fn g<'a>(&self, x: usize, y:usize) -> Box<Fn(bool) -> usize + 'a> {
| ^^ | ^^
error[E0597]: `y` does not live long enough error[E0597]: `y` does not live long enough
--> $DIR/region-borrow-params-issue-29793-small.rs:114:21 --> $DIR/region-borrow-params-issue-29793-small.rs:114:49
| |
LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough | --------- ^ borrowed value does not live long enough
| |
| value captured here
... ...
LL | } LL | }
| - `y` dropped here while still borrowed | - `y` dropped here while still borrowed
@ -155,10 +179,12 @@ LL | fn g<'a>(&self, x: usize, y:usize) -> Box<Fn(bool) -> usize + 'a> {
| ^^ | ^^
error[E0597]: `x` does not live long enough error[E0597]: `x` does not live long enough
--> $DIR/region-borrow-params-issue-29793-small.rs:142:21 --> $DIR/region-borrow-params-issue-29793-small.rs:142:38
| |
LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough | --------- ^ borrowed value does not live long enough
| |
| value captured here
... ...
LL | } LL | }
| - `x` dropped here while still borrowed | - `x` dropped here while still borrowed
@ -170,10 +196,12 @@ LL | fn g<'a>(&self, x: usize, y:usize) -> Box<Fn(bool) -> usize + 'a> {
| ^^ | ^^
error[E0597]: `y` does not live long enough error[E0597]: `y` does not live long enough
--> $DIR/region-borrow-params-issue-29793-small.rs:142:21 --> $DIR/region-borrow-params-issue-29793-small.rs:142:49
| |
LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough | --------- ^ borrowed value does not live long enough
| |
| value captured here
... ...
LL | } LL | }
| - `y` dropped here while still borrowed | - `y` dropped here while still borrowed
@ -185,10 +213,12 @@ LL | fn g<'a>(&self, x: usize, y:usize) -> Box<Fn(bool) -> usize + 'a> {
| ^^ | ^^
error[E0597]: `x` does not live long enough error[E0597]: `x` does not live long enough
--> $DIR/region-borrow-params-issue-29793-small.rs:157:21 --> $DIR/region-borrow-params-issue-29793-small.rs:157:38
| |
LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough | --------- ^ borrowed value does not live long enough
| |
| value captured here
... ...
LL | } LL | }
| - `x` dropped here while still borrowed | - `x` dropped here while still borrowed
@ -200,10 +230,12 @@ LL | fn g<'a>(&self, x: usize, y:usize) -> Box<Fn(bool) -> usize + 'a> {
| ^^ | ^^
error[E0597]: `y` does not live long enough error[E0597]: `y` does not live long enough
--> $DIR/region-borrow-params-issue-29793-small.rs:157:21 --> $DIR/region-borrow-params-issue-29793-small.rs:157:49
| |
LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough | --------- ^ borrowed value does not live long enough
| |
| value captured here
... ...
LL | } LL | }
| - `y` dropped here while still borrowed | - `y` dropped here while still borrowed
@ -215,10 +247,12 @@ LL | fn g<'a>(&self, x: usize, y:usize) -> Box<Fn(bool) -> usize + 'a> {
| ^^ | ^^
error[E0597]: `x` does not live long enough error[E0597]: `x` does not live long enough
--> $DIR/region-borrow-params-issue-29793-small.rs:185:21 --> $DIR/region-borrow-params-issue-29793-small.rs:185:38
| |
LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough | --------- ^ borrowed value does not live long enough
| |
| value captured here
... ...
LL | } LL | }
| - `x` dropped here while still borrowed | - `x` dropped here while still borrowed
@ -230,10 +264,12 @@ LL | fn g<'a>(&self, x: usize, y:usize) -> Box<Fn(bool) -> usize + 'a> {
| ^^ | ^^
error[E0597]: `y` does not live long enough error[E0597]: `y` does not live long enough
--> $DIR/region-borrow-params-issue-29793-small.rs:185:21 --> $DIR/region-borrow-params-issue-29793-small.rs:185:49
| |
LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough | --------- ^ borrowed value does not live long enough
| |
| value captured here
... ...
LL | } LL | }
| - `y` dropped here while still borrowed | - `y` dropped here while still borrowed
@ -245,10 +281,12 @@ LL | fn g<'a>(&self, x: usize, y:usize) -> Box<Fn(bool) -> usize + 'a> {
| ^^ | ^^
error[E0597]: `x` does not live long enough error[E0597]: `x` does not live long enough
--> $DIR/region-borrow-params-issue-29793-small.rs:199:21 --> $DIR/region-borrow-params-issue-29793-small.rs:199:38
| |
LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough | --------- ^ borrowed value does not live long enough
| |
| value captured here
... ...
LL | } LL | }
| - `x` dropped here while still borrowed | - `x` dropped here while still borrowed
@ -260,10 +298,12 @@ LL | fn g<'a>(&self, x: usize, y:usize) -> Box<Fn(bool) -> usize + 'a> {
| ^^ | ^^
error[E0597]: `y` does not live long enough error[E0597]: `y` does not live long enough
--> $DIR/region-borrow-params-issue-29793-small.rs:199:21 --> $DIR/region-borrow-params-issue-29793-small.rs:199:49
| |
LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough | --------- ^ borrowed value does not live long enough
| |
| value captured here
... ...
LL | } LL | }
| - `y` dropped here while still borrowed | - `y` dropped here while still borrowed

View File

@ -1,13 +1,14 @@
error[E0597]: `y` does not live long enough error[E0597]: `y` does not live long enough
--> $DIR/regions-nested-fns-2.rs:16:9 --> $DIR/regions-nested-fns-2.rs:18:25
| |
LL | / |z| { LL | |z| {
LL | | //~^ ERROR E0373 | --- value captured here
LL | | if false { &y } else { z } LL | //~^ ERROR E0373
LL | | }); LL | if false { &y } else { z }
| |_________^ borrowed value does not live long enough | ^ borrowed value does not live long enough
LL | } LL | });
| - `y` dropped here while still borrowed LL | }
| - `y` dropped here while still borrowed
| |
= note: borrowed value must be valid for the static lifetime... = note: borrowed value must be valid for the static lifetime...

View File

@ -8,7 +8,7 @@ LL | f(Box::new(|| {
| | | |
LL | | //~^ ERROR: cannot borrow `f` as mutable more than once LL | | //~^ ERROR: cannot borrow `f` as mutable more than once
LL | | f((Box::new(|| {}))) LL | | f((Box::new(|| {})))
| | - borrow occurs due to use of `f` in closure | | - second borrow occurs due to use of `f` in closure
LL | | })); LL | | }));
| |_______- borrow later used here | |_______- borrow later used here
@ -37,18 +37,17 @@ LL | foo(f);
error[E0505]: cannot move out of `f` because it is borrowed error[E0505]: cannot move out of `f` because it is borrowed
--> $DIR/borrowck-call-is-borrow-issue-12224.rs:65:16 --> $DIR/borrowck-call-is-borrow-issue-12224.rs:65:16
| |
LL | f(Box::new(|a| { LL | f(Box::new(|a| {
| _____-__________^ | - ^^^ move out of `f` occurs here
| | | | |
| |_____borrow of `f` occurs here | _____borrow of `f` occurs here
| || | |
LL | || foo(f); LL | | foo(f);
LL | || //~^ ERROR cannot move `f` into closure because it is borrowed | | - move occurs due to use in closure
LL | || //~| ERROR cannot move out of captured outer variable in an `FnMut` closure LL | | //~^ ERROR cannot move `f` into closure because it is borrowed
LL | || }), 3); LL | | //~| ERROR cannot move out of captured outer variable in an `FnMut` closure
| ||_____^____- borrow later used here LL | | }), 3);
| |_____| | |__________- borrow later used here
| move out of `f` occurs here
error: aborting due to 5 previous errors error: aborting due to 5 previous errors

View File

@ -11,19 +11,18 @@ LL | bad.join();
| --- borrow later used here | --- borrow later used here
error[E0597]: `y` does not live long enough error[E0597]: `y` does not live long enough
--> $DIR/send-is-not-static-ensures-scoping.rs:29:16 --> $DIR/send-is-not-static-ensures-scoping.rs:30:22
| |
LL | scoped(|| { LL | scoped(|| {
| ________________^ | -- value captured here
LL | | let _z = y; LL | let _z = y;
LL | | //~^ ERROR `y` does not live long enough | ^ borrowed value does not live long enough
LL | | }) ...
| |_________^ borrowed value does not live long enough LL | };
LL | }; | - `y` dropped here while still borrowed
| - `y` dropped here while still borrowed
LL | LL |
LL | bad.join(); LL | bad.join();
| --- borrow later used here | --- borrow later used here
error: aborting due to 2 previous errors error: aborting due to 2 previous errors