about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2020-02-15 01:50:26 +0100
committerMazdak Farrokhzad <twingoow@gmail.com>2020-02-15 20:57:12 +0100
commitf8d2264463162291f5cb3391c98d7bc95ec17d87 (patch)
tree513c6f3eae554053189a205993fe56db960b6462 /src/test
parent1c2906ead3825c013ac022249f1e1ee3a3b97c75 (diff)
downloadrust-f8d2264463162291f5cb3391c98d7bc95ec17d87.tar.gz
rust-f8d2264463162291f5cb3391c98d7bc95ec17d87.zip
parse associated statics.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/issues/issue-58856-2.stderr4
-rw-r--r--src/test/ui/issues/issue-60075.stderr2
-rw-r--r--src/test/ui/parser/assoc-static-semantic-fail.rs43
-rw-r--r--src/test/ui/parser/assoc-static-semantic-fail.stderr99
-rw-r--r--src/test/ui/parser/assoc-static-syntactic-pass.rs29
-rw-r--r--src/test/ui/parser/issue-32446.stderr4
-rw-r--r--src/test/ui/parser/issue-41155.stderr4
-rw-r--r--src/test/ui/parser/macro/trait-non-item-macros.stderr4
-rw-r--r--src/test/ui/parser/removed-syntax-static-fn.rs4
-rw-r--r--src/test/ui/parser/removed-syntax-static-fn.stderr25
10 files changed, 200 insertions, 18 deletions
diff --git a/src/test/ui/issues/issue-58856-2.stderr b/src/test/ui/issues/issue-58856-2.stderr
index 6221b90b31d..f4ca3c46ea2 100644
--- a/src/test/ui/issues/issue-58856-2.stderr
+++ b/src/test/ui/issues/issue-58856-2.stderr
@@ -7,11 +7,11 @@ LL |     fn how_are_you(&self -> Empty {
    |                   |     help: `)` may belong here
    |                   unclosed delimiter
 
-error: expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, `pub`, `type`, `unsafe`, `}`, or identifier, found `)`
+error: expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, `pub`, `static`, `type`, `unsafe`, `}`, or identifier, found `)`
   --> $DIR/issue-58856-2.rs:11:1
    |
 LL |     }
-   |      - expected one of 11 possible tokens
+   |      - expected one of 12 possible tokens
 LL | }
    | ^ unexpected token
 
diff --git a/src/test/ui/issues/issue-60075.stderr b/src/test/ui/issues/issue-60075.stderr
index b2beb73503b..bab50a53b1a 100644
--- a/src/test/ui/issues/issue-60075.stderr
+++ b/src/test/ui/issues/issue-60075.stderr
@@ -4,7 +4,7 @@ error: expected one of `.`, `;`, `?`, `else`, or an operator, found `}`
 LL |         });
    |          ^ expected one of `.`, `;`, `?`, `else`, or an operator
 
-error: expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, `pub`, `type`, `unsafe`, `}`, or identifier, found `;`
+error: expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, `pub`, `static`, `type`, `unsafe`, `}`, or identifier, found `;`
   --> $DIR/issue-60075.rs:6:11
    |
 LL |     fn qux() -> Option<usize> {
diff --git a/src/test/ui/parser/assoc-static-semantic-fail.rs b/src/test/ui/parser/assoc-static-semantic-fail.rs
new file mode 100644
index 00000000000..cf3debd77cb
--- /dev/null
+++ b/src/test/ui/parser/assoc-static-semantic-fail.rs
@@ -0,0 +1,43 @@
+// Semantically, we do not allow e.g., `static X: u8 = 0;` as an associated item.
+
+#![feature(specialization)]
+
+fn main() {}
+
+struct S;
+impl S {
+    static IA: u8 = 0;
+    //~^ ERROR associated `static` items are not allowed
+    static IB: u8;
+    //~^ ERROR associated `static` items are not allowed
+    default static IC: u8 = 0;
+    //~^ ERROR associated `static` items are not allowed
+    pub(crate) default static ID: u8;
+    //~^ ERROR associated `static` items are not allowed
+}
+
+trait T {
+    static TA: u8 = 0;
+    //~^ ERROR associated `static` items are not allowed
+    static TB: u8;
+    //~^ ERROR associated `static` items are not allowed
+    default static TC: u8 = 0;
+    //~^ ERROR associated `static` items are not allowed
+    //~| ERROR `default` is only allowed on items in
+    pub(crate) default static TD: u8;
+    //~^ ERROR associated `static` items are not allowed
+    //~| ERROR `default` is only allowed on items in
+    //~| ERROR unnecessary visibility qualifier
+}
+
+impl T for S {
+    static TA: u8 = 0;
+    //~^ ERROR associated `static` items are not allowed
+    static TB: u8;
+    //~^ ERROR associated `static` items are not allowed
+    default static TC: u8 = 0;
+    //~^ ERROR associated `static` items are not allowed
+    pub default static TD: u8;
+    //~^ ERROR associated `static` items are not allowed
+    //~| ERROR unnecessary visibility qualifier
+}
diff --git a/src/test/ui/parser/assoc-static-semantic-fail.stderr b/src/test/ui/parser/assoc-static-semantic-fail.stderr
new file mode 100644
index 00000000000..d5a02c9bebc
--- /dev/null
+++ b/src/test/ui/parser/assoc-static-semantic-fail.stderr
@@ -0,0 +1,99 @@
+error: associated `static` items are not allowed
+  --> $DIR/assoc-static-semantic-fail.rs:9:5
+   |
+LL |     static IA: u8 = 0;
+   |     ^^^^^^^^^^^^^^^^^^
+
+error: associated `static` items are not allowed
+  --> $DIR/assoc-static-semantic-fail.rs:11:5
+   |
+LL |     static IB: u8;
+   |     ^^^^^^^^^^^^^^
+
+error: associated `static` items are not allowed
+  --> $DIR/assoc-static-semantic-fail.rs:13:5
+   |
+LL |     default static IC: u8 = 0;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: associated `static` items are not allowed
+  --> $DIR/assoc-static-semantic-fail.rs:15:5
+   |
+LL |     pub(crate) default static ID: u8;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: associated `static` items are not allowed
+  --> $DIR/assoc-static-semantic-fail.rs:20:5
+   |
+LL |     static TA: u8 = 0;
+   |     ^^^^^^^^^^^^^^^^^^
+
+error: associated `static` items are not allowed
+  --> $DIR/assoc-static-semantic-fail.rs:22:5
+   |
+LL |     static TB: u8;
+   |     ^^^^^^^^^^^^^^
+
+error: `default` is only allowed on items in `impl` definitions
+  --> $DIR/assoc-static-semantic-fail.rs:24:5
+   |
+LL |     default static TC: u8 = 0;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: associated `static` items are not allowed
+  --> $DIR/assoc-static-semantic-fail.rs:24:5
+   |
+LL |     default static TC: u8 = 0;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: `default` is only allowed on items in `impl` definitions
+  --> $DIR/assoc-static-semantic-fail.rs:27:5
+   |
+LL |     pub(crate) default static TD: u8;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0449]: unnecessary visibility qualifier
+  --> $DIR/assoc-static-semantic-fail.rs:27:5
+   |
+LL |     pub(crate) default static TD: u8;
+   |     ^^^^^^^^^^
+
+error: associated `static` items are not allowed
+  --> $DIR/assoc-static-semantic-fail.rs:27:5
+   |
+LL |     pub(crate) default static TD: u8;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: associated `static` items are not allowed
+  --> $DIR/assoc-static-semantic-fail.rs:34:5
+   |
+LL |     static TA: u8 = 0;
+   |     ^^^^^^^^^^^^^^^^^^
+
+error: associated `static` items are not allowed
+  --> $DIR/assoc-static-semantic-fail.rs:36:5
+   |
+LL |     static TB: u8;
+   |     ^^^^^^^^^^^^^^
+
+error: associated `static` items are not allowed
+  --> $DIR/assoc-static-semantic-fail.rs:38:5
+   |
+LL |     default static TC: u8 = 0;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0449]: unnecessary visibility qualifier
+  --> $DIR/assoc-static-semantic-fail.rs:40:5
+   |
+LL |     pub default static TD: u8;
+   |     ^^^ `pub` not permitted here because it's implied
+
+error: associated `static` items are not allowed
+  --> $DIR/assoc-static-semantic-fail.rs:40:5
+   |
+LL |     pub default static TD: u8;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 16 previous errors
+
+For more information about this error, try `rustc --explain E0449`.
diff --git a/src/test/ui/parser/assoc-static-syntactic-pass.rs b/src/test/ui/parser/assoc-static-syntactic-pass.rs
new file mode 100644
index 00000000000..7f5b9f79335
--- /dev/null
+++ b/src/test/ui/parser/assoc-static-syntactic-pass.rs
@@ -0,0 +1,29 @@
+// Syntactically, we do allow e.g., `static X: u8 = 0;` as an associated item.
+
+// check-pass
+
+fn main() {}
+
+#[cfg(FALSE)]
+impl S {
+    static IA: u8 = 0;
+    static IB: u8;
+    default static IC: u8 = 0;
+    pub(crate) default static ID: u8;
+}
+
+#[cfg(FALSE)]
+trait T {
+    static TA: u8 = 0;
+    static TB: u8;
+    default static TC: u8 = 0;
+    pub(crate) default static TD: u8;
+}
+
+#[cfg(FALSE)]
+impl T for S {
+    static TA: u8 = 0;
+    static TB: u8;
+    default static TC: u8 = 0;
+    pub default static TD: u8;
+}
diff --git a/src/test/ui/parser/issue-32446.stderr b/src/test/ui/parser/issue-32446.stderr
index 25c1efe35ae..d25828da0b9 100644
--- a/src/test/ui/parser/issue-32446.stderr
+++ b/src/test/ui/parser/issue-32446.stderr
@@ -1,8 +1,8 @@
-error: expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, `pub`, `type`, `unsafe`, `}`, or identifier, found `...`
+error: expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, `pub`, `static`, `type`, `unsafe`, `}`, or identifier, found `...`
   --> $DIR/issue-32446.rs:4:11
    |
 LL | trait T { ... }
