2017-07-29 09:05:50 -07:00
|
|
|
error[E0626]: borrow may still be in use when generator yields
|
2018-10-04 20:49:38 +02:00
|
|
|
--> $DIR/yield-while-iterating.rs:13:19
|
2017-07-15 06:52:49 -04:00
|
|
|
|
|
2018-02-23 03:42:32 +03:00
|
|
|
LL | for p in &x { //~ ERROR
|
2017-07-15 06:52:49 -04:00
|
|
|
| ^
|
2018-02-23 03:42:32 +03:00
|
|
|
LL | yield();
|
2017-07-15 06:52:49 -04:00
|
|
|
| ------- possible yield occurs here
|
|
|
|
|
|
|
|
error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable
|
2018-10-04 20:49:38 +02:00
|
|
|
--> $DIR/yield-while-iterating.rs:58:20
|
2017-07-15 06:52:49 -04:00
|
|
|
|
|
2018-02-23 03:42:32 +03:00
|
|
|
LL | let mut b = || {
|
2017-07-15 06:52:49 -04:00
|
|
|
| -- mutable borrow occurs here
|
2018-02-23 03:42:32 +03:00
|
|
|
LL | for p in &mut x {
|
2017-07-15 06:52:49 -04:00
|
|
|
| - previous borrow occurs due to use of `x` in closure
|
|
|
|
...
|
2018-02-23 03:42:32 +03:00
|
|
|
LL | println!("{}", x[0]); //~ ERROR
|
2017-07-15 06:52:49 -04:00
|
|
|
| ^ immutable borrow occurs here
|
2018-10-04 20:49:38 +02:00
|
|
|
LL | Pin::new(&mut b).resume();
|
2018-02-23 03:42:32 +03:00
|
|
|
LL | }
|
2017-07-15 06:52:49 -04:00
|
|
|
| - mutable borrow ends here
|
|
|
|
|
|
|
|
error: aborting due to 2 previous errors
|
|
|
|
|
2018-03-03 15:59:40 +01:00
|
|
|
Some errors occurred: E0502, E0626.
|
|
|
|
For more information about an error, try `rustc --explain E0502`.
|