Skip to content
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

diagnostics: Duplicate derive clone suggestion #91492

Closed
eopb opened this issue Dec 3, 2021 · 1 comment · Fixed by #91544
Closed

diagnostics: Duplicate derive clone suggestion #91492

eopb opened this issue Dec 3, 2021 · 1 comment · Fixed by #91544
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. D-papercut Diagnostics: An error or lint that needs small tweaks. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@eopb
Copy link
Contributor

eopb commented Dec 3, 2021

Given the following code: Playground

pub struct Foo;
fn fun(foo: &mut Vec<Foo>, bar: &[Foo]) {
    foo.extend_from_slice(bar);
}

The current output is:

error[E0599]: the method `extend_from_slice` exists for mutable reference `&mut Vec<Foo>`, but its trait bounds were not satisfied
 --> src/lib.rs:3:9
  |
1 | pub struct Foo;
  | ---------------------- doesn't satisfy `Foo: Clone`
2 | fn fun(foo: &mut Vec<Foo>, bar: &[Foo]) {
3 |     foo.extend_from_slice(bar);
  |         ^^^^^^^^^^^^^^^^^
  |
  = note: the following trait bounds were not satisfied:
          `Foo: Clone`
help: consider annotating `Foo` with `#[derive(Clone, Clone)]`
  |
1 | #[derive(Clone, Clone)]
  |

For more information about this error, try `rustc --explain E0599`.
error: could not compile `playground` due to previous error

Ideally the output should look like:

error[E0599]: the method `extend_from_slice` exists for mutable reference `&mut Vec<Foo>`, but its trait bounds were not satisfied
 --> src/lib.rs:3:9
  |
1 | pub struct Foo;
  | ---------------------- doesn't satisfy `Foo: Clone`
2 | fn fun(foo: &mut Vec<Foo>, bar: &[Foo]) {
3 |     foo.extend_from_slice(bar);
  |         ^^^^^^^^^^^^^^^^^
  |
  = note: the following trait bounds were not satisfied:
          `Foo: Clone`
help: consider annotating `Foo` with `#[derive(Clone)]`
  |
1 | #[derive(Clone)]
  |

For more information about this error, try `rustc --explain E0599`.
error: could not compile `playground` due to previous error
@eopb eopb 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 Dec 3, 2021
@inquisitivecrystal inquisitivecrystal added D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. D-papercut Diagnostics: An error or lint that needs small tweaks. C-bug Category: This is a bug. labels Dec 3, 2021
@rukai
Copy link
Contributor

rukai commented Dec 4, 2021

@rustbot claim

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 C-bug Category: This is a bug. D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. D-papercut Diagnostics: An error or lint that needs small tweaks. 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