@@ -1854,25 +1854,24 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
18541854 fcx. err_ctxt ( ) . report_mismatched_types ( cause, fcx. param_env , expected, found, ty_err) ;
18551855
18561856 let due_to_block = matches ! ( fcx. tcx. hir_node( block_or_return_id) , hir:: Node :: Block ( ..) ) ;
1857-
1858- let parent_id = fcx. tcx . parent_hir_id ( block_or_return_id) ;
1859- let parent = fcx. tcx . hir_node ( parent_id) ;
1857+ let parent = fcx. tcx . parent_hir_node ( block_or_return_id) ;
18601858 if let Some ( expr) = expression
18611859 && let hir:: Node :: Expr ( & hir:: Expr {
18621860 kind : hir:: ExprKind :: Closure ( & hir:: Closure { body, .. } ) ,
18631861 ..
18641862 } ) = parent
1865- && !matches ! ( fcx. tcx. hir_body( body) . value. kind, hir:: ExprKind :: Block ( ..) )
18661863 {
1867- fcx. suggest_missing_semicolon ( & mut err, expr, expected, true ) ;
1864+ let needs_block =
1865+ !matches ! ( fcx. tcx. hir_body( body) . value. kind, hir:: ExprKind :: Block ( ..) ) ;
1866+ fcx. suggest_missing_semicolon ( & mut err, expr, expected, needs_block, true ) ;
18681867 }
18691868 // Verify that this is a tail expression of a function, otherwise the
18701869 // label pointing out the cause for the type coercion will be wrong
18711870 // as prior return coercions would not be relevant (#57664).
18721871 if let Some ( expr) = expression
18731872 && due_to_block
18741873 {
1875- fcx. suggest_missing_semicolon ( & mut err, expr, expected, false ) ;
1874+ fcx. suggest_missing_semicolon ( & mut err, expr, expected, false , false ) ;
18761875 let pointing_at_return_type = fcx. suggest_mismatched_types_on_tail (
18771876 & mut err,
18781877 expr,
0 commit comments