Skip to content

Purely-diverging functions cannot return impl Trait. #44923

@kennytm

Description

@kennytm

Originally reported in #34511 (comment), separated out to make it easier to track. #43869 and #44731 are examples caused by this issue.

If a function is purely diverging, any part of the return type cannot contain impl Trait, e.g.

fn do_it_later_but_cannot() -> impl Iterator<Item=u8> { //~ ERROR E0227
    unimplemented!()
}

this fails because ! does not implement Iterator. But I think this should be allowed even without the explicit impl, since ! can be coerced to any concrete type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-bugCategory: This is a bug.T-langRelevant to the language team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions