about summary refs log tree commit diff
path: root/src/test/ui/parser
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-03-18 02:32:39 +0000
committerbors <bors@rust-lang.org>2021-03-18 02:32:39 +0000
commit81c1d7a1506e5f4bcc5f12fb49f3b6e9bb87c605 (patch)
tree694da0e4224aef84e5c245671096c9265d44f1f6 /src/test/ui/parser
parent146f5745606b48afca8e7d7702e363e88caa80e1 (diff)
parent21c157442c1e97745b91b8c3286ceabbc9f7be3f (diff)
downloadrust-81c1d7a1506e5f4bcc5f12fb49f3b6e9bb87c605.tar.gz
rust-81c1d7a1506e5f4bcc5f12fb49f3b6e9bb87c605.zip
Auto merge of #76447 - pickfire:async-pub, r=estebank
Detect async visibility wrong order, `async pub`

Partially address #76437.
Diffstat (limited to 'src/test/ui/parser')
-rw-r--r--src/test/ui/parser/duplicate-visibility.rs5
-rw-r--r--src/test/ui/parser/duplicate-visibility.stderr25
-rw-r--r--src/test/ui/parser/issue-76437-async.rs7
-rw-r--r--src/test/ui/parser/issue-76437-async.stderr11
-rw-r--r--src/test/ui/parser/issue-76437-const-async-unsafe.rs7
-rw-r--r--src/test/ui/parser/issue-76437-const-async-unsafe.stderr11
-rw-r--r--src/test/ui/parser/issue-76437-const-async.rs7
-rw-r--r--src/test/ui/parser/issue-76437-const-async.stderr11
-rw-r--r--src/test/ui/parser/issue-76437-const.rs7
-rw-r--r--src/test/ui/parser/issue-76437-const.stderr11
-rw-r--r--src/test/ui/parser/issue-76437-pub-crate-unsafe.rs7
-rw-r--r--src/test/ui/parser/issue-76437-pub-crate-unsafe.stderr11
-rw-r--r--src/test/ui/parser/issue-76437-unsafe.rs7
-rw-r--r--src/test/ui/parser/issue-76437-unsafe.stderr11
14 files changed, 121 insertions, 17 deletions
diff --git a/src/test/ui/parser/duplicate-visibility.rs b/src/test/ui/parser/duplicate-visibility.rs
index 547329cfb1b..97f19b3da45 100644
--- a/src/test/ui/parser/duplicate-visibility.rs
+++ b/src/test/ui/parser/duplicate-visibility.rs
@@ -1,7 +1,8 @@
+// ignore-tidy-linelength
+
 fn main() {}
 
 extern "C" {
     pub pub fn foo();
-    //~^ ERROR visibility `pub` is not followed by an item
-    //~| ERROR non-item in item list
+    //~^ ERROR expected one of `(`, `async`, `const`, `default`, `extern`, `fn`, `pub`, `unsafe`, or `use`, found keyword `pub`
 }
diff --git a/src/test/ui/parser/duplicate-visibility.stderr b/src/test/ui/parser/duplicate-visibility.stderr
index 8d8122292ae..6ac27078ea3 100644
--- a/src/test/ui/parser/duplicate-visibility.stderr
+++ b/src/test/ui/parser/duplicate-visibility.stderr
@@ -1,21 +1,16 @@
-error: visibility `pub` is not followed by an item
-  --> $DIR/duplicate-visibility.rs:4:5
-   |
-LL |     pub pub fn foo();
-   |     ^^^ the visibility
-   |
-   = help: you likely meant to define an item, e.g., `pub fn foo() {}`
-
-error: non-item in item list
-  --> $DIR/duplicate-visibility.rs:4:9
+error: expected one of `(`, `async`, `const`, `default`, `extern`, `fn`, `pub`, `unsafe`, or `use`, found keyword `pub`
+  --> $DIR/duplicate-visibility.rs:6:9
    |
 LL | extern "C" {
-   |            - item list starts here
+   |            - while parsing this item list starting here
 LL |     pub pub fn foo();
-   |         ^^^ non-item starts here
-...
+   |         ^^^
+   |         |
+   |         expected one of 9 possible tokens
+   |         help: visibility `pub` must come before `pub pub`: `pub pub pub`
+LL |
 LL | }
