Skip to content

Commit 6ab0b14

Browse files
committed
feat: make unnecessary mut autofixable
1 parent d5a4c52 commit 6ab0b14

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

clippy_lints/src/mut_reference.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
use clippy_utils::diagnostics::span_lint_and_sugg;
22
use clippy_utils::source::snippet;
33
use rustc_errors::Applicability;
4-
use rustc_hir::{
5-
AssocItemKind, BorrowKind, Expr, ExprKind, FieldDef, HirId, ImplItemRef, IsAuto, Item, ItemKind, Mod, Mutability,
6-
QPath, TraitItemRef, TyKind, Variant, VariantData,
7-
};
4+
use rustc_hir::{BorrowKind, Expr, ExprKind, Mutability};
85
use rustc_lint::{LateContext, LateLintPass};
9-
use rustc_middle::ty::print::with_forced_trimmed_paths;
10-
use rustc_middle::ty::{self, GenericArgKind, Ty};
6+
use rustc_middle::ty::{self, Ty};
117
use rustc_session::declare_lint_pass;
12-
use rustc_span::symbol::sym;
138
use std::iter;
149

1510
declare_clippy_lint! {

tests/ui/mut_reference.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: the function `takes_an_immutable_reference` doesn't need a mutable refere
22
--> tests/ui/mut_reference.rs:30:34
33
|
44
LL | takes_an_immutable_reference(&mut 42);
5-
| ^^^^^^^
5+
| ^^^^^^^ help: try: `&42`
66
|
77
= note: `-D clippy::unnecessary-mut-passed` implied by `-D warnings`
88
= help: to override `-D warnings` add `#[allow(clippy::unnecessary_mut_passed)]`
@@ -11,13 +11,13 @@ error: the function `as_ptr` doesn't need a mutable reference
1111
--> tests/ui/mut_reference.rs:34:12
1212
|
1313
LL | as_ptr(&mut 42);
14-
| ^^^^^^^
14+
| ^^^^^^^ help: try: `&42`
1515

1616
error: the method `takes_an_immutable_reference` doesn't need a mutable reference
1717
--> tests/ui/mut_reference.rs:39:44
1818
|
1919
LL | my_struct.takes_an_immutable_reference(&mut 42);
20-
| ^^^^^^^
20+
| ^^^^^^^ help: try: `&42`
2121

2222
error: aborting due to 3 previous errors
2323

0 commit comments

Comments
 (0)