@@ -1829,39 +1829,36 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
18291829 // Verify that this is a tail expression of a function, otherwise the
18301830 // label pointing out the cause for the type coercion will be wrong
18311831 // as prior return coercions would not be relevant (#57664).
1832- let fn_decl = if let ( Some ( expr) , Some ( blk_id) ) = ( expression, blk_id) {
1832+ if let Some ( expr) = expression
1833+ && let Some ( blk_id) = blk_id
1834+ {
18331835 fcx. suggest_missing_semicolon ( & mut err, expr, expected, false ) ;
18341836 let pointing_at_return_type =
18351837 fcx. suggest_mismatched_types_on_tail ( & mut err, expr, expected, found, blk_id) ;
1836- if let ( Some ( cond_expr) , true , false ) = (
1837- fcx. tcx . hir ( ) . get_if_cause ( expr. hir_id ) ,
1838- expected. is_unit ( ) ,
1839- pointing_at_return_type,
1840- )
1838+ if let Some ( cond_expr) = fcx. tcx . hir ( ) . get_if_cause ( expr. hir_id )
1839+ && expected. is_unit ( )
1840+ && !pointing_at_return_type
18411841 // If the block is from an external macro or try (`?`) desugaring, then
18421842 // do not suggest adding a semicolon, because there's nowhere to put it.
18431843 // See issues #81943 and #87051.
18441844 && matches ! (
18451845 cond_expr. span. desugaring_kind( ) ,
18461846 None | Some ( DesugaringKind :: WhileLoop )
1847- ) && !in_external_macro ( fcx. tcx . sess , cond_expr. span )
1848- && !matches ! (
1849- cond_expr. kind,
1850- hir:: ExprKind :: Match ( .., hir:: MatchSource :: TryDesugar ( _) )
1851- )
1847+ )
1848+ && !in_external_macro ( fcx. tcx . sess , cond_expr. span )
1849+ && !matches ! (
1850+ cond_expr. kind,
1851+ hir:: ExprKind :: Match ( .., hir:: MatchSource :: TryDesugar ( _) )
1852+ )
18521853 {
18531854 err. span_label ( cond_expr. span , "expected this to be `()`" ) ;
18541855 if expr. can_have_side_effects ( ) {
18551856 fcx. suggest_semicolon_at_end ( cond_expr. span , & mut err) ;
18561857 }
18571858 }
1858- fcx. get_node_fn_decl ( parent)
1859- . map ( |( fn_id, fn_decl, _, is_main) | ( fn_id, fn_decl, is_main) )
1860- } else {
1861- fcx. get_fn_decl ( parent_id)
18621859 } ;
18631860
1864- if let Some ( ( fn_id, fn_decl, can_suggest) ) = fn_decl {
1861+ if let Some ( ( fn_id, fn_decl, can_suggest) ) = fcx . get_fn_decl ( parent_id ) {
18651862 if blk_id. is_none ( ) {
18661863 fcx. suggest_missing_return_type (
18671864 & mut err,
0 commit comments