Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E0277 for #[derive(_)]-able trait on local type should have structured suggestion #95099

Closed
estebank opened this issue Mar 19, 2022 · 1 comment · Fixed by #95525
Closed

E0277 for #[derive(_)]-able trait on local type should have structured suggestion #95099

estebank opened this issue Mar 19, 2022 · 1 comment · Fixed by #95525
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-papercut Diagnostics: An error or lint that needs small tweaks. D-terse Diagnostics: An error or lint that doesn't give enough information about the problem at hand. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@estebank
Copy link
Contributor

estebank commented Mar 19, 2022

When encountering code that requires a deriveable trait on a type that doesn't have it, we currently emit an E0277 error and when possible point at the trait bound that introduced the obligation:

error[E0277]: can't compare `S` with `S`
 --> src/main.rs:3:9
  |
3 |     foo(S);
  |     --- ^ no implementation for `S == S`
  |     |
  |     required by a bound introduced by this call
  |
  = help: the trait `PartialEq` is not implemented for `S`
note: required by a bound in `foo`
 --> src/main.rs:6:11
  |
6 | fn foo<T: PartialEq>(_: T) {}
  |           ^^^^^^^^^ required by this bound in `foo`

When the bound applies on a local type, we should suggest

help: consider annotating `S` with `#[derive(PartialEq)]`
  |
1 | #[derive(PartialEq)]
  |

like we do for E0369.

@estebank estebank added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. A-diagnostics Area: Messages for errors, warnings, and lints P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-papercut Diagnostics: An error or lint that needs small tweaks. D-terse Diagnostics: An error or lint that doesn't give enough information about the problem at hand. labels Mar 19, 2022
@ohno418
Copy link
Contributor

ohno418 commented Mar 28, 2022

@rustbot claim

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Apr 5, 2022
…77, r=compiler-errors

Suggest derivable trait on E0277 error

Closes rust-lang#95099 .
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Apr 5, 2022
…77, r=compiler-errors

Suggest derivable trait on E0277 error

Closes rust-lang#95099 .
@bors bors closed this as completed in 661b0e5 Apr 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-papercut Diagnostics: An error or lint that needs small tweaks. D-terse Diagnostics: An error or lint that doesn't give enough information about the problem at hand. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants