Skip to content

Commit 0cc6d2e

Browse files
committed
Add test case for local macro (which is different from foreign crate macros)
1 parent 506a0df commit 0cc6d2e

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/test/ui/typeck/issue-81943.rs

+4
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@ fn f<F: Fn(i32)>(f: F) { f(0); }
22
fn main() {
33
f(|x| dbg!(x)); //~ERROR
44
f(|x| match x { tmp => { tmp } }); //~ERROR
5+
macro_rules! d {
6+
($e:expr) => { match $e { x => { x } } }
7+
}
8+
f(|x| d!(x)); //~ERROR
59
}

src/test/ui/typeck/issue-81943.stderr

+15-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,20 @@ LL | f(|x| match x { tmp => { tmp } });
1515
| | expected `()`, found `i32`
1616
| expected this to be `()`
1717

18-
error: aborting due to 2 previous errors
18+
error[E0308]: mismatched types
19+
--> $DIR/issue-81943.rs:6:38
20+
|
21+
LL | ($e:expr) => { match $e { x => { x } } }
22+
| ------------------^----- help: consider using a semicolon here
23+
| | |
24+
| | expected `()`, found `i32`
25+
| expected this to be `()`
26+
LL | }
27+
LL | f(|x| d!(x));
28+
| ----- in this macro invocation
29+
|
30+
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
31+
32+
error: aborting due to 3 previous errors
1933

2034
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)