about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2025-08-10 21:52:23 +0000
committerEsteban Küber <esteban@kuber.com.ar>2025-08-10 21:52:23 +0000
commitd9bd24d331919299975f36c64ddf6febc4f41fd4 (patch)
tree4e10add17ca52ea555678895de25a9c2ab9728c9
parente9609abda42e8d88cf1f07946362cd81516792da (diff)
downloadrust-d9bd24d331919299975f36c64ddf6febc4f41fd4.tar.gz
rust-d9bd24d331919299975f36c64ddf6febc4f41fd4.zip
Add test showing innecessary inference span
-rw-r--r--tests/ui/proc-macro/auxiliary/match-expander.rs15
-rw-r--r--tests/ui/proc-macro/match-expander.rs13
-rw-r--r--tests/ui/proc-macro/match-expander.stderr14
3 files changed, 42 insertions, 0 deletions
diff --git a/tests/ui/proc-macro/auxiliary/match-expander.rs b/tests/ui/proc-macro/auxiliary/match-expander.rs
new file mode 100644
index 00000000000..bf78df2addf
--- /dev/null
+++ b/tests/ui/proc-macro/auxiliary/match-expander.rs
@@ -0,0 +1,15 @@
+extern crate proc_macro;
+
+use proc_macro::TokenStream;
+
+#[proc_macro]
+pub fn matcher(input: TokenStream) -> TokenStream {
+"
+struct S(());
+let s = S(());
+match s {
+    true => {}
+    _ => {}
+}
+".parse().unwrap()
+}
diff --git a/tests/ui/proc-macro/match-expander.rs b/tests/ui/proc-macro/match-expander.rs
new file mode 100644
index 00000000000..34e9a876153
--- /dev/null
+++ b/tests/ui/proc-macro/match-expander.rs
@@ -0,0 +1,13 @@
+//@ proc-macro: match-expander.rs
+// Ensure that we don't point at macro invocation when providing inference contexts.
+
+#[macro_use]
+extern crate match_expander;
+
+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
new file mode 100644
index 00000000000..38a0acc4941
--- /dev/null
+++ b/tests/ui/proc-macro/match-expander.stderr
@@ -0,0 +1,14 @@
+error[E0308]: mismatched types
+  --> $DIR/match-expander.rs:8:5
+   |
+LL |     match_expander::matcher!();
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |     |
+   |     expected `S`, found `bool`
+   |     this expression has type `S`
+   |
+   = note: this error originates in the macro `match_expander::matcher` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0308`.