about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2020-03-17 09:37:59 +0100
committerMazdak Farrokhzad <twingoow@gmail.com>2020-03-24 06:28:55 +0100
commitb0537e2081e11ef55c5ab71c3ca5f76fe7158312 (patch)
tree05d58275a5d0be8fef6d6d0d3c8b6f312984cc89
parentb7909b22b5ef31a9cc847be58f50cdf268c7b854 (diff)
downloadrust-b0537e2081e11ef55c5ab71c3ca5f76fe7158312.tar.gz
rust-b0537e2081e11ef55c5ab71c3ca5f76fe7158312.zip
generic_extension: defatalize Error case
-rw-r--r--src/librustc_expand/mbe/macro_rules.rs6
-rw-r--r--src/test/ui/macros/macro-match-nonterminal.rs9
-rw-r--r--src/test/ui/macros/macro-match-nonterminal.stderr18
-rw-r--r--src/test/ui/parser/macro/issue-33569.rs2
-rw-r--r--src/test/ui/parser/macro/issue-33569.stderr6
5 files changed, 32 insertions, 9 deletions
diff --git a/src/librustc_expand/mbe/macro_rules.rs b/src/librustc_expand/mbe/macro_rules.rs
index 3c619c62c2b..9d6f5e75faa 100644
--- a/src/librustc_expand/mbe/macro_rules.rs
+++ b/src/librustc_expand/mbe/macro_rules.rs
@@ -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.
diff --git a/src/test/ui/macros/macro-match-nonterminal.rs b/src/test/ui/macros/macro-match-nonterminal.rs
index 6d4b32c9bc9..b23e5c71c03 100644
--- a/src/test/ui/macros/macro-match-nonterminal.rs
+++ b/src/test/ui/macros/macro-match-nonterminal.rs
@@ -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!()
diff --git a/src/test/ui/macros/macro-match-nonterminal.stderr b/src/test/ui/macros/macro-match-nonterminal.stderr
index 1de8c5bd4b4..674ce3434aa 100644
--- a/src/test/ui/macros/macro-match-nonterminal.stderr
+++ b/src/test/ui/macros/macro-match-nonterminal.stderr
@@ -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
 
diff --git a/src/test/ui/parser/macro/issue-33569.rs b/src/test/ui/parser/macro/issue-33569.rs
index 9ed53519ceb..e32825ad3e0 100644
--- a/src/test/ui/parser/macro/issue-33569.rs
+++ b/src/test/ui/parser/macro/issue-33569.rs
@@ -1,3 +1,5 @@
+fn main() {}
+
 macro_rules! foo {
     { $+ } => { //~ ERROR expected identifier, found `+`
                 //~^ ERROR missing fragment specifier
diff --git a/src/test/ui/parser/macro/issue-33569.stderr b/src/test/ui/parser/macro/issue-33569.stderr
index b4d38d3ce48..a08d26095f5 100644
--- a/src/test/ui/parser/macro/issue-33569.stderr
+++ b/src/test/ui/parser/macro/issue-33569.stderr
@@ -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 |     { $+ } => {
    |        ^