Cut needless mut
This commit is contained in:
parent
0e4ce7ffff
commit
64d6f82825
13 changed files with 15 additions and 23 deletions
|
|
@ -56,7 +56,7 @@ impl_lint_pass!(CognitiveComplexity => [COGNITIVE_COMPLEXITY]);
|
|||
|
||||
impl CognitiveComplexity {
|
||||
fn check<'tcx>(
|
||||
&mut self,
|
||||
&self,
|
||||
cx: &LateContext<'tcx>,
|
||||
kind: FnKind<'tcx>,
|
||||
decl: &'tcx FnDecl<'_>,
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ declare_clippy_lint! {
|
|||
}
|
||||
|
||||
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 @@ impl<'tcx> Visitor<'tcx> for MatchExprVisitor<'_, 'tcx> {
|
|||
}
|
||||
|
||||
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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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 @@ impl<'tcx> DivergenceVisitor<'_, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ impl Params {
|
|||
}
|
||||
|
||||
/// 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 @@ impl ArithmeticSideEffects {
|
|||
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))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ impl PassByRefOrValue {
|
|||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,15 +103,7 @@ impl EarlyLintPass for RawStrings {
|
|||
}
|
||||
|
||||
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,
|
||||
|
|
|
|||
|
|
@ -380,7 +380,7 @@ impl<'tcx> IndexBinding<'_, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
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 @@ impl<'tcx> IndexBinding<'_, 'tcx> {
|
|||
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,
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ impl UnnecessaryBoxReturns {
|
|||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -258,7 +258,7 @@ impl HirEqInterExpr<'_, '_, '_> {
|
|||
})
|
||||
}
|
||||
|
||||
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),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue