Skip to content

Copy supertrait not holding error has empty note #108174

Closed
@BoxyUwU

Description

@BoxyUwU

Code

struct Foo {
    a: &'static str
}

impl Copy for Foo {}

Current output

error[E0277]: the trait bound `Foo: Clone` is not satisfied
 --> src/lib.rs:5:6
  |
5 | impl Copy for Foo {}
  |      ^^^^ the trait `Clone` is not implemented for `Foo`
  |
note: required by a bound in `Copy`
 --> /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/marker.rs:391:17
  |
  = note: required by this bound in `Copy`
help: consider annotating `Foo` with `#[derive(Clone)]`
  |
1 | #[derive(Clone)]
  |

Desired output

error[E0277]: the trait bound `Foo: Clone` is not satisfied
 --> src/lib.rs:5:6
  |
5 | impl Copy for Foo {}
  |      ^^^^ the trait `Clone` is not implemented for `Foo`
  |
note: required by a bound in `Copy`
 --> /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/marker.rs:391:17
  |
  | trait Copy: Clone {
  |             ^^^^^ required by this bound in `Copy`
  |
help: consider annotating `Foo` with `#[derive(Clone)]`
  |
1 | #[derive(Clone)]
  | ++++++++++++++++ // to be honest I don't remember how exactly the `+++` suggestions are structured
  | struct Foo {

Rationale and extra context

An empty not is rather confusing and really has no reason to exist and just takes up space, it should actually point to the supertrait like every other error imo (or at the very least have the note removed..) It also seems a bit weird to me that the compiler suggests adding #[derive(Clone)] but doesnt make it an actual suggestion with the nice green ++++

Other cases

No response

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-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