-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-coroutinesArea: CoroutinesArea: CoroutinesA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Obviously this shouldn't actually work, due to the state type being infinitely sized (at least not without become
/TCO for generators), but it should generate an error similar to recursive types.
Program:
#![feature(generators, conservative_impl_trait, generator_trait)]
use std::ops::{Generator, GeneratorState};
fn foo() -> impl Generator<Yield = (), Return = ()> {
|| {
let mut gen = foo();
let mut r = gen.resume();
while let GeneratorState::Yielded(v) = r {
yield v;
r = gen.resume();
}
}
}
fn main() {
foo();
}
Output:
Compiling playground v0.0.1 (file:///playground)
thread 'rustc' has overflowed its stack
fatal runtime error: stack overflow
error: Could not compile `playground`.
To learn more, run the command again with --verbose.
Expected (something like):
Compiling playground v0.0.1 (file:///playground)
error[E0072]: recursive type `Foo` has infinite size
--> src/main.rs:1:1
|
1 | struct Foo(Foo);
| ^^^^^^^^^^^----^
| | |
| | recursive without indirection
| recursive type has infinite size
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `Foo` representable
error: aborting due to previous error
error: Could not compile `playground`.
To learn more, run the command again with --verbose.
Metadata
Metadata
Assignees
Labels
A-coroutinesArea: CoroutinesArea: CoroutinesA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.