generic_extension: defatalize Error case

This commit is contained in:
Mazdak Farrokhzad 2020-03-17 09:37:59 +01:00
parent b7909b22b5
commit b0537e2081
5 changed files with 32 additions and 9 deletions

View File

@ -293,7 +293,11 @@ fn generic_extension<'cx>(
Some((ref best_token, _)) if best_token.span.lo() >= token.span.lo() => {}
_ => best_failure = Some((token, msg)),
},
Error(err_sp, ref msg) => cx.span_fatal(err_sp.substitute_dummy(sp), &msg[..]),
Error(err_sp, ref msg) => {
let span = err_sp.substitute_dummy(sp);
cx.struct_span_err(span, &msg).emit();
return DummyResult::any(span);
}
}
// The matcher was not `Success(..)`ful.

View File

@ -1,4 +1,11 @@
macro_rules! test { ($a, $b) => (()); } //~ ERROR missing fragment
macro_rules! test {
($a, $b) => {
//~^ ERROR missing fragment
//~| ERROR missing fragment
//~| WARN this was previously accepted
()
};
}
fn main() {
test!()

View File

@ -1,8 +1,18 @@
error: missing fragment specifier
--> $DIR/macro-match-nonterminal.rs:1:24
--> $DIR/macro-match-nonterminal.rs:2:8
|
LL | macro_rules! test { ($a, $b) => (()); }
| ^
LL | ($a, $b) => {
| ^
error: aborting due to previous error
error: missing fragment specifier
--> $DIR/macro-match-nonterminal.rs:2:10
|
LL | ($a, $b) => {
| ^^
|
= note: `#[deny(missing_fragment_specifier)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107>
error: aborting due to 2 previous errors

View File

@ -1,3 +1,5 @@
fn main() {}
macro_rules! foo {
{ $+ } => { //~ ERROR expected identifier, found `+`
//~^ ERROR missing fragment specifier

View File

@ -1,17 +1,17 @@
error: expected identifier, found `+`
--> $DIR/issue-33569.rs:2:8
--> $DIR/issue-33569.rs:4:8
|
LL | { $+ } => {
| ^
error: expected one of: `*`, `+`, or `?`
--> $DIR/issue-33569.rs:4:13
--> $DIR/issue-33569.rs:6:13
|
LL | $(x)(y)
| ^^^
error: missing fragment specifier
--> $DIR/issue-33569.rs:2:8
--> $DIR/issue-33569.rs:4:8
|
LL | { $+ } => {
| ^