rust/compiler/rustc_lint
Matthias Krüger 86727df4ed
Rollup merge of #121471 - estebank:lint-clone, r=TaKO8Ki
When encountering `<&T as Clone>::clone(x)` because `T: Clone`, suggest `#[derive(Clone)]`

CC #40699.

```
warning: call to `.clone()` on a reference in this situation does nothing
  --> $DIR/noop-method-call.rs:23:71
   |
LL |     let non_clone_type_ref_clone: &PlainType<u32> = non_clone_type_ref.clone();
   |                                                                       ^^^^^^^^
   |
   = note: the type `PlainType<u32>` does not implement `Clone`, so calling `clone` on `&PlainType<u32>` copies the reference, which does not do anything and can be removed
help: remove this redundant call
   |
LL -     let non_clone_type_ref_clone: &PlainType<u32> = non_clone_type_ref.clone();
LL +     let non_clone_type_ref_clone: &PlainType<u32> = non_clone_type_ref;
   |
help: if you meant to clone `PlainType<u32>`, implement `Clone` for it
   |
LL + #[derive(Clone)]
LL | struct PlainType<T>(T);
   |
```
2024-02-23 09:42:11 +01:00
..
src Rollup merge of #121471 - estebank:lint-clone, r=TaKO8Ki 2024-02-23 09:42:11 +01:00
Cargo.toml Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
messages.ftl When encountering <&T as Clone>::clone(x) because T: Clone, suggest #[derive(Clone)] 2024-02-22 18:01:20 +00:00