Skip to content

Wrong error when lifetime is appended to associated type #45817

Closed
@mqudsi

Description

@mqudsi
error[E0404]: expected trait, found enum `std::result::Result`
   --> src/imessage/db.rs:216:44
    |
216 | fn unwrap_iter<'a,T,E>(iter: Iterator<Item=std::result::Result<T,E> + 'a>) -> Result<Vec<T>>
    |                                            ^^^^^^^^^^^^^^^^^^^^^^^^ not a trait

In the code fragment above, the problem is not that Item needs to point to a trait (is that even acceptable?) but rather that + 'a can only come after a trait.

Ideally, this should actually be a different error ("lifetime specification here is not valid" or something along those lines) with the source of the error being the presence of 'a and not the definition of Item, but if it remains E0404 then at least a hint should be provided along the lines of

+ 'a can only follow a trait, but std::result::Result<...> is a type

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-trait-systemArea: Trait systemC-enhancementCategory: An issue proposing an enhancement or a PR with one.D-confusingDiagnostics: Confusing error or lint that should be reworked.D-papercutDiagnostics: An error or lint that needs small tweaks.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions