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