diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-11-17 22:33:18 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-17 22:33:18 +0100 |
| commit | c9ccb0ba2853f97886bdd2b5ea1839839e5e6229 (patch) | |
| tree | d4dbdd01989b27bef18fefd426ba110abce04190 /compiler/rustc_lint/src | |
| parent | 43dca249a218305591e6eb896dd63c419871b018 (diff) | |
| parent | 1cf4132a1610de4319a382aa447f9fe3da52a19c (diff) | |
| download | rust-c9ccb0ba2853f97886bdd2b5ea1839839e5e6229.tar.gz rust-c9ccb0ba2853f97886bdd2b5ea1839839e5e6229.zip | |
Rollup merge of #104433 - TaKO8Ki:fix-104392, r=estebank
Fix `emit_unused_delims_expr` ICE Fixes #104392
Diffstat (limited to 'compiler/rustc_lint/src')
| -rw-r--r-- | compiler/rustc_lint/src/unused.rs | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs index ff0fb9bae92..9ae34013ecb 100644 --- a/compiler/rustc_lint/src/unused.rs +++ b/compiler/rustc_lint/src/unused.rs @@ -533,16 +533,14 @@ trait UnusedDelimLint { right_pos: Option<BytePos>, ) { let spans = match value.kind { - ast::ExprKind::Block(ref block, None) if block.stmts.len() > 0 => { - let start = block.stmts[0].span; - let end = block.stmts[block.stmts.len() - 1].span; - if let Some(start) = start.find_ancestor_inside(value.span) - && let Some(end) = end.find_ancestor_inside(value.span) + ast::ExprKind::Block(ref block, None) if block.stmts.len() == 1 => { + if let StmtKind::Expr(expr) = &block.stmts[0].kind + && let ExprKind::Err = expr.kind { - Some(( - value.span.with_hi(start.lo()), - value.span.with_lo(end.hi()), - )) + return + } + if let Some(span) = block.stmts[0].span.find_ancestor_inside(value.span) { + Some((value.span.with_hi(span.lo()), value.span.with_lo(span.hi()))) } else { None } |