-   | - item list ends here
+   | - the item list ends here
 
-error: aborting due to 2 previous errors
+error: aborting due to previous error
 
diff --git a/src/test/ui/parser/issue-76437-async.rs b/src/test/ui/parser/issue-76437-async.rs
new file mode 100644
index 00000000000..84ee3dd2112
--- /dev/null
+++ b/src/test/ui/parser/issue-76437-async.rs
@@ -0,0 +1,7 @@
+// edition:2018
+
+mod t {
+    async pub fn t() {}
+    //~^ ERROR expected one of `extern`, `fn`, or `unsafe`, found keyword `pub`
+    //~| HELP visibility `pub` must come before `async`
+}
diff --git a/src/test/ui/parser/issue-76437-async.stderr b/src/test/ui/parser/issue-76437-async.stderr
new file mode 100644
index 00000000000..2c9c2a8cfba
--- /dev/null
+++ b/src/test/ui/parser/issue-76437-async.stderr
@@ -0,0 +1,11 @@
+error: expected one of `extern`, `fn`, or `unsafe`, found keyword `pub`
+  --> $DIR/issue-76437-async.rs:4:11
+   |
+LL |     async pub fn t() {}
+   |     ------^^^
+   |     |     |
+   |     |     expected one of `extern`, `fn`, or `unsafe`
+   |     help: visibility `pub` must come before `async`: `pub async`
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/parser/issue-76437-const-async-unsafe.rs b/src/test/ui/parser/issue-76437-const-async-unsafe.rs
new file mode 100644
index 00000000000..f1e06e4ad89
--- /dev/null
+++ b/src/test/ui/parser/issue-76437-const-async-unsafe.rs
@@ -0,0 +1,7 @@
+// edition:2018
+
+mod t {
+    const async unsafe pub fn t() {}
+    //~^ ERROR expected one of `extern` or `fn`, found keyword `pub`
+    //~| HELP visibility `pub` must come before `const async unsafe`
+}
diff --git a/src/test/ui/parser/issue-76437-const-async-unsafe.stderr b/src/test/ui/parser/issue-76437-const-async-unsafe.stderr
new file mode 100644
index 00000000000..2e91beda116
--- /dev/null
+++ b/src/test/ui/parser/issue-76437-const-async-unsafe.stderr
@@ -0,0 +1,11 @@
+error: expected one of `extern` or `fn`, found keyword `pub`
+  --> $DIR/issue-76437-const-async-unsafe.rs:4:24
+   |
+LL |     const async unsafe pub fn t() {}
+   |     -------------------^^^
+   |     |                  |
+   |     |                  expected one of `extern` or `fn`
+   |     help: visibility `pub` must come before `const async unsafe`: `pub const async unsafe`
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/parser/issue-76437-const-async.rs b/src/test/ui/parser/issue-76437-const-async.rs
new file mode 100644
index 00000000000..3c789fdcd02
--- /dev/null
+++ b/src/test/ui/parser/issue-76437-const-async.rs
@@ -0,0 +1,7 @@
+// edition:2018
+
+mod t {
+    const async pub fn t() {}
+    //~^ ERROR expected one of `extern`, `fn`, or `unsafe`, found keyword `pub`
+    //~| HELP visibility `pub` must come before `const async`
+}
diff --git a/src/test/ui/parser/issue-76437-const-async.stderr b/src/test/ui/parser/issue-76437-const-async.stderr
new file mode 100644
index 00000000000..21b96c14d7d
--- /dev/null
+++ b/src/test/ui/parser/issue-76437-const-async.stderr
@@ -0,0 +1,11 @@
+error: expected one of `extern`, `fn`, or `unsafe`, found keyword `pub`
+  --> $DIR/issue-76437-const-async.rs:4:17
+   |
+LL |     const async pub fn t() {}
+   |     ------------^^^
+   |     |           |
+   |     |           expected one of `extern`, `fn`, or `unsafe`
+   |     help: visibility `pub` must come before `const async`: `pub const async`
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/parser/issue-76437-const.rs b/src/test/ui/parser/issue-76437-const.rs
new file mode 100644
index 00000000000..d3815a52346
--- /dev/null
+++ b/src/test/ui/parser/issue-76437-const.rs
@@ -0,0 +1,7 @@
+// edition:2018
+
+mod t {
+    const pub fn t() {}
+    //~^ ERROR expected one of `async`, `extern`, `fn`, or `unsafe`, found keyword `pub`
+    //~| HELP visibility `pub` must come before `const`
+}
diff --git a/src/test/ui/parser/issue-76437-const.stderr b/src/test/ui/parser/issue-76437-const.stderr
new file mode 100644
index 00000000000..cf80d9a9037
--- /dev/null
+++ b/src/test/ui/parser/issue-76437-const.stderr
@@ -0,0 +1,11 @@
+error: expected one of `async`, `extern`, `fn`, or `unsafe`, found keyword `pub`
+  --> $DIR/issue-76437-const.rs:4:11
+   |
+LL |     const pub fn t() {}
+   |     ------^^^
+   |     |     |
+   |     |     expected one of `async`, `extern`, `fn`, or `unsafe`
+   |     help: visibility `pub` must come before `const`: `pub const`
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/parser/issue-76437-pub-crate-unsafe.rs b/src/test/ui/parser/issue-76437-pub-crate-unsafe.rs
new file mode 100644
index 00000000000..daa1d120795
--- /dev/null
+++ b/src/test/ui/parser/issue-76437-pub-crate-unsafe.rs
@@ -0,0 +1,7 @@
+// edition:2018
+
+mod t {
+    unsafe pub(crate) fn t() {}
+    //~^ ERROR expected one of `extern` or `fn`, found keyword `pub`
+    //~| HELP visibility `pub(crate)` must come before `unsafe`
+}
diff --git a/src/test/ui/parser/issue-76437-pub-crate-unsafe.stderr b/src/test/ui/parser/issue-76437-pub-crate-unsafe.stderr
new file mode 100644
index 00000000000..fa8f13721c8
--- /dev/null
+++ b/src/test/ui/parser/issue-76437-pub-crate-unsafe.stderr
@@ -0,0 +1,11 @@
+error: expected one of `extern` or `fn`, found keyword `pub`
+  --> $DIR/issue-76437-pub-crate-unsafe.rs:4:12
+   |
+LL |     unsafe pub(crate) fn t() {}
+   |     -------^^^-------
+   |     |      |
+   |     |      expected one of `extern` or `fn`
+   |     help: visibility `pub(crate)` must come before `unsafe`: `pub(crate) unsafe`
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/parser/issue-76437-unsafe.rs b/src/test/ui/parser/issue-76437-unsafe.rs
new file mode 100644
index 00000000000..785a79a79a2
--- /dev/null
+++ b/src/test/ui/parser/issue-76437-unsafe.rs
@@ -0,0 +1,7 @@
+// edition:2018
+
+mod t {
+    unsafe pub fn t() {}
+    //~^ ERROR expected one of `extern` or `fn`, found keyword `pub`
+    //~| HELP visibility `pub` must come before `unsafe`
+}
diff --git a/src/test/ui/parser/issue-76437-unsafe.stderr b/src/test/ui/parser/issue-76437-unsafe.stderr
new file mode 100644
index 00000000000..c63292ef853
--- /dev/null
+++ b/src/test/ui/parser/issue-76437-unsafe.stderr
@@ -0,0 +1,11 @@
+error: expected one of `extern` or `fn`, found keyword `pub`
+  --> $DIR/issue-76437-unsafe.rs:4:12
+   |
+LL |     unsafe pub fn t() {}
+   |     -------^^^
+   |     |      |
+   |     |      expected one of `extern` or `fn`
+   |     help: visibility `pub` must come before `unsafe`: `pub unsafe`
+
+error: aborting due to previous error
+