diff options
| author | Ada Alakbarova <ada.alakbarova@proton.me> | 2025-09-09 16:39:51 +0200 |
|---|---|---|
| committer | Ada Alakbarova <ada.alakbarova@proton.me> | 2025-09-13 11:53:04 +0200 |
| commit | af82c3db6c7259860ffdbe1dfd44b305b7796988 (patch) | |
| tree | 3f79849ec0ed93f17c082c055adda9222ff80dcc | |
| parent | 472768ad5eaafe31d7dfe3544277761bdb7f6824 (diff) | |
| download | rust-af82c3db6c7259860ffdbe1dfd44b305b7796988.tar.gz rust-af82c3db6c7259860ffdbe1dfd44b305b7796988.zip | |
tiny clean-up
| -rw-r--r-- | clippy_lints/src/returns.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/clippy_lints/src/returns.rs b/clippy_lints/src/returns.rs index e0c93153a77..a3e9e51bf12 100644 --- a/clippy_lints/src/returns.rs +++ b/clippy_lints/src/returns.rs @@ -162,9 +162,9 @@ impl RetReplacement<'_> { impl Display for RetReplacement<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - Self::Empty => write!(f, ""), - Self::Block => write!(f, "{{}}"), - Self::Unit => write!(f, "()"), + Self::Empty => f.write_str(""), + Self::Block => f.write_str("{}"), + Self::Unit => f.write_str("()"), Self::NeedsPar(inner, _) => write!(f, "({inner})"), Self::Expr(inner, _) => write!(f, "{inner}"), } @@ -228,7 +228,7 @@ impl<'tcx> LateLintPass<'tcx> for Return { fn check_block(&mut self, cx: &LateContext<'tcx>, block: &'tcx Block<'_>) { // we need both a let-binding stmt and an expr if let Some(retexpr) = block.expr - && let Some(stmt) = block.stmts.iter().last() + && let Some(stmt) = block.stmts.last() && let StmtKind::Let(local) = &stmt.kind && local.ty.is_none() && cx.tcx.hir_attrs(local.hir_id).is_empty() @@ -315,7 +315,7 @@ fn check_block_return<'tcx>(cx: &LateContext<'tcx>, expr_kind: &ExprKind<'tcx>, if let ExprKind::Block(block, _) = expr_kind { if let Some(block_expr) = block.expr { check_final_expr(cx, block_expr, semi_spans, RetReplacement::Empty, None); - } else if let Some(stmt) = block.stmts.iter().last() { + } else if let Some(stmt) = block.stmts.last() { match stmt.kind { StmtKind::Expr(expr) => { check_final_expr(cx, expr, semi_spans, RetReplacement::Empty, None); |