-   |           ^^^ expected one of 11 possible tokens
+   |           ^^^ expected one of 12 possible tokens
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/parser/issue-41155.stderr b/src/test/ui/parser/issue-41155.stderr
index 327bc65818f..a91ef6c67e8 100644
--- a/src/test/ui/parser/issue-41155.stderr
+++ b/src/test/ui/parser/issue-41155.stderr
@@ -1,8 +1,8 @@
-error: expected one of `(`, `async`, `const`, `default`, `extern`, `fn`, `type`, `unsafe`, or identifier, found `}`
+error: expected one of `(`, `async`, `const`, `default`, `extern`, `fn`, `static`, `type`, `unsafe`, or identifier, found `}`
   --> $DIR/issue-41155.rs:5:1
    |
 LL |     pub
-   |        - expected one of 9 possible tokens
+   |        - expected one of 10 possible tokens
 LL | }
    | ^ unexpected token
 
diff --git a/src/test/ui/parser/macro/trait-non-item-macros.stderr b/src/test/ui/parser/macro/trait-non-item-macros.stderr
index 9d05e85bcc0..c76b096a1eb 100644
--- a/src/test/ui/parser/macro/trait-non-item-macros.stderr
+++ b/src/test/ui/parser/macro/trait-non-item-macros.stderr
@@ -1,8 +1,8 @@
-error: expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, `pub`, `type`, `unsafe`, or identifier, found `2`
+error: expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, `pub`, `static`, `type`, `unsafe`, or identifier, found `2`
   --> $DIR/trait-non-item-macros.rs:2:19
    |
 LL |     ($a:expr) => ($a)
-   |                   ^^ expected one of 10 possible tokens
+   |                   ^^ expected one of 11 possible tokens
 ...
 LL |     bah!(2);
    |     -------- in this macro invocation
diff --git a/src/test/ui/parser/removed-syntax-static-fn.rs b/src/test/ui/parser/removed-syntax-static-fn.rs
index 9e12222f3fd..cd643b874db 100644
--- a/src/test/ui/parser/removed-syntax-static-fn.rs
+++ b/src/test/ui/parser/removed-syntax-static-fn.rs
@@ -1,8 +1,10 @@
 struct S;
 
 impl S {
-    //~^ ERROR missing `fn`, `type`, or `const` for associated-item declaration
     static fn f() {}
+    //~^ ERROR expected identifier, found keyword `fn`
+    //~| ERROR expected one of `:`, `;`, or `=`
+    //~| ERROR missing type for `static` item
 }
 
 fn main() {}
diff --git a/src/test/ui/parser/removed-syntax-static-fn.stderr b/src/test/ui/parser/removed-syntax-static-fn.stderr
index 5edf88026fb..dc5625bdade 100644
--- a/src/test/ui/parser/removed-syntax-static-fn.stderr
+++ b/src/test/ui/parser/removed-syntax-static-fn.stderr
@@ -1,11 +1,20 @@
-error: missing `fn`, `type`, or `const` for associated-item declaration
-  --> $DIR/removed-syntax-static-fn.rs:3:9
+error: expected identifier, found keyword `fn`
+  --> $DIR/removed-syntax-static-fn.rs:4:12
    |
-LL |   impl S {
-   |  _________^
-LL | |
-LL | |     static fn f() {}
-   | |____^ missing `fn`, `type`, or `const`
+LL |     static fn f() {}
+   |            ^^ expected identifier, found keyword
 
-error: aborting due to previous error
+error: expected one of `:`, `;`, or `=`, found `f`
+  --> $DIR/removed-syntax-static-fn.rs:4:15
+   |
+LL |     static fn f() {}
+   |               ^ expected one of `:`, `;`, or `=`
+
+error: missing type for `static` item
+  --> $DIR/removed-syntax-static-fn.rs:4:12
+   |
+LL |     static fn f() {}
+   |            ^^ help: provide a type for the item: `r#fn: <type>`
+
+error: aborting due to 3 previous errors