Skip to content

Can we split E0308 into different errors for better --explain? #95378

@scottmcm

Description

@scottmcm

(Inspired by the question in https://users.rust-lang.org/t/returning-different-types-in-match-arms/73508?u=scottmcm)

When you get an error like https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=b1f5ac9c4d61db01d47d3a3927cfb544

error[E0308]: match arms have incompatible types

It would be nice to have that be a separate error code from the "you passed the wrong type to a function" errors.

Because the existing explain for E0308 talks more about the "there's only one valid type" case.

Ideally we could have a separate error code for the match/if arms with different types case, so that the explain for that would could talk about the "make an enum" or "use Box-of-dyn" solutions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-inferenceArea: Type inferenceT-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