expand: add recovery for parse_nt

This commit is contained in:
Mazdak Farrokhzad 2020-03-17 14:13:32 +01:00
parent 3979964200
commit 21944b3a10
5 changed files with 63 additions and 16 deletions

View file

@ -42,6 +42,11 @@ LL | fn f() { assert_eq!(f(), (), assert_eq!(assert_eq!
LL |
LL | fn main() {}
| ^^ unexpected token
|
::: $SRC_DIR/libcore/macros/mod.rs:LL:COL
|
LL | ($left:expr, $right:expr) => ({
| ---------- while parsing argument for this `expr` macro fragment
error: aborting due to 4 previous errors

View file

@ -0,0 +1,10 @@
macro_rules! foo {
($e:expr) => {}
}
foo!(1 + @); //~ ERROR expected expression, found `@`
foo!(1 + @); //~ ERROR expected expression, found `@`
fn main() {
let _recovery_witness: () = 0; //~ ERROR mismatched types
}

View file

@ -0,0 +1,29 @@
error: expected expression, found `@`
--> $DIR/nt-parsing-has-recovery.rs:5:10
|
LL | ($e:expr) => {}
| ------- while parsing argument for this `expr` macro fragment
...
LL | foo!(1 + @);
| ^ expected expression
error: expected expression, found `@`
--> $DIR/nt-parsing-has-recovery.rs:6:10
|
LL | ($e:expr) => {}
| ------- while parsing argument for this `expr` macro fragment
...
LL | foo!(1 + @);
| ^ expected expression
error[E0308]: mismatched types
--> $DIR/nt-parsing-has-recovery.rs:9:33
|
LL | let _recovery_witness: () = 0;
| -- ^ expected `()`, found integer
| |
| expected due to this
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0308`.