Skip to content

Incorrect suggestion on type error #55336

Closed
@estebank

Description

@estebank

We're incorrectly suggesting wrapping with Ok() when it won't help:

error[E0308]: try expression alternatives have incompatible types
   -->
    |
503 | /   segments
504 | |     .next()
505 | |     .ok_or(ApplicationIssue::InvalidMessage(foo::Error::InvalidHeader))?
    | |________________________________________________________________________^ expected struct `failure::Error`, found enum `foo::Error`
    |
    = note: expected type `std::result::Result<_, failure::Error>`
               found type `std::result::Result<_, foo::Error>`
help: try wrapping with a success variant
    |
503 |   Ok(segments
504 |     .next()
505 |     .ok_or(ApplicationIssue::InvalidMessage(foo::Error::InvalidHeader))?)

It should be suggesting using using map_err instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions