Repository: rust
Issue: 30+ duplicates on E0308 with expected and found being literally identical
Labels: A-diagnostics,A-lifetimes,metabug,T-compiler,D-confusing,A-higher-ranked

Hi! :wave:

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 <some thing>" and "found <literally the same thing>".
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"](https://github.com/search?q=repo%3Arust-lang%2Frust+%22one+type+is+more+general+than+the+other%22&type=issues) I stopped. Excluding unrelated ones, so far I found all of these as likely duplicates of this symptom:

- #37300
- #57875
- #60658
- #64650
- #71671
- #71723
- #72063
- #74497
- #79187
- #79648
- #81511
- #81685
- #84296
- #84400
- #85516
- #87093
- #89620
- #89923
- #90656
- #90696
- #91829
- #91966
- #92039
- #97010  
- #99492
- #102400
- #108114
- #109572
- #110339
- #111497
- #112010
- #112855
- #114849
- #114883
- #121944

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:

```console
# 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:

```rust
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();
}
```