Skip to content

fire debug assertion when expected and found item look the same in diagnostic? #119713

Open
@matthiaskrgr

Description

@matthiaskrgr

Sometimes rustc outputs silly error hints like

   = note: expected trait `for<'a> <for<'a> fn(&'a u32) -> &'a u32 {function2} as FnOnce<(&'a u32,)>>`
              found trait `for<'a> <for<'a> fn(&'a u32) -> &'a u32 {function2} as FnOnce<(&'a u32,)>>`

where "expected" and "found" look like they are the same which is quite unhelpful.
(example from #114883 )

I wonder if we should have a debug assertion in these cases (rustc displaying both types being identical although they shouldn't be) that helps catch these kid of diagnostic mishaps, similar to the "span must not be empty and have no suggestion" and "span must not have overlapping parts" debug assertions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-lifetimesArea: Lifetimes / regionsD-confusingDiagnostics: Confusing error or lint that should be reworked.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