Skip to content

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

Closed
@estebank

Description

@estebank

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);
    |                                                 +

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`D-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.D-papercutDiagnostics: An error or lint that needs small tweaks.D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions