@@ -1829,39 +1829,36 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
1829
1829
// Verify that this is a tail expression of a function, otherwise the
1830
1830
// label pointing out the cause for the type coercion will be wrong
1831
1831
// 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
+ {
1833
1835
fcx. suggest_missing_semicolon ( & mut err, expr, expected, false ) ;
1834
1836
let pointing_at_return_type =
1835
1837
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
1841
1841
// If the block is from an external macro or try (`?`) desugaring, then
1842
1842
// do not suggest adding a semicolon, because there's nowhere to put it.
1843
1843
// See issues #81943 and #87051.
1844
1844
&& matches ! (
1845
1845
cond_expr. span. desugaring_kind( ) ,
1846
1846
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
+ )
1852
1853
{
1853
1854
err. span_label ( cond_expr. span , "expected this to be `()`" ) ;
1854
1855
if expr. can_have_side_effects ( ) {
1855
1856
fcx. suggest_semicolon_at_end ( cond_expr. span , & mut err) ;
1856
1857
}
1857
1858
}
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)
1862
1859
} ;
1863
1860
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 ) {
1865
1862
if blk_id. is_none ( ) {
1866
1863
fcx. suggest_missing_return_type (
1867
1864
& mut err,
0 commit comments