forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#55013 - matthewjasper:propagate-generator-b…
…ounds, r=nikomatsakis [NLL] Propagate bounds from generators This used to only be done for closures.
- Loading branch information
Showing
6 changed files
with
57 additions
and
19 deletions.
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
12 changes: 12 additions & 0 deletions
12
src/test/ui/generator/generator-region-requirements.ast.stderr
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,12 @@ | ||
error[E0621]: explicit lifetime required in the type of `x` | ||
--> $DIR/generator-region-requirements.rs:15:51 | ||
| | ||
LL | fn dangle(x: &mut i32) -> &'static mut i32 { | ||
| -------- help: add explicit lifetime `'static` to the type of `x`: `&'static mut i32` | ||
... | ||
LL | GeneratorState::Complete(c) => return c, | ||
| ^ lifetime `'static` required | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0621`. |
12 changes: 12 additions & 0 deletions
12
src/test/ui/generator/generator-region-requirements.nll.stderr
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,12 @@ | ||
error[E0621]: explicit lifetime required in the type of `x` | ||
--> $DIR/generator-region-requirements.rs:11:9 | ||
| | ||
LL | fn dangle(x: &mut i32) -> &'static mut i32 { | ||
| -------- help: add explicit lifetime `'static` to the type of `x`: `&'static mut i32` | ||
... | ||
LL | x | ||
| ^ lifetime `'static` required | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0621`. |
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,21 @@ | ||
// revisions: ast nll | ||
// ignore-compare-mode-nll | ||
|
||
#![feature(generators, generator_trait)] | ||
#![cfg_attr(nll, feature(nll))] | ||
use std::ops::{Generator, GeneratorState}; | ||
|
||
fn dangle(x: &mut i32) -> &'static mut i32 { | ||
let mut g = || { | ||
yield; | ||
x | ||
}; | ||
loop { | ||
match unsafe { g.resume() } { | ||
GeneratorState::Complete(c) => return c, | ||
GeneratorState::Yielded(_) => (), | ||
} | ||
} | ||
} | ||
|
||
fn main() {} |