Skip to content

Commit 510d3b6

Browse files
committed
Use clippy_utils::is_mutable() in unnecessary_struct_initialization
1 parent e0a62ac commit 510d3b6

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

clippy_lints/src/unnecessary_struct_initialization.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use clippy_utils::diagnostics::span_lint_and_sugg;
22
use clippy_utils::source::snippet;
33
use clippy_utils::ty::is_copy;
4-
use clippy_utils::{get_parent_expr, path_to_local};
5-
use rustc_hir::{BindingMode, Expr, ExprField, ExprKind, Node, PatKind, Path, QPath, StructTailExpr, UnOp};
4+
use clippy_utils::{get_parent_expr, is_mutable, path_to_local};
5+
use rustc_hir::{Expr, ExprField, ExprKind, Path, QPath, StructTailExpr, UnOp};
66
use rustc_lint::{LateContext, LateLintPass};
77
use rustc_session::declare_lint_pass;
88

@@ -157,16 +157,6 @@ fn same_path_in_all_fields<'tcx>(
157157
}
158158
}
159159

160-
fn is_mutable(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
161-
if let Some(hir_id) = path_to_local(expr)
162-
&& let Node::Pat(pat) = cx.tcx.hir_node(hir_id)
163-
{
164-
matches!(pat.kind, PatKind::Binding(BindingMode::MUT, ..))
165-
} else {
166-
true
167-
}
168-
}
169-
170160
fn check_references(cx: &LateContext<'_>, expr_a: &Expr<'_>, expr_b: &Expr<'_>) -> bool {
171161
if let Some(parent) = get_parent_expr(cx, expr_a)
172162
&& let parent_ty = cx.typeck_results().expr_ty_adjusted(parent)

0 commit comments

Comments
 (0)