]> git.lizzy.rs Git - rust.git/commitdiff
Simplify error output
authorEsteban Küber <esteban@kuber.com.ar>
Tue, 28 Mar 2017 00:15:16 +0000 (17:15 -0700)
committerEsteban Küber <esteban@kuber.com.ar>
Tue, 28 Mar 2017 00:15:16 +0000 (17:15 -0700)
src/libsyntax/parse/parser.rs
src/test/ui/did_you_mean/issue-40006.stderr

index a19339f8cc1c124db93a4e5c78e44fba0aa29226..2603b3302c61003e6ab1c41bf08b0c8b876a0ea3 100644 (file)
@@ -4708,26 +4708,21 @@ fn parse_impl_method(&mut self, vis: &Visibility)
                 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:
index 93a0c58f91a57c244e7c06e849e0b118149f7d27..460958027ad0f2d574d68d3698ae32a80b01fd7f 100644 (file)
@@ -1,12 +1,8 @@
-error: can't qualify macro invocation with `pub`
-  --> $DIR/issue-40006.rs:14:5
+error: missing `fn` for method declaration
+  --> $DIR/issue-40006.rs:14:8
    |
 14 |     pub hello_method(&self) {
-   |     ^^^-            - expected `!` here for a macro invocation
-   |        |
-   |        did you mean to write `fn` here for a method declaration?
-   |
-   = help: try adjusting the macro to put `pub` inside the invocation
+   |        ^ missing `fn`
 
 error: aborting due to previous error