rust/compiler/rustc_lint/src
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
..
context Reduce capabilities of Diagnostic. 2024-02-20 13:22:17 +11:00
nonstandard_style mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
array_into_iter.rs Rename LintContext::emit_spanned_lint as LintContext::emit_span_lint. 2024-01-23 08:08:25 +11:00
async_fn_in_trait.rs Rename TyCtxt::emit_spanned_lint as TyCtxt::emit_node_span_lint. 2024-01-23 08:09:05 +11:00
builtin.rs Rollup merge of #121318 - kadiwa4:no_assembly_in_supposedly_safe_code, r=Nilstrieb 2024-02-20 15:13:55 +01:00
context.rs clean up potential_query_instability with FxIndexMap and UnordMap 2024-02-14 18:36:37 +08:00
deref_into_dyn_supertrait.rs Auto merge of #120017 - nnethercote:lint-api, r=oli-obk 2024-01-23 00:06:57 +00:00
drop_forget_useless.rs hir: Remove hir::Map::{opt_parent_id,parent_id,get_parent,find_parent} 2024-02-10 12:24:46 +03:00
early.rs Use fewer delayed bugs. 2024-02-14 20:30:37 +11:00
enum_intrinsics_non_enums.rs Rename LintContext::emit_spanned_lint as LintContext::emit_span_lint. 2024-01-23 08:08:25 +11:00
errors.rs Reduce capabilities of Diagnostic. 2024-02-20 13:22:17 +11:00
expect.rs Rename TyCtxt::emit_spanned_lint as TyCtxt::emit_node_span_lint. 2024-01-23 08:09:05 +11:00
for_loops_over_fallibles.rs Rename LintContext::emit_spanned_lint as LintContext::emit_span_lint. 2024-01-23 08:08:25 +11:00
foreign_modules.rs Rename TyCtxt::emit_spanned_lint as TyCtxt::emit_node_span_lint. 2024-01-23 08:09:05 +11:00
hidden_unicode_codepoints.rs Rename LintContext::emit_spanned_lint as LintContext::emit_span_lint. 2024-01-23 08:08:25 +11:00
internal.rs hir: Remove hir::Map::{opt_parent_id,parent_id,get_parent,find_parent} 2024-02-10 12:24:46 +03:00
invalid_from_utf8.rs Rename LintContext::emit_spanned_lint as LintContext::emit_span_lint. 2024-01-23 08:08:25 +11:00
late.rs tidy 2024-02-09 19:30:47 +01:00
let_underscore.rs Rename LintContext::emit_spanned_lint as LintContext::emit_span_lint. 2024-01-23 08:08:25 +11:00
levels.rs Reduce capabilities of Diagnostic. 2024-02-20 13:22:17 +11:00
lib.rs Auto merge of #121087 - oli-obk:eager_const_failures, r=lcnr 2024-02-20 09:02:34 +00:00
lints.rs Rollup merge of #121471 - estebank:lint-clone, r=TaKO8Ki 2024-02-23 09:42:11 +01:00
map_unit_fn.rs Rename LintContext::emit_spanned_lint as LintContext::emit_span_lint. 2024-01-23 08:08:25 +11:00
methods.rs Rename LintContext::emit_spanned_lint as LintContext::emit_span_lint. 2024-01-23 08:08:25 +11:00
multiple_supertrait_upcastable.rs Rename LintContext::emit_spanned_lint as LintContext::emit_span_lint. 2024-01-23 08:08:25 +11:00
non_ascii_idents.rs clean up potential_query_instability with FxIndexMap and UnordMap 2024-02-14 18:36:37 +08:00
non_fmt_panic.rs Rename LintContext::emit_spanned_lint as LintContext::emit_span_lint. 2024-01-23 08:08:25 +11:00
nonstandard_style.rs hir: Remove hir::Map::{opt_parent_id,parent_id,get_parent,find_parent} 2024-02-10 12:24:46 +03:00
noop_method_call.rs When encountering <&T as Clone>::clone(x) because T: Clone, suggest #[derive(Clone)] 2024-02-22 18:01:20 +00:00
opaque_hidden_inferred_bound.rs introduce enter_forall 2024-02-08 13:01:08 +00:00
pass_by_value.rs Rename LintContext::emit_spanned_lint as LintContext::emit_span_lint. 2024-01-23 08:08:25 +11:00
passes.rs Remove rustc_lint_defs::lint_array 2023-09-28 23:01:25 +02:00
ptr_nulls.rs Rename LintContext::emit_spanned_lint as LintContext::emit_span_lint. 2024-01-23 08:08:25 +11:00
redundant_semicolon.rs Rename LintContext::emit_spanned_lint as LintContext::emit_span_lint. 2024-01-23 08:08:25 +11:00
reference_casting.rs Ignore unsized types when trying to determine the size of a type 2024-02-14 19:23:20 +01:00
tests.rs refactor(rustc_lint): inline check_lint_name_cmdline 2023-08-30 17:35:07 +01:00
traits.rs Rename LintContext::emit_spanned_lint as LintContext::emit_span_lint. 2024-01-23 08:08:25 +11:00
types.rs hir: Remove hir::Map::{opt_parent_id,parent_id,get_parent,find_parent} 2024-02-10 12:24:46 +03:00
unit_bindings.rs Rename LintContext::emit_spanned_lint as LintContext::emit_span_lint. 2024-01-23 08:08:25 +11:00
unused.rs Fix false positive with if let and ranges 2024-02-14 15:15:22 +08:00