1
Fork 0

Fix yield-while-local-borrowed.rs test

This commit is contained in:
John Kåre Alsaker 2018-01-11 19:49:26 +01:00
parent 9b57e60f03
commit bae2988e6f
2 changed files with 42 additions and 8 deletions

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
// compile-flags: -Z borrowck=compare
#![feature(generators, generator_trait)] #![feature(generators, generator_trait)]
use std::ops::{GeneratorState, Generator}; use std::ops::{GeneratorState, Generator};
@ -19,7 +21,9 @@ fn borrow_local_inline() {
// (This error occurs because the region shows up in the type of // (This error occurs because the region shows up in the type of
// `b` and gets extended by region inference.) // `b` and gets extended by region inference.)
let mut b = move || { let mut b = move || {
let a = &3; let a = &mut 3;
//~^ ERROR borrow may still be in use when generator yields (Ast)
//~| ERROR borrow may still be in use when generator yields (Mir)
yield(); yield();
println!("{}", a); println!("{}", a);
}; };
@ -30,7 +34,7 @@ fn borrow_local_inline_done() {
// No error here -- `a` is not in scope at the point of `yield`. // No error here -- `a` is not in scope at the point of `yield`.
let mut b = move || { let mut b = move || {
{ {
let a = &3; let a = &mut 3;
} }
yield(); yield();
}; };
@ -45,7 +49,9 @@ fn borrow_local() {
let mut b = move || { let mut b = move || {
let a = 3; let a = 3;
{ {
let b = &a; //~ ERROR let b = &a;
//~^ ERROR borrow may still be in use when generator yields (Ast)
//~| ERROR borrow may still be in use when generator yields (Mir)
yield(); yield();
println!("{}", b); println!("{}", b);
} }

View file

@ -1,10 +1,38 @@
error[E0626]: borrow may still be in use when generator yields error[E0626]: borrow may still be in use when generator yields (Mir)
--> $DIR/yield-while-local-borrowed.rs:48:22 --> $DIR/yield-while-local-borrowed.rs:24:17
| |
48 | let b = &a; //~ ERROR 24 | let a = &mut 3;
| ^^^^^^
...
27 | yield();
| ------- possible yield occurs here
error[E0626]: borrow may still be in use when generator yields (Ast)
--> $DIR/yield-while-local-borrowed.rs:24:22
|
24 | let a = &mut 3;
| ^ | ^
49 | yield(); ...
27 | yield();
| ------- possible yield occurs here
error[E0626]: borrow may still be in use when generator yields (Ast)
--> $DIR/yield-while-local-borrowed.rs:52:22
|
52 | let b = &a;
| ^
...
55 | yield();
| ------- possible yield occurs here | ------- possible yield occurs here
error: aborting due to previous error error[E0626]: borrow may still be in use when generator yields (Mir)
--> $DIR/yield-while-local-borrowed.rs:52:21
|
52 | let b = &a;
| ^^
...
55 | yield();
| ------- possible yield occurs here
error: aborting due to 4 previous errors