@@ -5,7 +5,7 @@ use clippy_utils::source::{IntoSpan as _, SpanRangeExt, snippet, snippet_block_w
55use clippy_utils:: { span_contains_non_whitespace, tokenize_with_text} ;
66use rustc_ast:: BinOpKind ;
77use rustc_errors:: Applicability ;
8- use rustc_hir:: { Block , Expr , ExprKind , Stmt , StmtKind } ;
8+ use rustc_hir:: { Block , Expr , ExprKind , StmtKind } ;
99use rustc_lexer:: TokenKind ;
1010use rustc_lint:: { LateContext , LateLintPass } ;
1111use rustc_session:: impl_lint_pass;
@@ -257,14 +257,9 @@ fn block_starts_with_significant_tokens(
257257/// If `block` is a block with either one expression or a statement containing an expression,
258258/// return the expression. We don't peel blocks recursively, as extra blocks might be intentional.
259259fn expr_block < ' tcx > ( block : & Block < ' tcx > ) -> Option < & ' tcx Expr < ' tcx > > {
260- match block. stmts {
261- [ ] => block. expr ,
262- [
263- Stmt {
264- kind : StmtKind :: Semi ( expr) ,
265- ..
266- } ,
267- ] if block. expr . is_none ( ) => Some ( expr) ,
260+ match ( block. stmts , block. expr ) {
261+ ( [ ] , expr) => expr,
262+ ( [ stmt] , None ) if let StmtKind :: Semi ( expr) = stmt. kind => Some ( expr) ,
268263 _ => None ,
269264 }
270265}
0 commit comments