File tree Expand file tree Collapse file tree 2 files changed +42
-8
lines changed Expand file tree Collapse file tree 2 files changed +42
-8
lines changed Original file line number Diff line number Diff line change 88// option. This file may not be copied, modified, or distributed
99// except according to those terms.
1010
11+ // compile-flags: -Z borrowck=compare
12+
1113#![ feature( generators, generator_trait) ]
1214
1315use std:: ops:: { GeneratorState , Generator } ;
@@ -19,7 +21,9 @@ fn borrow_local_inline() {
1921 // (This error occurs because the region shows up in the type of
2022 // `b` and gets extended by region inference.)
2123 let mut b = move || {
22- let a = & 3 ;
24+ let a = & mut 3 ;
25+ //~^ ERROR borrow may still be in use when generator yields (Ast)
26+ //~| ERROR borrow may still be in use when generator yields (Mir)
2327 yield ( ) ;
2428 println ! ( "{}" , a) ;
2529 } ;
@@ -30,7 +34,7 @@ fn borrow_local_inline_done() {
3034 // No error here -- `a` is not in scope at the point of `yield`.
3135 let mut b = move || {
3236 {
33- let a = & 3 ;
37+ let a = & mut 3 ;
3438 }
3539 yield ( ) ;
3640 } ;
@@ -45,7 +49,9 @@ fn borrow_local() {
4549 let mut b = move || {
4650 let a = 3 ;
4751 {
48- let b = & a; //~ ERROR
52+ let b = & a;
53+ //~^ ERROR borrow may still be in use when generator yields (Ast)
54+ //~| ERROR borrow may still be in use when generator yields (Mir)
4955 yield ( ) ;
5056 println ! ( "{}" , b) ;
5157 }
Original file line number Diff line number Diff line change 1- error[E0626]: borrow may still be in use when generator yields
2- --> $DIR/yield-while-local-borrowed.rs:48:22
1+ error[E0626]: borrow may still be in use when generator yields (Mir)
2+ --> $DIR/yield-while-local-borrowed.rs:24:17
33 |
4- 48 | let b = &a; //~ ERROR
4+ 24 | let a = &mut 3;
5+ | ^^^^^^
6+ ...
7+ 27 | yield();
8+ | ------- possible yield occurs here
9+
10+ error[E0626]: borrow may still be in use when generator yields (Ast)
11+ --> $DIR/yield-while-local-borrowed.rs:24:22
12+ |
13+ 24 | let a = &mut 3;
14+ | ^
15+ ...
16+ 27 | yield();
17+ | ------- possible yield occurs here
18+
19+ error[E0626]: borrow may still be in use when generator yields (Ast)
20+ --> $DIR/yield-while-local-borrowed.rs:52:22
21+ |
22+ 52 | let b = &a;
523 | ^
6- 49 | yield();
24+ ...
25+ 55 | yield();
26+ | ------- possible yield occurs here
27+
28+ error[E0626]: borrow may still be in use when generator yields (Mir)
29+ --> $DIR/yield-while-local-borrowed.rs:52:21
30+ |
31+ 52 | let b = &a;
32+ | ^^
33+ ...
34+ 55 | yield();
735 | ------- possible yield occurs here
836
9- error: aborting due to previous error
37+ error: aborting due to 4 previous errors
1038
You can’t perform that action at this time.
0 commit comments