sp,
);
- // Check the `expn_info()` to see if this is a macro; if so, it's hard to
- // extract the text and make a good suggestion, so don't bother.
- let is_macro = sp.ctxt().outer_expn_info().is_some();
+ // If the span is from a macro, then it's hard to extract the text
+ // and make a good suggestion, so don't bother.
+ let is_macro = sp.from_expansion();
match (&expr.node, &expected.sty, &checked_ty.sty) {
(_, &ty::Ref(_, exp, _), &ty::Ref(_, check, _)) => match (&exp.sty, &check.sty) {
// FIXME(estebank): modify once we decide to suggest `as` casts
return false;
}
+ if !self.tcx.sess.source_map().span_to_filename(expr.span).is_real() {
+ // Ignore if span is from within a macro.
+ return false;
+ }
// If casting this expression to a given numeric type would be appropriate in case of a type
// mismatch.