about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2020-02-23 04:49:26 +0100
committerMazdak Farrokhzad <twingoow@gmail.com>2020-02-24 00:59:38 +0100
commitab84914fe47aa2da615c9e759e686d1a45f8aae3 (patch)
tree408412e26a58c1b2da1da200a4202b6f19e7e25d
parentd446c73e6ab94fe37f7d7b8f2abf633ed6344c8a (diff)
downloadrust-ab84914fe47aa2da615c9e759e686d1a45f8aae3.tar.gz
rust-ab84914fe47aa2da615c9e759e686d1a45f8aae3.zip
parser: tweak unmatched wording
-rw-r--r--src/librustc_parse/parser/item.rs11
-rw-r--r--src/test/ui/parser/default-unmatched-assoc.rs4
-rw-r--r--src/test/ui/parser/default-unmatched-assoc.stderr12
-rw-r--r--src/test/ui/parser/default-unmatched-extern.rs2
-rw-r--r--src/test/ui/parser/default-unmatched-extern.stderr6
-rw-r--r--src/test/ui/parser/default-unmatched.rs2
-rw-r--r--src/test/ui/parser/default-unmatched.stderr6
-rw-r--r--src/test/ui/parser/default.rs2
-rw-r--r--src/test/ui/parser/default.stderr6
-rw-r--r--src/test/ui/parser/duplicate-visibility.rs2
-rw-r--r--src/test/ui/parser/duplicate-visibility.stderr4
-rw-r--r--src/test/ui/parser/impl-parsing.rs2
-rw-r--r--src/test/ui/parser/impl-parsing.stderr6
-rw-r--r--src/test/ui/parser/issue-41155.rs2
-rw-r--r--src/test/ui/parser/issue-41155.stderr4
-rw-r--r--src/test/ui/pub/pub-restricted-error-fn.rs2
-rw-r--r--src/test/ui/pub/pub-restricted-error-fn.stderr4
17 files changed, 45 insertions, 32 deletions
diff --git a/src/librustc_parse/parser/item.rs b/src/librustc_parse/parser/item.rs
index 52619866c4e..d2073a5473a 100644
--- a/src/librustc_parse/parser/item.rs
+++ b/src/librustc_parse/parser/item.rs
@@ -119,17 +119,18 @@ impl<'a> Parser<'a> {
         }
         let vs = pprust::vis_to_string(&vis);
         let vs = vs.trim_end();
-        self.struct_span_err(vis.span, &format!("unmatched visibility `{}`", vs))
-            .span_label(vis.span, "the unmatched visibility")
+        self.struct_span_err(vis.span, &format!("visibility `{}` not followed by an item", vs))
+            .span_label(vis.span, "the visibility")
             .help(&format!("you likely meant to define an item, e.g., `{} fn foo() {{}}`", vs))
             .emit();
     }
 
     /// Error in-case a `default` was parsed but no item followed.
     fn error_on_unmatched_defaultness(&self, def: Defaultness) {
-        if let Defaultness::Default(span) = def {
-            self.struct_span_err(span, "unmatched `default`")
-                .span_label(span, "the unmatched `default`")
+        if let Defaultness::Default(sp) = def {
+            self.struct_span_err(sp, "`default` not followed by an item")
+                .span_label(sp, "the `default` qualifier")
+                .note("only `fn`, `const`, `type`, or `impl` items may be prefixed by `default`")
                 .emit();
         }
     }
diff --git a/src/test/ui/parser/default-unmatched-assoc.rs b/src/test/ui/parser/default-unmatched-assoc.rs
index bca6f5654db..0c8ee0f7800 100644
--- a/src/test/ui/parser/default-unmatched-assoc.rs
+++ b/src/test/ui/parser/default-unmatched-assoc.rs
@@ -3,7 +3,7 @@ fn main() {}
 trait Foo {
     default!(); //~ ERROR cannot find macro `default` in this scope
     default do
-    //~^ ERROR unmatched `default`
+    //~^ ERROR `default` not followed by an item
     //~| ERROR non-item in item list
 }
 
@@ -11,6 +11,6 @@ struct S;
 impl S {
     default!(); //~ ERROR cannot find macro `default` in this scope
     default do
-    //~^ ERROR unmatched `default`
+    //~^ ERROR `default` not followed by an item
     //~| ERROR non-item in item list
 }
diff --git a/src/test/ui/parser/default-unmatched-assoc.stderr b/src/test/ui/parser/default-unmatched-assoc.stderr
index f3877f2ca6d..22db46d63df 100644
--- a/src/test/ui/parser/default-unmatched-assoc.stderr
+++ b/src/test/ui/parser/default-unmatched-assoc.stderr
@@ -1,8 +1,10 @@
-error: unmatched `default`
+error: `default` not followed by an item
   --> $DIR/default-unmatched-assoc.rs:5:5
    |
 LL |     default do
-   |     ^^^^^^^ the unmatched `default`
+   |     ^^^^^^^ the `default` qualifier
+   |
+   = note: only `fn`, `const`, `type`, or `impl` items may be prefixed by `default`
 
 error: non-item in item list
   --> $DIR/default-unmatched-assoc.rs:5:13
@@ -16,11 +18,13 @@ LL |     default do
 LL | }
    | - item list ends here
 
-error: unmatched `default`
+error: `default` not followed by an item
   --> $DIR/default-unmatched-assoc.rs:13:5
    |
 LL |     default do
-   |     ^^^^^^^ the unmatched `default`
+   |     ^^^^^^^ the `default` qualifier
+   |
+   = note: only `fn`, `const`, `type`, or `impl` items may be prefixed by `default`
 
 error: non-item in item list
   --> $DIR/default-unmatched-assoc.rs:13:13
diff --git a/src/test/ui/parser/default-unmatched-extern.rs b/src/test/ui/parser/default-unmatched-extern.rs
index fbf87a892f0..784df9bc77e 100644
--- a/src/test/ui/parser/default-unmatched-extern.rs
+++ b/src/test/ui/parser/default-unmatched-extern.rs
@@ -3,6 +3,6 @@ fn main() {}
 extern "C" {
     default!(); //~ ERROR cannot find macro `default` in this scope
     default do
-    //~^ ERROR unmatched `default`
+    //~^ ERROR `default` not followed by an item
     //~| ERROR non-item in item list
 }
diff --git a/src/test/ui/parser/default-unmatched-extern.stderr b/src/test/ui/parser/default-unmatched-extern.stderr
index 00c8898e2ce..ffbfbc73c18 100644
--- a/src/test/ui/parser/default-unmatched-extern.stderr
+++ b/src/test/ui/parser/default-unmatched-extern.stderr
@@ -1,8 +1,10 @@
-error: unmatched `default`
+error: `default` not followed by an item
   --> $DIR/default-unmatched-extern.rs:5:5
    |
 LL |     default do
-   |     ^^^^^^^ the unmatched `default`
+   |     ^^^^^^^ the `default` qualifier
+   |
+   = note: only `fn`, `const`, `type`, or `impl` items may be prefixed by `default`
 
 error: non-item in item list
   --> $DIR/default-unmatched-extern.rs:5:13
diff --git a/src/test/ui/parser/default-unmatched.rs b/src/test/ui/parser/default-unmatched.rs
index 31696de0a5c..796e184a0d8 100644
--- a/src/test/ui/parser/default-unmatched.rs
+++ b/src/test/ui/parser/default-unmatched.rs
@@ -1,6 +1,6 @@
 mod foo {
     default!(); // OK.
     default do
-    //~^ ERROR unmatched `default`
+    //~^ ERROR `default` not followed by an item
     //~| ERROR expected item, found reserved keyword `do`
 }
diff --git a/src/test/ui/parser/default-unmatched.stderr b/src/test/ui/parser/default-unmatched.stderr
index 6e4ef7b79fc..26012557761 100644
--- a/src/test/ui/parser/default-unmatched.stderr
+++ b/src/test/ui/parser/default-unmatched.stderr
@@ -1,8 +1,10 @@
-error: unmatched `default`
+error: `default` not followed by an item
   --> $DIR/default-unmatched.rs:3:5
    |
 LL |     default do
-   |     ^^^^^^^ the unmatched `default`
+   |     ^^^^^^^ the `default` qualifier
+   |
+   = note: only `fn`, `const`, `type`, or `impl` items may be prefixed by `default`
 
 error: expected item, found reserved keyword `do`
   --> $DIR/default-unmatched.rs:3:13
