Skip to content

Commit b0537e2

Browse files
committed
generic_extension: defatalize Error case
1 parent b7909b2 commit b0537e2

File tree

5 files changed

+32
-9
lines changed

5 files changed

+32
-9
lines changed

src/librustc_expand/mbe/macro_rules.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,11 @@ fn generic_extension<'cx>(
293293
Some((ref best_token, _)) if best_token.span.lo() >= token.span.lo() => {}
294294
_ => best_failure = Some((token, msg)),
295295
},
296-
Error(err_sp, ref msg) => cx.span_fatal(err_sp.substitute_dummy(sp), &msg[..]),
296+
Error(err_sp, ref msg) => {
297+
let span = err_sp.substitute_dummy(sp);
298+
cx.struct_span_err(span, &msg).emit();
299+
return DummyResult::any(span);
300+
}
297301
}
298302

299303
// The matcher was not `Success(..)`ful.

src/test/ui/macros/macro-match-nonterminal.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
macro_rules! test { ($a, $b) => (()); } //~ ERROR missing fragment
1+
macro_rules! test {
2+
($a, $b) => {
3+
//~^ ERROR missing fragment
4+
//~| ERROR missing fragment
5+
//~| WARN this was previously accepted
6+
()
7+
};
8+
}
29

310
fn main() {
411
test!()
Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
error: missing fragment specifier
2-
--> $DIR/macro-match-nonterminal.rs:1:24
2+
--> $DIR/macro-match-nonterminal.rs:2:8
33
|
4-
LL | macro_rules! test { ($a, $b) => (()); }
5-
| ^
4+
LL | ($a, $b) => {
5+
| ^
66

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

src/test/ui/parser/macro/issue-33569.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
fn main() {}
2+
13
macro_rules! foo {
24
{ $+ } => { //~ ERROR expected identifier, found `+`
35
//~^ ERROR missing fragment specifier

src/test/ui/parser/macro/issue-33569.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
error: expected identifier, found `+`
2-
--> $DIR/issue-33569.rs:2:8
2+
--> $DIR/issue-33569.rs:4:8
33
|
44
LL | { $+ } => {
55
| ^
66

77
error: expected one of: `*`, `+`, or `?`
8-
--> $DIR/issue-33569.rs:4:13
8+
--> $DIR/issue-33569.rs:6:13
99
|
1010
LL | $(x)(y)
1111
| ^^^
1212

1313
error: missing fragment specifier
14-
--> $DIR/issue-33569.rs:2:8
14+
--> $DIR/issue-33569.rs:4:8
1515
|
1616
LL | { $+ } => {
1717
| ^

0 commit comments

Comments
 (0)