@@ -162,9 +162,9 @@ impl RetReplacement<'_> {
162
162
impl Display for RetReplacement < ' _ > {
163
163
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
164
164
match self {
165
- Self :: Empty => write ! ( f , "" ) ,
166
- Self :: Block => write ! ( f , "{{} }") ,
167
- Self :: Unit => write ! ( f , "()" ) ,
165
+ Self :: Empty => f . write_str ( "" ) ,
166
+ Self :: Block => f . write_str ( "{ }") ,
167
+ Self :: Unit => f . write_str ( "()" ) ,
168
168
Self :: NeedsPar ( inner, _) => write ! ( f, "({inner})" ) ,
169
169
Self :: Expr ( inner, _) => write ! ( f, "{inner}" ) ,
170
170
}
@@ -228,7 +228,7 @@ impl<'tcx> LateLintPass<'tcx> for Return {
228
228
fn check_block ( & mut self , cx : & LateContext < ' tcx > , block : & ' tcx Block < ' _ > ) {
229
229
// we need both a let-binding stmt and an expr
230
230
if let Some ( retexpr) = block. expr
231
- && let Some ( stmt) = block. stmts . iter ( ) . last ( )
231
+ && let Some ( stmt) = block. stmts . last ( )
232
232
&& let StmtKind :: Let ( local) = & stmt. kind
233
233
&& local. ty . is_none ( )
234
234
&& 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>,
315
315
if let ExprKind :: Block ( block, _) = expr_kind {
316
316
if let Some ( block_expr) = block. expr {
317
317
check_final_expr ( cx, block_expr, semi_spans, RetReplacement :: Empty , None ) ;
318
- } else if let Some ( stmt) = block. stmts . iter ( ) . last ( ) {
318
+ } else if let Some ( stmt) = block. stmts . last ( ) {
319
319
match stmt. kind {
320
320
StmtKind :: Expr ( expr) => {
321
321
check_final_expr ( cx, expr, semi_spans, RetReplacement :: Empty , None ) ;
0 commit comments