Skip to content

Commit 48816e7

Browse files
committed
Do not point at macro invocation when providing inference context
1 parent d9bd24d commit 48816e7

File tree

3 files changed

+2
-6
lines changed

3 files changed

+2
-6
lines changed

compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
459459
span,
460460
format!("this is an iterator with items of type `{}`", args.type_at(0)),
461461
);
462-
} else {
462+
} else if !span.overlaps(cause.span) {
463463
let expected_ty = self.tcx.short_string(expected_ty, err.long_ty_path());
464464
err.span_label(span, format!("this expression has type `{expected_ty}`"));
465465
}

tests/ui/proc-macro/match-expander.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@ fn main() {
88
match_expander::matcher!();
99
//~^ ERROR: mismatched types
1010
//~| NOTE: expected `S`, found `bool`
11-
//~| NOTE: this expression has type `S`
1211
//~| NOTE: in this expansion of match_expander::matcher!
1312
}

tests/ui/proc-macro/match-expander.stderr

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ error[E0308]: mismatched types
22
--> $DIR/match-expander.rs:8:5
33
|
44
LL | match_expander::matcher!();
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
6-
| |
7-
| expected `S`, found `bool`
8-
| this expression has type `S`
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `S`, found `bool`
96
|
107
= note: this error originates in the macro `match_expander::matcher` (in Nightly builds, run with -Z macro-backtrace for more info)
118

0 commit comments

Comments
 (0)