Skip to content

Confusing error message when traits from different modules have the same name #36184

@elidupree

Description

@elidupree

This error looks pretty bizarre, right? Especially the "help:" message, which is clearly not helpful at all. (This is from the current nightly.)

error[E0277]: the trait bound `B: Basics` is not satisfied
   --> src\collision_detection\simple_grid.rs:115:1
    |
115 | pub fn insert_predictors <B: Basics, Settings: TimeStewardSettings <B>> (s
ettings: Settings) {
    | ^ trait `B: Basics` not satisfied
    |
    = help: consider adding a `where B: Basics` bound
    = note: required by `TimeStewardSettings`

What happened is that I had two traits named Basics, one in the crate root and one in the current module. Presumably, the compiler could give a clearer error message in this situation, although I'm not sure what the best way to handle it is – it would obviously be bad to give the full path for every trait mentioned in an error message. Maybe it should give the full path exactly when there are two traits (or other objects) with the same name?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.D-confusingDiagnostics: Confusing error or lint that should be reworked.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-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