Skip to content

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

Closed
@andreytkachenko

Description

@andreytkachenko

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions