File tree 2 files changed +42
-8
lines changed
2 files changed +42
-8
lines changed Original file line number Diff line number Diff line change 8
8
// option. This file may not be copied, modified, or distributed
9
9
// except according to those terms.
10
10
11
+ // compile-flags: -Z borrowck=compare
12
+
11
13
#![ feature( generators, generator_trait) ]
12
14
13
15
use std:: ops:: { GeneratorState , Generator } ;
@@ -19,7 +21,9 @@ fn borrow_local_inline() {
19
21
// (This error occurs because the region shows up in the type of
20
22
// `b` and gets extended by region inference.)
21
23
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)
23
27
yield ( ) ;
24
28
println ! ( "{}" , a) ;
25
29
} ;
@@ -30,7 +34,7 @@ fn borrow_local_inline_done() {
30
34
// No error here -- `a` is not in scope at the point of `yield`.
31
35
let mut b = move || {
32
36
{
33
- let a = & 3 ;
37
+ let a = & mut 3 ;
34
38
}
35
39
yield ( ) ;
36
40
} ;
@@ -45,7 +49,9 @@ fn borrow_local() {
45
49
let mut b = move || {
46
50
let a = 3 ;
47
51
{
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)
49
55
yield ( ) ;
50
56
println ! ( "{}" , b) ;
51
57
}
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
3
3
|
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;
5
23
| ^
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();
7
35
| ------- possible yield occurs here
8
36
9
- error: aborting due to previous error
37
+ error: aborting due to 4 previous errors
10
38
You can’t perform that action at this time.
0 commit comments