@@ -42,6 +42,7 @@ use rustc_hir as hir;
4242use rustc_hir:: def_id:: DefId ;
4343use rustc_infer:: infer:: type_variable:: { TypeVariableOrigin , TypeVariableOriginKind } ;
4444use rustc_infer:: infer:: { Coercion , InferOk , InferResult } ;
45+ use rustc_middle:: lint:: in_external_macro;
4546use rustc_middle:: ty:: adjustment:: {
4647 Adjust , Adjustment , AllowTwoPhase , AutoBorrow , AutoBorrowMutability , PointerCast ,
4748} ;
@@ -1451,12 +1452,9 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
14511452 // If the block is from an external macro, then do not suggest
14521453 // adding a semicolon, because there's nowhere to put it.
14531454 // See issue #81943.
1454- let hir = fcx. tcx . hir ( ) ;
1455- let body_owner =
1456- hir. body_owner ( hir. body_owned_by ( hir. enclosing_body_owner ( fcx. body_id ) ) ) ;
1457- let from_same_crate = cond_expr. span . ctxt ( ) . dollar_crate_name ( )
1458- == hir. span ( body_owner) . ctxt ( ) . dollar_crate_name ( ) ;
1459- if cond_expr. span . desugaring_kind ( ) . is_none ( ) && from_same_crate {
1455+ if cond_expr. span . desugaring_kind ( ) . is_none ( )
1456+ && !in_external_macro ( fcx. tcx . sess , cond_expr. span )
1457+ {
14601458 err. span_label ( cond_expr. span , "expected this to be `()`" ) ;
14611459 fcx. suggest_semicolon_at_end ( cond_expr. span , & mut err) ;
14621460 }
0 commit comments