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

Trait errors should suggest * if appropriate for the boudn to succeed #90997

Open
estebank opened this issue Nov 18, 2021 · 0 comments · May be fixed by #133292
Open

Trait errors should suggest * if appropriate for the boudn to succeed #90997

estebank opened this issue Nov 18, 2021 · 0 comments · May be fixed by #133292
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-newcomer-roadblock Diagnostics: Confusing error or lint; hard to understand for new users. 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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@estebank
Copy link
Contributor

Trait errors should suggest dereferencing just like type errors do in the second error below:

error[E0277]: the trait bound `&rustc_span::def_id::DefId: rustc_middle::ty::query::sealed::IntoQueryParam<rustc_span::def_id::DefId>` is not satisfied
   --> compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs:151:39
    |
151 |             if self.tcx.trait_of_item(item) == Some(trait_ref.def_id) {
    |                         ------------- ^^^^ the trait `rustc_middle::ty::query::sealed::IntoQueryParam<rustc_span::def_id::DefId>` is not implemented for `&rustc_span::def_id::DefId`
    |                         |
    |                         required by a bound introduced by this call

error[E0308]: mismatched types
   --> compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs:152:49
    |
152 |                 let method = self.tcx.item_name(item);
    |                                                 ^^^^ expected struct `rustc_span::def_id::DefId`, found `&rustc_span::def_id::DefId`
    |
help: consider dereferencing the borrow
    |
152 |                 let method = self.tcx.item_name(*item);
    |                                                 +
@estebank estebank added A-diagnostics Area: Messages for errors, warnings, and lints 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-newcomer-roadblock Diagnostics: Confusing error or lint; hard to understand for new users. D-terse Diagnostics: An error or lint that doesn't give enough information about the problem at hand. labels Nov 18, 2021
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-newcomer-roadblock Diagnostics: Confusing error or lint; hard to understand for new users. 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. 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.

1 participant