Repository: rust
Issue: Error in associated type definition is repeated where it is used in a function signature.
Labels: A-diagnostics,T-compiler

<!--
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: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=45c6db6600bf537e04ed3c8111a4d89d
<details>
<summary>code</summary>

```rust
pub trait MyTrait {
    type Assoc;

    fn get() -> Self::Assoc;
}

struct A;

struct B;

// missing implementation of MyTrait for A

impl MyTrait for B {
    type Assoc = <A as MyTrait>::Assoc;

    // Self::Assoc repeats error shown at definition of type Assoc
    fn get() -> Self::Assoc {
        todo!()
    }
}
```

</details>

The current output is (1.64.0):

```
error[[E0277]](https://doc.rust-lang.org/stable/error-index.html#E0277): the trait bound `A: Foo` is not satisfied
  --> src/lib.rs:16:18
   |
16 |     type Assoc = <A as Foo>::Assoc;
   |                  ^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `A`
   |
   = help: the trait `Foo` is implemented for `B`

error[[E0277]](https://doc.rust-lang.org/stable/error-index.html#E0277): the trait bound `A: Foo` is not satisfied
  --> src/lib.rs:19:17
   |
19 |     fn get() -> Self::Assoc {
   |                 ^^^^^^^^^^^ the trait `Foo` is not implemented for `A`
   |
   = help: the trait `Foo` is implemented for `B`
```
<details>
<summary>On beta/nightly it is a bit different, the second error now points to the whole function</summary>

```
error[[E0277]](https://doc.rust-lang.org/beta/error-index.html#E0277): the trait bound `A: MyTrait` is not satisfied
  --> src/lib.rs:14:18
   |
14 |     type Assoc = <A as MyTrait>::Assoc;
   |                  ^^^^^^^^^^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `A`
   |
   = help: the trait `MyTrait` is implemented for `B`

error[[E0277]](https://doc.rust-lang.org/beta/error-index.html#E0277): the trait bound `A: MyTrait` is not satisfied
  --> src/lib.rs:17:5
   |
17 | /     fn get() -> Self::Assoc {
18 | |         todo!()
19 | |     }
   | |_____^ the trait `MyTrait` is not implemented for `A`
   |
   = help: the trait `MyTrait` is implemented for `B`
```

</details>

<!-- The following is not always necessary. -->
Ideally the output should look like:

```
error[[E0277]](https://doc.rust-lang.org/stable/error-index.html#E0277): the trait bound `A: MyTrait` is not satisfied
  --> src/lib.rs:14:18
   |
14 |     type Assoc = <A as MyTrait>::Assoc;
   |                  ^^^^^^^^^^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `A`
   |
   = help: the trait `MyTrait` is implemented for `B`
```

<!--
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.
-->