mirror of
https://github.com/rust-lang/rust.git
synced 2026-07-26 17:42:22 -04:00
a8d7877d23
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.