diff --git a/src/test/ui/parser/default.rs b/src/test/ui/parser/default.rs
index bd9ed0f4524..6cfa141478e 100644
--- a/src/test/ui/parser/default.rs
+++ b/src/test/ui/parser/default.rs
@@ -20,7 +20,7 @@ impl Foo for u16 {
 
 impl Foo for u32 { //~ ERROR not all trait items implemented, missing: `foo`
     default pub fn foo<T: Default>() -> T { T::default() }
-    //~^ ERROR unmatched `default`
+    //~^ ERROR `default` not followed by an item
     //~| ERROR non-item in item list
 }
 
diff --git a/src/test/ui/parser/default.stderr b/src/test/ui/parser/default.stderr
index fbf8101c36a..96b14b42767 100644
--- a/src/test/ui/parser/default.stderr
+++ b/src/test/ui/parser/default.stderr
@@ -1,8 +1,10 @@
-error: unmatched `default`
+error: `default` not followed by an item
   --> $DIR/default.rs:22:5
    |
 LL |     default pub fn foo<T: Default>() -> T { T::default() }
-   |     ^^^^^^^ the unmatched `default`
+   |     ^^^^^^^ the `default` qualifier
+   |
+   = note: only `fn`, `const`, `type`, or `impl` items may be prefixed by `default`
 
 error: non-item in item list
   --> $DIR/default.rs:22:13
diff --git a/src/test/ui/parser/duplicate-visibility.rs b/src/test/ui/parser/duplicate-visibility.rs
index 949b6e1dc24..edea2d1e5e2 100644
--- a/src/test/ui/parser/duplicate-visibility.rs
+++ b/src/test/ui/parser/duplicate-visibility.rs
@@ -2,6 +2,6 @@ fn main() {}
 
 extern {
     pub pub fn foo();
-    //~^ ERROR unmatched visibility `pub`
+    //~^ ERROR visibility `pub` not followed by an item
     //~| ERROR non-item in item list
 }
diff --git a/src/test/ui/parser/duplicate-visibility.stderr b/src/test/ui/parser/duplicate-visibility.stderr
index 2c79a343d05..d8e38046a6c 100644
--- a/src/test/ui/parser/duplicate-visibility.stderr
+++ b/src/test/ui/parser/duplicate-visibility.stderr
@@ -1,8 +1,8 @@
-error: unmatched visibility `pub`
+error: visibility `pub` not followed by an item
   --> $DIR/duplicate-visibility.rs:4:5
    |
 LL |     pub pub fn foo();
-   |     ^^^ the unmatched visibility
+   |     ^^^ the visibility
    |
    = help: you likely meant to define an item, e.g., `pub fn foo() {}`
 
diff --git a/src/test/ui/parser/impl-parsing.rs b/src/test/ui/parser/impl-parsing.rs
index 662ed28f2f7..c2ed7531a94 100644
--- a/src/test/ui/parser/impl-parsing.rs
+++ b/src/test/ui/parser/impl-parsing.rs
@@ -7,4 +7,4 @@ impl ?Sized for Type {} //~ ERROR expected a trait, found type
 impl ?Sized for .. {} //~ ERROR expected a trait, found type
 
 default unsafe FAIL //~ ERROR expected item, found keyword `unsafe`
-//~^ ERROR unmatched `default`
+//~^ ERROR `default` not followed by an item
diff --git a/src/test/ui/parser/impl-parsing.stderr b/src/test/ui/parser/impl-parsing.stderr
index a5fc3e46896..ce673765aba 100644
--- a/src/test/ui/parser/impl-parsing.stderr
+++ b/src/test/ui/parser/impl-parsing.stderr
@@ -22,11 +22,13 @@ error: expected a trait, found type
 LL | impl ?Sized for .. {}
    |      ^^^^^^
 
-error: unmatched `default`
+error: `default` not followed by an item
   --> $DIR/impl-parsing.rs:9:1
    |
 LL | default unsafe FAIL
-   | ^^^^^^^ the unmatched `default`
+   | ^^^^^^^ the `default` qualifier
+   |
+   = note: only `fn`, `const`, `type`, or `impl` items may be prefixed by `default`
 
 error: expected item, found keyword `unsafe`
   --> $DIR/impl-parsing.rs:9:9
diff --git a/src/test/ui/parser/issue-41155.rs b/src/test/ui/parser/issue-41155.rs
index bed4805e7ce..5bfbe0c5e68 100644
--- a/src/test/ui/parser/issue-41155.rs
+++ b/src/test/ui/parser/issue-41155.rs
@@ -1,7 +1,7 @@
 struct S;
 
 impl S {
-    pub //~ ERROR unmatched visibility `pub`
+    pub //~ ERROR visibility `pub` not followed by an item
 } //~ ERROR non-item in item list
 
 fn main() {}
diff --git a/src/test/ui/parser/issue-41155.stderr b/src/test/ui/parser/issue-41155.stderr
index a9c1035f4d8..09bbee51800 100644
--- a/src/test/ui/parser/issue-41155.stderr
+++ b/src/test/ui/parser/issue-41155.stderr
@@ -1,8 +1,8 @@
-error: unmatched visibility `pub`
+error: visibility `pub` not followed by an item
   --> $DIR/issue-41155.rs:4:5
    |
 LL |     pub
-   |     ^^^ the unmatched visibility
+   |     ^^^ the visibility
    |
    = help: you likely meant to define an item, e.g., `pub fn foo() {}`
 
diff --git a/src/test/ui/pub/pub-restricted-error-fn.rs b/src/test/ui/pub/pub-restricted-error-fn.rs
index 3f8904fbe79..73806fdfe72 100644
--- a/src/test/ui/pub/pub-restricted-error-fn.rs
+++ b/src/test/ui/pub/pub-restricted-error-fn.rs
@@ -1,2 +1,2 @@
-pub(crate) () fn foo() {} //~ unmatched visibility
+pub(crate) () fn foo() {} //~ ERROR visibility `pub(crate)` not followed by an item
 //~^ ERROR expected item, found `(`
diff --git a/src/test/ui/pub/pub-restricted-error-fn.stderr b/src/test/ui/pub/pub-restricted-error-fn.stderr
index c0168b02da6..42d03941e41 100644
--- a/src/test/ui/pub/pub-restricted-error-fn.stderr
+++ b/src/test/ui/pub/pub-restricted-error-fn.stderr
@@ -1,8 +1,8 @@
-error: unmatched visibility `pub(crate)`
+error: visibility `pub(crate)` not followed by an item
   --> $DIR/pub-restricted-error-fn.rs:1:1
    |
 LL | pub(crate) () fn foo() {}
-   | ^^^^^^^^^^ the unmatched visibility
+   | ^^^^^^^^^^ the visibility
    |
    = help: you likely meant to define an item, e.g., `pub(crate) fn foo() {}`