Skip to content

Empty "tuple variant defined here" note #105241

Closed
@jruderman

Description

@jruderman

Code

playground

fn f() -> Option<()> {
    Some(0_u32)
}

fn main() {}

Current output

error[E0308]: mismatched types
 --> tvdh.rs:2:10
  |
2 |     Some(0_u32)
  |     ---- ^^^^^ expected `()`, found `u32`
  |     |
  |     arguments to this enum variant are incorrect
  |
note: tuple variant defined here

error: aborting due to previous error

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

The note starting with "note: tuple variant defined here" is confusing. Where is "here"?

I suspect it's trying to to show part of the definition of the Option type, but failing because the definition is in a different crate (or because it's part of std).

Ideal output

Don't try to show the enum-variant definition when it can't be shown, I guess?

For cases like this one that involve generics, see #105240 for a proposed alternative.

Regression

The empty note first appears in nightly-2022-06-12

Version

rustc 1.67.0-nightly (32e613bba 2022-12-02)
binary: rustc
commit-hash: 32e613bbaafee1bcabba48a2257b838f8d1c03d3
commit-date: 2022-12-02
host: x86_64-apple-darwin
release: 1.67.0-nightly
LLVM version: 15.0.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-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