@@ -5,7 +5,7 @@ use clippy_utils::source::{IntoSpan as _, SpanRangeExt, snippet, snippet_block_w
5
5
use clippy_utils:: { span_contains_non_whitespace, tokenize_with_text} ;
6
6
use rustc_ast:: BinOpKind ;
7
7
use rustc_errors:: Applicability ;
8
- use rustc_hir:: { Block , Expr , ExprKind , Stmt , StmtKind } ;
8
+ use rustc_hir:: { Block , Expr , ExprKind , StmtKind } ;
9
9
use rustc_lexer:: TokenKind ;
10
10
use rustc_lint:: { LateContext , LateLintPass } ;
11
11
use rustc_session:: impl_lint_pass;
@@ -257,14 +257,9 @@ fn block_starts_with_significant_tokens(
257
257
/// If `block` is a block with either one expression or a statement containing an expression,
258
258
/// return the expression. We don't peel blocks recursively, as extra blocks might be intentional.
259
259
fn 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) ,
268
263
_ => None ,
269
264
}
270
265
}
0 commit comments