Rollup merge of #55013 - matthewjasper:propagate-generator-bounds, r=nikomatsakis
[NLL] Propagate bounds from generators This used to only be done for closures.
This commit is contained in:
commit
0724efd9a1
6 changed files with 57 additions and 19 deletions
|
|
@ -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`.
|
||||
|
|
@ -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`.
|
||||
21
src/test/ui/generator/generator-region-requirements.rs
Normal file
21
src/test/ui/generator/generator-region-requirements.rs
Normal file
|
|
@ -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() {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue