Closed
Description
The following code does not compile on nightly (and 1.29.1 stable) (playground):
fn foo() -> impl Iterator<Item = i32> {
panic!()
}
I expected this code to compile, but instead I get the following error:
error[E0277]: the trait bound `(): std::iter::Iterator` is not satisfied
--> src/lib.rs:1:13
|
1 | fn foo() -> impl Iterator<Item = i32> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^ `()` is not an iterator; maybe try calling `.iter()` or a similar method
|
= help: the trait `std::iter::Iterator` is not implemented for `()`
= note: the return type of a function must have a statically known size
error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.
error: Could not compile `playground`.
To learn more, run the command again with --verbose.
This seems like it should work to me.
Metadata
Metadata
Assignees
Labels
Area: Associated items (types, constants & functions)Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.`#![feature(never_type)]`Relevant to the compiler team, which will review and decide on the PR/issue.Relevant to the language team, which will review and decide on the PR/issue.