Skip to content

The span for “trait bound not satisfied” is weird #41817

Closed
@nagisa

Description

@nagisa

For following code

pub trait Arbitrary: Sized + 'static {}

impl<'a, A> Arbitrary for ::std::borrow::Cow<'a, A> {}

The error is

error[E0277]: the trait bound `A: std::clone::Clone` is not satisfied
 --> <anon>:3:13
  |
3 | impl<'a, A> Arbitrary for ::std::borrow::Cow<'a, A> {}
  |             ^^^^^^^^^ the trait `std::clone::Clone` is not implemented for `A`
  |
  = help: consider adding a `where A: std::clone::Clone` bound
  = note: required because of the requirements on the impl of `std::borrow::ToOwned` for `A`
  = note: required because it appears within the type `std::borrow::Cow<'a, A>`
  = note: required by `Arbitrary`

Note the span is pointing at Arbitrary, despite error really being about the generic bound A. It should point at A instead.

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-papercutDiagnostics: An error or lint that needs small tweaks.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