Files
Jonathan Brouwer a8d7877d23 Rollup merge of #157126 - Dnreikronos:avoid-redundant-derive-note-on-unimplemented, r=estebank
Avoid redundant note when a #[derive] is already suggested

Fixes rust-lang/rust#157118

The `Debug` `#[rustc_on_unimplemented]` note ("add `#[derive(Debug)]` to `X` or manually `impl Debug for X`") just repeats the `consider annotating X with #[derive(..)]` suggestion that `suggest_derive` already emits, so on these bound errors it's pure noise.

Now the note only gets dropped when that suggestion will actually show, which is whenever `can_suggest_derive` holds: a crate-local ADT, not a union, with every field already implementing the trait. Deleting the note from the attribute outright would be too blunt, since when `can_suggest_derive` is false there's no suggestion and the note is the only hint the user gets. A crate-local struct with a non-`Debug` field still ends up with just:

```
error[E0277]: `Outer` doesn't implement `Debug`
   = note: add `#[derive(Debug)]` to `Outer` or manually `impl Debug for Outer`
```

Same story when `main_trait_predicate != leaf_trait_predicate`, since the note comes from the main predicate and the suggestion from the leaf.
2026-05-30 23:05:30 +02:00
..
2025-11-27 14:13:58 -05:00
2025-12-16 02:10:08 +09:00