Skip to content

Commit d9bd24d

Browse files
committed
Add test showing innecessary inference span
1 parent e9609ab commit d9bd24d

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
extern crate proc_macro;
2+
3+
use proc_macro::TokenStream;
4+
5+
#[proc_macro]
6+
pub fn matcher(input: TokenStream) -> TokenStream {
7+
"
8+
struct S(());
9+
let s = S(());
10+
match s {
11+
true => {}
12+
_ => {}
13+
}
14+
".parse().unwrap()
15+
}

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//@ proc-macro: match-expander.rs
2+
// Ensure that we don't point at macro invocation when providing inference contexts.
3+
4+
#[macro_use]
5+
extern crate match_expander;
6+
7+
fn main() {
8+
match_expander::matcher!();
9+
//~^ ERROR: mismatched types
10+
//~| NOTE: expected `S`, found `bool`
11+
//~| NOTE: this expression has type `S`
12+
//~| NOTE: in this expansion of match_expander::matcher!
13+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/match-expander.rs:8:5
3+
|
4+
LL | match_expander::matcher!();
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
| |
7+
| expected `S`, found `bool`
8+
| this expression has type `S`
9+
|
10+
= note: this error originates in the macro `match_expander::matcher` (in Nightly builds, run with -Z macro-backtrace for more info)
11+
12+
error: aborting due to 1 previous error
13+
14+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)