Skip to content

Copy supertrait not holding error has empty note #108174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
BoxyUwU opened this issue Feb 17, 2023 · 3 comments · Fixed by #109786
Closed

Copy supertrait not holding error has empty note #108174

BoxyUwU opened this issue Feb 17, 2023 · 3 comments · Fixed by #109786
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@BoxyUwU
Copy link
Member

BoxyUwU commented Feb 17, 2023

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

@BoxyUwU BoxyUwU added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 17, 2023
@Noratrieb Noratrieb changed the title Copy supertrait not holding error has empty not Copy supertrait not holding error has empty note Feb 17, 2023
@estebank
Copy link
Contributor

That suggestion should be

help: consider annotating `Foo` with `#[derive(Clone)]`
  |
1 + #[derive(Clone)]
  |

The note appears like that when the span is not available (which can happen for stdlib for a variety of reasons).

@WaffleLapkin
Copy link
Member

Indeed, I can't reproduce the empty note:

error[E0277]: the trait bound `Foo: Clone` is not satisfied
   --> ./t.rs:5:15
    |
5   | impl Copy for Foo {}
    |               ^^^ the trait `Clone` is not implemented for `Foo`
    |
note: required by a bound in `Copy`
   --> /home/waffle/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/marker.rs:392:17
    |
392 | pub trait Copy: Clone {
    |                 ^^^^^ required by this bound in `Copy`
help: consider annotating `Foo` with `#[derive(Clone)]`
    |
1   | #[derive(Clone)]
    |

I would guess that you are missing some rustup component? not sure...

The help not showing + is weird though...

@estebank
Copy link
Contributor

I have a change to fix the missing + already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants