@@ -1962,39 +1962,36 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
1962
1962
// Verify that this is a tail expression of a function, otherwise the
1963
1963
// label pointing out the cause for the type coercion will be wrong
1964
1964
// as prior return coercions would not be relevant (#57664).
1965
- let fn_decl = if let ( Some ( expr) , Some ( blk_id) ) = ( expression, blk_id) {
1965
+ if let Some ( expr) = expression
1966
+ && let Some ( blk_id) = blk_id
1967
+ {
1966
1968
fcx. suggest_missing_semicolon ( & mut err, expr, expected, false ) ;
1967
1969
let pointing_at_return_type =
1968
1970
fcx. suggest_mismatched_types_on_tail ( & mut err, expr, expected, found, blk_id) ;
1969
- if let ( Some ( cond_expr) , true , false ) = (
1970
- fcx. tcx . hir ( ) . get_if_cause ( expr. hir_id ) ,
1971
- expected. is_unit ( ) ,
1972
- pointing_at_return_type,
1973
- )
1971
+ if let Some ( cond_expr) = fcx. tcx . hir ( ) . get_if_cause ( expr. hir_id )
1972
+ && expected. is_unit ( )
1973
+ && !pointing_at_return_type
1974
1974
// If the block is from an external macro or try (`?`) desugaring, then
1975
1975
// do not suggest adding a semicolon, because there's nowhere to put it.
1976
1976
// See issues #81943 and #87051.
1977
1977
&& matches ! (
1978
1978
cond_expr. span. desugaring_kind( ) ,
1979
1979
None | Some ( DesugaringKind :: WhileLoop )
1980
- ) && !in_external_macro ( fcx. tcx . sess , cond_expr. span )
1981
- && !matches ! (
1982
- cond_expr. kind,
1983
- hir:: ExprKind :: Match ( .., hir:: MatchSource :: TryDesugar ( _) )
1984
- )
1980
+ )
1981
+ && !in_external_macro ( fcx. tcx . sess , cond_expr. span )
1982
+ && !matches ! (
1983
+ cond_expr. kind,
1984
+ hir:: ExprKind :: Match ( .., hir:: MatchSource :: TryDesugar ( _) )
1985
+ )
1985
1986
{
1986
1987
err. span_label ( cond_expr. span , "expected this to be `()`" ) ;
1987
1988
if expr. can_have_side_effects ( ) {
1988
1989
fcx. suggest_semicolon_at_end ( cond_expr. span , & mut err) ;
1989
1990
}
1990
1991
}
1991
- fcx. get_node_fn_decl ( parent)
1992
- . map ( |( fn_id, fn_decl, _, is_main) | ( fn_id, fn_decl, is_main) )
1993
- } else {
1994
- fcx. get_fn_decl ( parent_id)
1995
1992
} ;
1996
1993
1997
- if let Some ( ( fn_id, fn_decl, can_suggest) ) = fn_decl {
1994
+ if let Some ( ( fn_id, fn_decl, can_suggest) ) = fcx . get_fn_decl ( parent_id ) {
1998
1995
if blk_id. is_none ( ) {
1999
1996
fcx. suggest_missing_return_type (
2000
1997
& mut err,
0 commit comments