diff --git a/compiler/rustc_typeck/src/check/_match.rs b/compiler/rustc_typeck/src/check/_match.rs index 4f15592e6fbac..1b13c98e4c3fa 100644 --- a/compiler/rustc_typeck/src/check/_match.rs +++ b/compiler/rustc_typeck/src/check/_match.rs @@ -356,13 +356,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // 6 | | }; // | |_____^ expected integer, found `()` // ``` - if block.expr.is_none() && block.stmts.is_empty() && outer_span.is_some() { - let sp = if let Some(cs) = cond_span.find_ancestor_inside(span) { - span.with_hi(cs.hi()) - } else { - span - }; - outer_span = Some(sp); + if block.expr.is_none() && block.stmts.is_empty() + && let Some(outer_span) = &mut outer_span + && let Some(cond_span) = cond_span.find_ancestor_inside(*outer_span) + { + *outer_span = outer_span.with_hi(cond_span.hi()) } (self.find_block_span(block), block.hir_id)