Cut needless mut

This commit is contained in:
Nick Drozd
2025-08-18 15:04:36 -04:00
parent 0e4ce7ffff
commit 64d6f82825
13 changed files with 15 additions and 23 deletions
+1 -1
View File
@@ -56,7 +56,7 @@ pub fn new(conf: &'static Conf) -> Self {
impl CognitiveComplexity {
fn check<'tcx>(
&mut self,
&self,
cx: &LateContext<'tcx>,
kind: FnKind<'tcx>,
decl: &'tcx FnDecl<'_>,
+1 -1
View File
@@ -49,7 +49,7 @@
}
impl<'tcx> QuestionMark {
pub(crate) fn check_manual_let_else(&mut self, cx: &LateContext<'tcx>, stmt: &'tcx Stmt<'tcx>) {
pub(crate) fn check_manual_let_else(&self, cx: &LateContext<'tcx>, stmt: &'tcx Stmt<'tcx>) {
if let StmtKind::Let(local) = stmt.kind
&& let Some(init) = local.init
&& local.els.is_none()
@@ -54,7 +54,7 @@ fn visit_expr(&mut self, ex: &'tcx Expr<'_>) -> Self::Result {
}
impl MatchExprVisitor<'_, '_> {
fn case_altered(&mut self, segment_ident: Symbol, receiver: &Expr<'_>) -> ControlFlow<CaseMethod> {
fn case_altered(&self, segment_ident: Symbol, receiver: &Expr<'_>) -> ControlFlow<CaseMethod> {
if let Some(case_method) = get_case_method(segment_ident) {
let ty = self.cx.typeck_results().expr_ty(receiver).peel_refs();
+2 -2
View File
@@ -106,7 +106,7 @@ enum CheckResult<'tcx> {
impl<'tcx> OffendingFilterExpr<'tcx> {
pub fn check_map_call(
&mut self,
&self,
cx: &LateContext<'tcx>,
map_body: &'tcx Body<'tcx>,
map_param_id: HirId,
@@ -413,7 +413,7 @@ fn is_find_or_filter<'a>(
}
&& let PatKind::Binding(_, filter_param_id, _, None) = filter_pat.kind
&& let Some(mut offending_expr) = OffendingFilterExpr::hir(cx, filter_body.value, filter_param_id)
&& let Some(offending_expr) = OffendingFilterExpr::hir(cx, filter_body.value, filter_param_id)
&& let ExprKind::Closure(&Closure { body: map_body_id, .. }) = map_arg.kind
&& let map_body = cx.tcx.hir_body(map_body_id)
@@ -134,7 +134,7 @@ fn maybe_walk_expr(&mut self, e: &'tcx Expr<'_>) {
}
}
fn report_diverging_sub_expr(&mut self, e: &Expr<'_>) {
fn report_diverging_sub_expr(&self, e: &Expr<'_>) {
if let Some(macro_call) = root_macro_call_first_node(self.cx, e)
&& self.cx.tcx.is_diagnostic_item(sym::todo_macro, macro_call.def_id)
{
+1 -1
View File
@@ -173,7 +173,7 @@ fn clear(&mut self) {
}
/// Sets the `apply_lint` flag on each parameter.
fn flag_for_linting(&mut self) {
fn flag_for_linting(&self) {
// Stores the list of parameters currently being resolved. Needed to avoid cycles.
let mut eval_stack = Vec::new();
for param in &self.params {
@@ -325,7 +325,7 @@ fn manage_unary_ops<'tcx>(
self.issue_lint(cx, expr);
}
fn should_skip_expr<'tcx>(&mut self, cx: &LateContext<'tcx>, expr: &hir::Expr<'tcx>) -> bool {
fn should_skip_expr<'tcx>(&self, cx: &LateContext<'tcx>, expr: &hir::Expr<'tcx>) -> bool {
is_lint_allowed(cx, ARITHMETIC_SIDE_EFFECTS, expr.hir_id)
|| self.expr_span.is_some()
|| self.const_span.is_some_and(|sp| sp.contains(expr.span))
@@ -13,7 +13,7 @@ pub struct Context {
const_span: Option<Span>,
}
impl Context {
fn skip_expr(&mut self, e: &hir::Expr<'_>) -> bool {
fn skip_expr(&self, e: &hir::Expr<'_>) -> bool {
self.expr_id.is_some() || self.const_span.is_some_and(|span| span.contains(e.span))
}
+1 -1
View File
@@ -120,7 +120,7 @@ pub fn new(tcx: TyCtxt<'_>, conf: &'static Conf) -> Self {
}
}
fn check_poly_fn(&mut self, cx: &LateContext<'_>, def_id: LocalDefId, decl: &FnDecl<'_>, span: Option<Span>) {
fn check_poly_fn(&self, cx: &LateContext<'_>, def_id: LocalDefId, decl: &FnDecl<'_>, span: Option<Span>) {
if self.avoid_breaking_exported_api && cx.effective_visibilities.is_exported(def_id) {
return;
}
+1 -9
View File
@@ -103,15 +103,7 @@ fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) {
}
impl RawStrings {
fn check_raw_string(
&mut self,
cx: &EarlyContext<'_>,
str: &str,
lit_span: Span,
prefix: &str,
max: u8,
descr: &str,
) {
fn check_raw_string(&self, cx: &EarlyContext<'_>, str: &str, lit_span: Span, prefix: &str, max: u8, descr: &str) {
if !str.contains(['\\', '"']) {
span_lint_and_then(
cx,
+2 -2
View File
@@ -380,7 +380,7 @@ fn snippet_index_binding(&mut self, expr: &'tcx Expr<'tcx>) -> String {
}
}
fn is_used_other_than_swapping(&mut self, idx_ident: Ident) -> bool {
fn is_used_other_than_swapping(&self, idx_ident: Ident) -> bool {
if Self::is_used_slice_indexed(self.swap1_idx, idx_ident)
|| Self::is_used_slice_indexed(self.swap2_idx, idx_ident)
{
@@ -389,7 +389,7 @@ fn is_used_other_than_swapping(&mut self, idx_ident: Ident) -> bool {
self.is_used_after_swap(idx_ident)
}
fn is_used_after_swap(&mut self, idx_ident: Ident) -> bool {
fn is_used_after_swap(&self, idx_ident: Ident) -> bool {
let mut v = IndexBindingVisitor {
idx: idx_ident,
suggest_span: self.suggest_span,
+1 -1
View File
@@ -55,7 +55,7 @@ pub fn new(conf: &'static Conf) -> Self {
}
}
fn check_fn_item(&mut self, cx: &LateContext<'_>, decl: &FnDecl<'_>, def_id: LocalDefId, name: Symbol) {
fn check_fn_item(&self, cx: &LateContext<'_>, decl: &FnDecl<'_>, def_id: LocalDefId, name: Symbol) {
// we don't want to tell someone to break an exported function if they ask us not to
if self.avoid_breaking_exported_api && cx.effective_visibilities.is_exported(def_id) {
return;
+1 -1
View File
@@ -258,7 +258,7 @@ fn eq_block(&mut self, left: &Block<'_>, right: &Block<'_>) -> bool {
})
}
fn should_ignore(&mut self, expr: &Expr<'_>) -> bool {
fn should_ignore(&self, expr: &Expr<'_>) -> bool {
macro_backtrace(expr.span).last().is_some_and(|macro_call| {
matches!(
self.inner.cx.tcx.get_diagnostic_name(macro_call.def_id),