-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port borrows across yield check to MIR borrowck
- Loading branch information
Showing
4 changed files
with
116 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// compile-flags: -Z borrowck=compare | ||
|
||
#![feature(generators)] | ||
#![feature(nll)] | ||
|
||
fn main() { | ||
|| { | ||
// The reference in `_a` is a Legal with NLL since it ends before the yield | ||
let _a = &mut true; //~ ERROR borrow may still be in use when generator yields (Ast) | ||
let b = &mut true; //~ ERROR borrow may still be in use when generator yields (Ast) | ||
//~^ borrow may still be in use when generator yields (Mir) | ||
yield (); | ||
println!("{}", b); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
error[E0626]: borrow may still be in use when generator yields (Mir) | ||
--> $DIR/generator-with-nll.rs:20:17 | ||
| | ||
20 | let b = &mut true; //~ ERROR borrow may still be in use when generator yields (Ast) | ||
| ^^^^^^^^^ | ||
21 | //~^ borrow may still be in use when generator yields (Mir) | ||
22 | yield (); | ||
| -------- possible yield occurs here | ||
|
||
error[E0626]: borrow may still be in use when generator yields (Ast) | ||
--> $DIR/generator-with-nll.rs:19:23 | ||
| | ||
19 | let _a = &mut true; //~ ERROR borrow may still be in use when generator yields (Ast) | ||
| ^^^^ | ||
... | ||
22 | yield (); | ||
| -------- possible yield occurs here | ||
|
||
error[E0626]: borrow may still be in use when generator yields (Ast) | ||
--> $DIR/generator-with-nll.rs:20:22 | ||
| | ||
20 | let b = &mut true; //~ ERROR borrow may still be in use when generator yields (Ast) | ||
| ^^^^ | ||
21 | //~^ borrow may still be in use when generator yields (Mir) | ||
22 | yield (); | ||
| -------- possible yield occurs here | ||
|
||
error: aborting due to 3 previous errors | ||
|