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

30+ duplicates on E0308 with expected and found being literally identical #112985

Open
hartwork opened this issue Jun 23, 2023 · 3 comments
Open
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-lifetimes Area: Lifetimes / regions D-confusing Diagnostics: Confusing error or lint that should be reworked. metabug Issues about issues themselves ("bugs about bugs") T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@hartwork
Copy link

hartwork commented Jun 23, 2023

Hi! 👋

I was about to report a compiler diagnostics bug and then noticed that this things has 30+ duplicates here going back until January 2019 that are 99% open as of the moment, and not strongly interlinked. The pattern is this:

  1. Diagnostic "one type is more general than the other"
  2. The details saying that the compiler literally got what they expected a la "note: expected " and "found ".
  3. Often a reference to E0308 also

There is one concrete visual example with code further down.

After going through the first six pages of of matches for "one type is more general than the other" I stopped. Excluding unrelated ones, so far I found all of these as likely duplicates of this symptom:

Should one of these become the master issue?

Before you mass-close all the others, please verify that they are actual duplicates and didn't just fool me to believe they are.

Thank you!


PS: For completeness, my very broken diagnostics output was this, verbose rustc version included:

# cargo build
   Compiling issueXXX v0.1.0 (/tmp/tmp.5dilaGzlwK/issueXXX)
error[E0308]: mismatched types
   --> src/main.rs:9:14
    |
9   |         .arg(Arg::new("services").value_parser(parse_value))
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
    |
    = note: expected trait `for<'a> <for<'a> fn(&'a str) -> Result<&'a str, &'a str> {parse_value} as FnOnce<(&'a str,)>>`
               found trait `for<'a> <for<'a> fn(&'a str) -> Result<&'a str, &'a str> {parse_value} as FnOnce<(&'a str,)>>`
note: the lifetime requirement is introduced here
   --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/clap_builder-4.3.8/src/builder/arg.rs:975:48
    |
975 |     pub fn value_parser(mut self, parser: impl IntoResettable<super::ValueParser>) -> Self {
    |                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

For more information about this error, try `rustc --explain E0308`.
error: could not compile `issueXXX` due to previous error

# rustc --version --verbose
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

And the related minimal reproducer code is this:

use clap::{Arg, Command};

fn parse_value(_text: &str) -> Result<&str, &str> {
    todo!()
}

fn main() {
    Command::new("rust-for-it")
        .arg(Arg::new("services").value_parser(parse_value))
        .get_matches();
}
@jyn514 jyn514 added the A-diagnostics Area: Messages for errors, warnings, and lints label Jun 24, 2023
@estebank estebank added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jun 27, 2023
@fmease fmease added metabug Issues about issues themselves ("bugs about bugs") A-lifetimes Area: Lifetimes / regions labels Sep 6, 2023
@estebank estebank added the D-confusing Diagnostics: Confusing error or lint that should be reworked. label Nov 16, 2023
@fmease fmease self-assigned this Mar 3, 2024
@fmease
Copy link
Member

fmease commented Mar 3, 2024

I've just assigned myself but it will take a few weeks until I'll actually have the time to look into fixing this (I need to clear my review backlog, finish several PRs of mine and work on other issues I'm assigned to).

@fmease
Copy link
Member

fmease commented Mar 3, 2024

As a side note, I'd like us to keep any “gray” issues (closed as not duplicate) in the list to be able to double-check if the future fix 🤞 addresses all reported instances.

@metasim
Copy link

metasim commented Sep 9, 2024

Is there a workaround recipe when running into this issue? I can't say I understand what triggers it or how to direct the compiler in a different direction.

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 A-lifetimes Area: Lifetimes / regions D-confusing Diagnostics: Confusing error or lint that should be reworked. metabug Issues about issues themselves ("bugs about bugs") 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

5 participants