Skip to content

e0308 possibly confusing error message #62677

Closed
@richard-uk1

Description

@richard-uk1

I got the following error today:

error[E0308]: mismatched types
  --> src/util.rs:13:33
   |
13 |     fn from_str(input: &str) -> Result<Self, Self::Err> {
   |        --------                 ^^^^^^^^^^^^^^^^^^^^^^^ expected enum `std::result::Result`, found ()
   |        |
   |        this function's body doesn't return
   |
   = note: expected type `std::result::Result<util::Color, &'static str>`
              found type `()`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.

I think the note this function's body doesn't return is misleading - I thought that the issue was that an inner method I was calling had an infinite loop, or returned ! some other way, but it doesn't mean this, it actually means "this function's body doesn't return a value". Maybe the error message could be changed?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.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