Skip to content

Commit

Permalink
Add test case for local macro (which is different from foreign crate …
Browse files Browse the repository at this point in the history
…macros)
  • Loading branch information
notriddle committed Feb 14, 2021
1 parent 506a0df commit 0cc6d2e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/test/ui/typeck/issue-81943.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ fn f<F: Fn(i32)>(f: F) { f(0); }
fn main() {
f(|x| dbg!(x)); //~ERROR
f(|x| match x { tmp => { tmp } }); //~ERROR
macro_rules! d {
($e:expr) => { match $e { x => { x } } }
}
f(|x| d!(x)); //~ERROR
}
16 changes: 15 additions & 1 deletion src/test/ui/typeck/issue-81943.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ LL | f(|x| match x { tmp => { tmp } });
| | expected `()`, found `i32`
| expected this to be `()`

error: aborting due to 2 previous errors
error[E0308]: mismatched types
--> $DIR/issue-81943.rs:6:38
|
LL | ($e:expr) => { match $e { x => { x } } }
| ------------------^----- help: consider using a semicolon here
| | |
| | expected `()`, found `i32`
| expected this to be `()`
LL | }
LL | f(|x| d!(x));
| ----- in this macro invocation
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 3 previous errors

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

0 comments on commit 0cc6d2e

Please sign in to comment.