Skip to content

Misleading diagnostic span using trait projections in arguments #60980

Closed
@alexcrichton

Description

@alexcrichton

I came across an interesting case today where the span for a diagnostic isn't quite leading to the best location. When compiling the example code below

struct A;

trait IntoWasmAbi {
    type Abi;
    fn into_abi(self) -> Self::Abi;
}

type T = <A as IntoWasmAbi>::Abi;

fn foo(a: T) {}

you get:

error[E0277]: the trait bound `A: IntoWasmAbi` is not satisfied
  --> src/lib.rs:10:1
   |
10 | fn foo(a: T) {}
   | ^^^^^^^^^^^^^^^ the trait `IntoWasmAbi` is not implemented for `A`

but it's sort of misleading because neither A nor IntoWasmAbi is mentioned in the highlight. It'd be ideal if the error would point to the type definition to indicat that's where the source of the error comes from.

Metadata

Metadata

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.D-confusingDiagnostics: Confusing error or lint that should be reworked.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