forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
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#106578 - compiler-errors:recursive-opaque-c…
…losure, r=TaKO8Ki Label closure captures/generator locals that make opaque types recursive cc rust-lang#46415 (comment)
- Loading branch information
Showing
4 changed files
with
99 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#![feature(generators, generator_trait)] | ||
|
||
use std::ops::{Generator, GeneratorState}; | ||
|
||
fn foo() -> impl Generator<Yield = (), Return = ()> { | ||
//~^ ERROR cannot resolve opaque type | ||
//~| NOTE recursive opaque type | ||
//~| NOTE in this expansion of desugaring of | ||
|| { | ||
//~^ NOTE returning here | ||
let mut gen = Box::pin(foo()); | ||
//~^ NOTE generator captures itself here | ||
let mut r = gen.as_mut().resume(()); | ||
while let GeneratorState::Yielded(v) = r { | ||
yield v; | ||
r = gen.as_mut().resume(()); | ||
} | ||
} | ||
} | ||
|
||
fn main() { | ||
foo(); | ||
} |
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,19 @@ | ||
error[E0720]: cannot resolve opaque type | ||
--> $DIR/recursive-generator.rs:5:13 | ||
| | ||
LL | fn foo() -> impl Generator<Yield = (), Return = ()> { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ recursive opaque type | ||
... | ||
LL | / || { | ||
LL | | | ||
LL | | let mut gen = Box::pin(foo()); | ||
| | ------- generator captures itself here | ||
LL | | | ||
... | | ||
LL | | } | ||
LL | | } | ||
| |_____- returning here with type `[generator@$DIR/recursive-generator.rs:9:5: 9:7]` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0720`. |
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