Skip to content

Return impl Trait on unimplemented funtion fails to compile! #51166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
andreytkachenko opened this issue May 29, 2018 · 2 comments
Closed

Return impl Trait on unimplemented funtion fails to compile! #51166

andreytkachenko opened this issue May 29, 2018 · 2 comments

Comments

@andreytkachenko
Copy link

This snipped of rust code

fn fail() -> impl Iterator<Item = u32> {
    unimplemented!()
}

fn main() {}

fails to compile with error:

 --> src/main.rs:2:14
  |
2 | fn fail() -> impl Iterator<Item = u32> {
  |              ^^^^^^^^^^^^^^^^^^^^^^^^^ `()` 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
@hanna-kruppe
Copy link
Contributor

Duplicate of #36375

@andreytkachenko
Copy link
Author

As duplicate of #36375

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants