Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty "tuple variant defined here" note #105241

Closed
jruderman opened this issue Dec 4, 2022 · 2 comments
Closed

Empty "tuple variant defined here" note #105241

jruderman opened this issue Dec 4, 2022 · 2 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jruderman
Copy link
Contributor

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
@jruderman jruderman added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 4, 2022
@jieyouxu
Copy link
Member

This seems to have been fixed, on stable (1.69.0) it produces

error[E0308]: mismatched types
   --> test.rs:2:10
    |
2   |     Some(0_u32)
    |     ---- ^^^^^ expected `()`, found `u32`
    |     |
    |     arguments to this enum variant are incorrect
    |
help: the type constructed contains `u32` due to the type of the argument passed
   --> test.rs:2:5
    |
2   |     Some(0_u32)
    |     ^^^^^-----^
    |          |
    |          this argument influences the type of `Some`
note: tuple variant defined here
   --> /home/jieyouxu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs:571:5
    |
571 |     Some(#[stable(feature = "rust1", since = "1.0.0")] T),
    |    
rustc 1.69.0 (84c898d65 2023-04-16)
binary: rustc
commit-hash: 84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc
commit-date: 2023-04-16
host: x86_64-unknown-linux-gnu
release: 1.69.0
LLVM version: 15.0.7

@jruderman
Copy link
Contributor Author

The filename option.rs is now shown (fixed in #104449)

The new hint "... due to the type of the argument passed" was added in #106752

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants