Skip to content

Commit ba6c648

Browse files
committed
Use the existing in_external_macro function instead of reimplementing it
1 parent 43d0da5 commit ba6c648

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

compiler/rustc_typeck/src/check/coercion.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ use rustc_hir as hir;
4242
use rustc_hir::def_id::DefId;
4343
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
4444
use rustc_infer::infer::{Coercion, InferOk, InferResult};
45+
use rustc_middle::lint::in_external_macro;
4546
use 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

Comments
 (0)