rust/compiler/rustc_errors/src
Esteban Küber 1d860902f6 When a trait isn't implemented, but another similar impl is found, point at it:
```
error[E0277]: the trait bound `u32: Trait` is not satisfied
  --> $DIR/trait_objects_fail.rs:26:9
   |
LL |     foo(&10_u32);
   |         ^^^^^^^ the trait `Trait` is not implemented for `u32`
   |
help: the trait `Trait<12>` is not implemented for `u32`
      but trait `Trait<2>` is implemented for it
  --> $DIR/trait_objects_fail.rs:7:1
   |
LL | impl Trait<2> for u32 {}
   | ^^^^^^^^^^^^^^^^^^^^^
   = note: required for the cast from `&u32` to `&dyn Trait`
```

Pointing at the `impl` definition that *could* apply given a different self type is particularly useful when it has a blanket self type, as it might not be obvious and is not trivially greppable:

```
error[E0277]: the trait bound `RawImpl<_>: Raw<_>` is not satisfied
  --> $DIR/issue-62742.rs:4:5
   |
LL |     WrongImpl::foo(0i32);
   |     ^^^^^^^^^ unsatisfied trait bound
   |
help: the trait `Raw<_>` is not implemented for `RawImpl<_>`
      but trait `Raw<[_]>` is implemented for it
  --> $DIR/issue-62742.rs:29:1
   |
LL | impl<T> Raw<[T]> for RawImpl<T> {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: required by a bound in `SafeImpl`
  --> $DIR/issue-62742.rs:33:35
   |
LL | pub struct SafeImpl<T: ?Sized, A: Raw<T>>(PhantomData<(A, T)>);
   |                                   ^^^^^^ required by this bound in `SafeImpl`
```
2025-10-31 20:38:31 +00:00
..
json Extract Translator struct 2025-06-19 13:02:04 -05:00
markdown chore: Remove unneeded ansi escape resets from output 2025-10-20 12:13:26 -06:00
annotate_snippet_emitter_writer.rs chore: Update to the latest annotate-snippets 2025-10-24 12:50:19 -06:00
codes.rs Move IntoDiagArg earlier in the dependency chains 2025-08-20 15:01:13 -07:00
decorate_diag.rs Refactor lint buffering to avoid requiring a giant enum 2025-08-22 01:59:56 -07:00
diagnostic.rs Revert "Auto merge of #146121 - Muscraft:filter-suggestion-parts, r=petrochenkov" 2025-10-23 18:18:35 +00:00
diagnostic_impls.rs Move IntoDiagArg earlier in the dependency chains 2025-08-20 15:01:13 -07:00
emitter.rs When a trait isn't implemented, but another similar impl is found, point at it: 2025-10-31 20:38:31 +00:00
error.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
json.rs refactor: Move to anstream + anstyle for styling 2025-10-20 12:13:25 -06:00
lib.rs Revert "Auto merge of #146121 - Muscraft:filter-suggestion-parts, r=petrochenkov" 2025-10-23 18:18:35 +00:00
lock.rs Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
registry.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
snippet.rs Use abs_diff where applicable 2025-03-27 18:29:06 +00:00
styled_buffer.rs use let chains in ast, borrowck, codegen, const_eval 2025-07-28 06:08:48 +05:00
tests.rs Extract Translator struct 2025-06-19 13:02:04 -05:00
timings.rs Add codegen timing section 2025-06-23 08:50:17 +02:00
translation.rs Extract Translator struct 2025-06-19 13:02:04 -05:00