Closed
Description
From what I understand the "never" type (!) returned by unimplemented!()
should satisfy any type constrain but this seems to fail when using impl Trait as a output.
I tried this code:
fn f() -> impl Iterator<Item = usize> {
unimplemented!()
}
fn main() {}
I expected this to compile.
Instead, this happened:
error[E0277]: the trait bound `(): std::iter::Iterator` is not satisfied
--> src/main.rs:1:11
|
1 | fn f() -> impl Iterator<Item = usize> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `()` 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
Meta
$ rustc --version --verbose
rustc 1.28.0-nightly (952f344cd 2018-05-18)
binary: rustc
commit-hash: 952f344cdc0bca58d9f6c54dcfbae0890246e886
commit-date: 2018-05-18
host: x86_64-unknown-linux-gnu
release: 1.28.0-nightly
LLVM version: 6.0
Metadata
Metadata
Assignees
Labels
No labels