]> git.lizzy.rs Git - rust.git/commitdiff
generic_extension: defatalize Error case
authorMazdak Farrokhzad <twingoow@gmail.com>
Tue, 17 Mar 2020 08:37:59 +0000 (09:37 +0100)
committerMazdak Farrokhzad <twingoow@gmail.com>
Tue, 24 Mar 2020 05:28:55 +0000 (06:28 +0100)
src/librustc_expand/mbe/macro_rules.rs
src/test/ui/macros/macro-match-nonterminal.rs
src/test/ui/macros/macro-match-nonterminal.stderr
src/test/ui/parser/macro/issue-33569.rs
src/test/ui/parser/macro/issue-33569.stderr

index 3c619c62c2bf20e9ddc56eac03fbc2159d77bbb4..9d6f5e75faadb1429a9ba07dcbe60e317b1dd387 100644 (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.
index 6d4b32c9bc9a02ddb696dfb63bd73c5e061fe9a8..b23e5c71c03f06e29245481dbfa775b0b3c57874 100644 (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!()
index 1de8c5bd4b47251cec4334a8dff926a2dd9f583e..674ce3434aac63fd9446e23a30c91f34fe2c3271 100644 (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
 
index 9ed53519ceb3156a82eb00d9ddb3454e4f7688e2..e32825ad3e06449a4fe23e8d3e1ee9160c2b86a9 100644 (file)
@@ -1,3 +1,5 @@
+fn main() {}
+
 macro_rules! foo {
     { $+ } => { //~ ERROR expected identifier, found `+`
                 //~^ ERROR missing fragment specifier
index b4d38d3ce4806ca8c5a6d9bf50241a3c01bdb684..a08d26095f5643891fa5da143ee7f4b6e88cf8d5 100644 (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 |     { $+ } => {
    |        ^