Do not point at macro invocation when providing inference context

This commit is contained in:
Esteban Küber
2025-08-10 21:55:02 +00:00
parent d9bd24d331
commit 48816e7493
3 changed files with 2 additions and 6 deletions

View File

@@ -459,7 +459,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
span,
format!("this is an iterator with items of type `{}`", args.type_at(0)),
);
} else {
} else if !span.overlaps(cause.span) {
let expected_ty = self.tcx.short_string(expected_ty, err.long_ty_path());
err.span_label(span, format!("this expression has type `{expected_ty}`"));
}

View File

@@ -8,6 +8,5 @@ fn main() {
match_expander::matcher!();
//~^ ERROR: mismatched types
//~| NOTE: expected `S`, found `bool`
//~| NOTE: this expression has type `S`
//~| NOTE: in this expansion of match_expander::matcher!
}

View File

@@ -2,10 +2,7 @@ error[E0308]: mismatched types
--> $DIR/match-expander.rs:8:5
|
LL | match_expander::matcher!();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| expected `S`, found `bool`
| this expression has type `S`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `S`, found `bool`
|
= note: this error originates in the macro `match_expander::matcher` (in Nightly builds, run with -Z macro-backtrace for more info)