about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2017-03-27 17:15:16 -0700
committerEsteban Küber <esteban@kuber.com.ar>2017-03-27 17:15:16 -0700
commitc963d613a2275d5c9b31cd7124dda2f2af61deb6 (patch)
tree9582b5ee80d16754374ab1ae47d413df395dd917 /src/libsyntax/parse
parent57009caabd2a45a6efa4d36149feec39ab0a0658 (diff)
downloadrust-c963d613a2275d5c9b31cd7124dda2f2af61deb6.tar.gz
rust-c963d613a2275d5c9b31cd7124dda2f2af61deb6.zip
Simplify error output
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/parser.rs17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index a19339f8cc1..2603b3302c6 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -4708,26 +4708,21 @@ impl<'a> Parser<'a> {
                 if let Err(mut bang_err) = bang_err {
                     // Given this code `pub path(`, it seems like this is not setting the
                     // visibility of a macro invocation, but rather a mistyped method declaration.
-                    // Keep the macro diagnostic, but also provide a hint that `fn` might be
-                    // missing. Don't complain about the missing `!` as a separate diagnostic, add
-                    // label in the appropriate place as part of one unified diagnostic.
+                    // Create a diagnostic pointing out that `fn` is missing.
                     //
                     // x |     pub path(&self) {
-                    //   |     ^^^-    - expected `!` here for a macro invocation
-                    //   |        |
-                    //   |        did you mean to write `fn` here for a method declaration?
+                    //   |        ^ missing `fn` for method declaration
 
+                    err.cancel();
                     bang_err.cancel();
-                    err.span_label(self.span, &"expected `!` here for a macro invocation");
                     //     pub  path(
                     //        ^^ `sp` below will point to this
                     let sp = mk_sp(prev_span.hi, self.prev_span.lo);
-                    err.span_label(sp,
-                                   &"did you mean to write `fn` here for a method declaration?");
+                    err = self.diagnostic()
+                        .struct_span_err(sp, "missing `fn` for method declaration");
+                    err.span_label(sp, &"missing `fn`");
                 }
                 return Err(err);
-            } else if let Err(bang_err) = bang_err {
-                return Err(bang_err);
             }
 
             // eat a matched-delimiter token tree: