about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2025-08-10 21:55:02 +0000
committerEsteban Küber <esteban@kuber.com.ar>2025-08-10 21:55:02 +0000
commit48816e74930cb8769fea5acb8a706878b4d79d5b (patch)
tree97add24276d9ac673f80cd1e937ed259d87def64
parentd9bd24d331919299975f36c64ddf6febc4f41fd4 (diff)
downloadrust-48816e74930cb8769fea5acb8a706878b4d79d5b.tar.gz
rust-48816e74930cb8769fea5acb8a706878b4d79d5b.zip
Do not point at macro invocation when providing inference context
-rw-r--r--compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs2
-rw-r--r--tests/ui/proc-macro/match-expander.rs1
-rw-r--r--tests/ui/proc-macro/match-expander.stderr5
3 files changed, 2 insertions, 6 deletions
diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs
index 1c890821b1d..8551780bcd5 100644
--- a/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs
+++ b/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs
@@ -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}`"));
                     }
diff --git a/tests/ui/proc-macro/match-expander.rs b/tests/ui/proc-macro/match-expander.rs
index 34e9a876153..23e5746c540 100644
--- a/tests/ui/proc-macro/match-expander.rs
+++ b/tests/ui/proc-macro/match-expander.rs
@@ -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!
 }
diff --git a/tests/ui/proc-macro/match-expander.stderr b/tests/ui/proc-macro/match-expander.stderr
index 38a0acc4941..b77468ec60a 100644
--- a/tests/ui/proc-macro/match-expander.stderr
+++ b/tests/ui/proc-macro/match-expander.stderr
@@ -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)