Repository: rust
Issue: E0283 and E0284 on same expression uselessly duplicate identical help
Labels: A-diagnostics,P-low,T-compiler,D-verbose

<!--
Thank you for filing a bug report! 🐛 Please provide a short summary of the bug,
along with any information you feel relevant to replicating the bug.

If you cannot produce a minimal reproduction case (something that would work in
isolation), please provide the steps or even link to a repository that causes
the problematic output to occur.
-->

Given the following code: [[playground]](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=ad231695c1c3e37f3fbbb20551d2ade7)

```rust
use std::borrow::Borrow;

pub trait IntoOwned<B>: Sized + Borrow<B>
where
    B: ?Sized,
{
    type Owned;
    fn into_owned(self) -> Self::Owned;
}

impl<'a, B> IntoOwned<B> for &'a B
where
    B: ?Sized + ToOwned,
{
    type Owned = <B as ToOwned>::Owned;
    fn into_owned(self) -> Self::Owned {
        self.to_owned()
    }
}

impl<T> IntoOwned<T> for T {
    type Owned = T;
    fn into_owned(self) -> Self::Owned {
        self
    }
}

fn main() {
    let hello: &str = "Hello World!";
    let owned: String = hello.into_owned();
    println!("{owned}");
}
```

The current output is:

```
error[E0284]: type annotations needed
  --> src/main.rs:30:31
   |
30 |     let owned: String = hello.into_owned();
   |                               ^^^^^^^^^^
   |
   = note: cannot satisfy `<&str as IntoOwned<_>>::Owned == String`
help: try using a fully qualified path to specify the expected types
   |
30 |     let owned: String = <&str as IntoOwned<B>>::into_owned(hello);
   |                         +++++++++++++++++++++++++++++++++++     ~

error[E0283]: type annotations needed
  --> src/main.rs:30:31
   |
30 |     let owned: String = hello.into_owned();
   |                               ^^^^^^^^^^
   |
note: multiple `impl`s satisfying `&str: IntoOwned<_>` found
  --> src/main.rs:11:1
   |
11 | impl<'a, B> IntoOwned<B> for &'a B
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
21 | impl<T> IntoOwned<T> for T {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^
help: try using a fully qualified path to specify the expected types
   |
30 |     let owned: String = <&str as IntoOwned<B>>::into_owned(hello);
   |                         +++++++++++++++++++++++++++++++++++     ~
```

<!-- The following is not always necessary. -->
Ideally the output should be a single error, something like:

```
error: type annotations needed
  --> src/main.rs:30:31
   |
30 |     let owned: String = hello.into_owned();
   |                               ^^^^^^^^^^
   |
   = note: cannot satisfy `<&str as IntoOwned<_>>::Owned == String`
note: multiple `impl`s satisfying `&str: IntoOwned<_>` found
  --> src/main.rs:11:1
   |
11 | impl<'a, B> IntoOwned<B> for &'a B
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
21 | impl<T> IntoOwned<T> for T {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^
help: try using a fully qualified path to specify the expected types
   |
30 |     let owned: String = <&str as IntoOwned<B>>::into_owned(hello);
   |                         +++++++++++++++++++++++++++++++++++     ~
```

<!--
If the problem is not self-explanatory, please provide a rationale for the
change.
-->

<!--
If dramatically different output is caused by small changes, consider also
adding them here.

If you're using the stable version of the compiler, you should also check if the
bug also exists in the beta or nightly versions. The output might also be
different depending on the Edition.
-->

Using UFCS (but leaving `B` as an inference variable) to avoid method lookup only emits E0283 and not E0284. This suggests that E0283 is the "more canonical" root error.