about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2019-02-25 22:40:44 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2019-02-25 23:21:54 +0300
commiteccc19996b1e6a38568544e0be3cfe971caa12eb (patch)
tree0a710c34f66ab112c523d37f9b4f1fbf3d0710fa
parent8e1b5d897a277e9e25685e9acac7333b9a0f8bf4 (diff)
downloadrust-eccc19996b1e6a38568544e0be3cfe971caa12eb.tar.gz
rust-eccc19996b1e6a38568544e0be3cfe971caa12eb.zip
Stabilize `unrestricted_attribute_tokens`
-rw-r--r--src/libcore/lib.rs1
-rw-r--r--src/libsyntax/feature_gate.rs18
-rw-r--r--src/test/run-pass/proc-macro/derive-b.rs2
-rw-r--r--src/test/ui/attr-eq-token-tree.rs2
-rw-r--r--src/test/ui/feature-gates/feature-gate-unrestricted-attribute-tokens.rs7
-rw-r--r--src/test/ui/feature-gates/feature-gate-unrestricted-attribute-tokens.stderr20
-rw-r--r--src/test/ui/macros/macro-attribute.rs2
-rw-r--r--src/test/ui/macros/macro-attribute.stderr2
-rw-r--r--src/test/ui/malformed/malformed-interpolated.stderr4
-rw-r--r--src/test/ui/marker_trait_attr/marker-attribute-with-values.rs5
-rw-r--r--src/test/ui/marker_trait_attr/marker-attribute-with-values.stderr12
-rw-r--r--src/test/ui/parser/attr-bad-meta.rs2
-rw-r--r--src/test/ui/parser/attr-bad-meta.stderr2
-rw-r--r--src/test/ui/proc-macro/proc-macro-attributes.rs1
-rw-r--r--src/test/ui/proc-macro/proc-macro-attributes.stderr16
-rw-r--r--src/test/ui/unrestricted-attribute-tokens.rs4
16 files changed, 26 insertions, 74 deletions
diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs
index f2165c676fd..63688e70c45 100644
--- a/src/libcore/lib.rs
+++ b/src/libcore/lib.rs
@@ -123,7 +123,6 @@
 #![feature(abi_unadjusted)]
 #![feature(adx_target_feature)]
 #![feature(maybe_uninit, maybe_uninit_slice, maybe_uninit_array)]
-#![feature(unrestricted_attribute_tokens)]
 #![feature(external_doc)]
 
 #[prelude_import]
diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs
index c9b441193b7..cc1953e69d4 100644
--- a/src/libsyntax/feature_gate.rs
+++ b/src/libsyntax/feature_gate.rs
@@ -21,8 +21,9 @@ use crate::early_buffered_lints::BufferedEarlyLintId;
 use crate::source_map::Spanned;
 use crate::edition::{ALL_EDITIONS, Edition};
 use crate::visit::{self, FnKind, Visitor};
-use crate::parse::ParseSess;
+use crate::parse::{token, ParseSess};
 use crate::symbol::Symbol;
+use crate::tokenstream::TokenTree;
 
 use errors::{DiagnosticBuilder, Handler};
 use rustc_data_structures::fx::FxHashMap;
@@ -431,9 +432,6 @@ declare_features! (
     // Added for testing E0705; perma-unstable.
     (active, test_2018_feature, "1.31.0", Some(0), Some(Edition::Edition2018)),
 
-    // support for arbitrary delimited token streams in non-macro attributes
-    (active, unrestricted_attribute_tokens, "1.30.0", Some(55208), None),
-
     // Allows unsized rvalues at arguments and parameters.
     (active, unsized_locals, "1.30.0", Some(48055), None),
 
@@ -700,6 +698,8 @@ declare_features! (
     (accepted, cfg_target_vendor, "1.33.0", Some(29718), None),
     // `extern crate self as foo;` puts local crate root into extern prelude under name `foo`.
     (accepted, extern_crate_self, "1.34.0", Some(56409), None),
+    // support for arbitrary delimited token streams in non-macro attributes
+    (accepted, unrestricted_attribute_tokens, "1.34.0", Some(55208), None),
 );
 
 // If you change this, please modify `src/doc/unstable-book` as well. You must
@@ -1660,13 +1660,9 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
 
         match BUILTIN_ATTRIBUTES.iter().find(|(name, ..)| attr.path == name) {
             Some(&(name, _, template, _)) => self.check_builtin_attribute(attr, name, template),
-            None => if !self.context.features.unrestricted_attribute_tokens {
-                // Unfortunately, `parse_meta` cannot be called speculatively
-                // because it can report errors by itself, so we have to call it
-                // only if the feature is disabled.
-                if let Err(mut err) = attr.parse_meta(self.context.parse_sess) {
-                    err.help("try enabling `#![feature(unrestricted_attribute_tokens)]`").emit()
-                }
+            None => if let Some(TokenTree::Token(_, token::Eq)) = attr.tokens.trees().next() {
+                // All key-value attributes are restricted to meta-item syntax.
+                attr.parse_meta(self.context.parse_sess).map_err(|mut err| err.emit()).ok();
             }
         }
     }
diff --git a/src/test/run-pass/proc-macro/derive-b.rs b/src/test/run-pass/proc-macro/derive-b.rs
index af48cabca99..da67534364b 100644
--- a/src/test/run-pass/proc-macro/derive-b.rs
+++ b/src/test/run-pass/proc-macro/derive-b.rs
@@ -1,7 +1,5 @@
 // aux-build:derive-b.rs
 
-#![feature(unrestricted_attribute_tokens)]
-
 extern crate derive_b;
 
 #[derive(Debug, PartialEq, derive_b::B, Eq, Copy, Clone)]
diff --git a/src/test/ui/attr-eq-token-tree.rs b/src/test/ui/attr-eq-token-tree.rs
index b8dfafc446e..6aacb9d572a 100644
--- a/src/test/ui/attr-eq-token-tree.rs
+++ b/src/test/ui/attr-eq-token-tree.rs
@@ -1,4 +1,4 @@
-#![feature(custom_attribute, unrestricted_attribute_tokens)]
+#![feature(custom_attribute)]
 
 #[my_attr = !] //~ ERROR unexpected token: `!`
 fn main() {}
diff --git a/src/test/ui/feature-gates/feature-gate-unrestricted-attribute-tokens.rs b/src/test/ui/feature-gates/feature-gate-unrestricted-attribute-tokens.rs
deleted file mode 100644
index 181c8592c54..00000000000
--- a/src/test/ui/feature-gates/feature-gate-unrestricted-attribute-tokens.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-#![feature(custom_attribute)]
-
-#[my_attr(a b c d)]
-//~^ ERROR expected one of `(`, `)`, `,`, `::`, or `=`, found `b`
-//~| ERROR expected one of `(`, `)`, `,`, `::`, or `=`, found `c`
-//~| ERROR expected one of `(`, `)`, `,`, `::`, or `=`, found `d`
-fn main() {}
diff --git a/src/test/ui/feature-gates/feature-gate-unrestricted-attribute-tokens.stderr b/src/test/ui/feature-gates/feature-gate-unrestricted-attribute-tokens.stderr
deleted file mode 100644
index 1ddf2ff6d64..00000000000
--- a/src/test/ui/feature-gates/feature-gate-unrestricted-attribute-tokens.stderr
+++ /dev/null
@@ -1,20 +0,0 @@
-error: expected one of `(`, `)`, `,`, `::`, or `=`, found `b`
-  --> $DIR/feature-gate-unrestricted-attribute-tokens.rs:3:13
-   |
-LL | #[my_attr(a b c d)]
-   |             ^ expected one of `(`, `)`, `,`, `::`, or `=` here
-
-error: expected one of `(`, `)`, `,`, `::`, or `=`, found `c`
-  --> $DIR/feature-gate-unrestricted-attribute-tokens.rs:3:15
-   |
-LL | #[my_attr(a b c d)]
-   |               ^ expected one of `(`, `)`, `,`, `::`, or `=` here
-
-error: expected one of `(`, `)`, `,`, `::`, or `=`, found `d`
-  --> $DIR/feature-gate-unrestricted-attribute-tokens.rs:3:17
-   |
-LL | #[my_attr(a b c d)]
-   |                 ^ expected one of `(`, `)`, `,`, `::`, or `=` here
-
-error: aborting due to 3 previous errors
-
diff --git a/src/test/ui/macros/macro-attribute.rs b/src/test/ui/macros/macro-attribute.rs
index 332246fd1cf..f580dfa8e34 100644
--- a/src/test/ui/macros/macro-attribute.rs
+++ b/src/test/ui/macros/macro-attribute.rs
@@ -1,4 +1,2 @@
-#![feature(unrestricted_attribute_tokens)]
-
 #[doc = $not_there] //~ ERROR unexpected token: `$`
 fn main() { }
diff --git a/src/test/ui/macros/macro-attribute.stderr b/src/test/ui/macros/macro-attribute.stderr
index 55f8e09b7e3..7314e483348 100644
--- a/src/test/ui/macros/macro-attribute.stderr
+++ b/src/test/ui/macros/macro-attribute.stderr
@@ -1,5 +1,5 @@
 error: unexpected token: `$`
-  --> $DIR/macro-attribute.rs:3:7
+  --> $DIR/macro-attribute.rs:1:7
    |
 LL | #[doc = $not_there] //~ ERROR unexpected token: `$`
    |       ^
diff --git a/src/test/ui/malformed/malformed-interpolated.stderr b/src/test/ui/malformed/malformed-interpolated.stderr
index f9c89316fcd..24aa590c4d9 100644
--- a/src/test/ui/malformed/malformed-interpolated.stderr
+++ b/src/test/ui/malformed/malformed-interpolated.stderr
@@ -17,8 +17,6 @@ LL |         #[my_attr = $expr] //~ ERROR suffixed literals are not allowed in a
 ...
 LL | check!(-0); // ERROR, see above
    | ----------- in this macro invocation
-   |
-   = help: try enabling `#![feature(unrestricted_attribute_tokens)]`
 
 error: unexpected token: `0 + 0`
   --> $DIR/malformed-interpolated.rs:5:19
@@ -28,8 +26,6 @@ LL |         #[my_attr = $expr] //~ ERROR suffixed literals are not allowed in a
 ...
 LL | check!(0 + 0); // ERROR, see above
    | -------------- in this macro invocation
-   |
-   = help: try enabling `#![feature(unrestricted_attribute_tokens)]`
 
 error: aborting due to 3 previous errors
 
diff --git a/src/test/ui/marker_trait_attr/marker-attribute-with-values.rs b/src/test/ui/marker_trait_attr/marker-attribute-with-values.rs
index ea356d574f6..f8bcec78650 100644
--- a/src/test/ui/marker_trait_attr/marker-attribute-with-values.rs
+++ b/src/test/ui/marker_trait_attr/marker-attribute-with-values.rs
@@ -1,5 +1,4 @@
 #![feature(marker_trait_attr)]
-#![feature(unrestricted_attribute_tokens)]
 
 #[marker(always)]
 trait Marker1 {}
@@ -9,8 +8,8 @@ trait Marker1 {}
 trait Marker2 {}
 //~^^ ERROR attribute must be of the form
 
-#[marker(key = value)]
+#[marker(key = "value")]
 trait Marker3 {}
-//~^^ ERROR expected unsuffixed literal or identifier, found value
+//~^^ ERROR attribute must be of the form `#[marker]`
 
 fn main() {}
diff --git a/src/test/ui/marker_trait_attr/marker-attribute-with-values.stderr b/src/test/ui/marker_trait_attr/marker-attribute-with-values.stderr
index c683b393d84..2b31dcb4760 100644
--- a/src/test/ui/marker_trait_attr/marker-attribute-with-values.stderr
+++ b/src/test/ui/marker_trait_attr/marker-attribute-with-values.stderr
@@ -1,20 +1,20 @@
 error: attribute must be of the form `#[marker]`
-  --> $DIR/marker-attribute-with-values.rs:4:1
+  --> $DIR/marker-attribute-with-values.rs:3:1
    |
 LL | #[marker(always)]
    | ^^^^^^^^^^^^^^^^^
 
 error: attribute must be of the form `#[marker]`
-  --> $DIR/marker-attribute-with-values.rs:8:1
+  --> $DIR/marker-attribute-with-values.rs:7:1
    |
 LL | #[marker("never")]
    | ^^^^^^^^^^^^^^^^^^
 
-error: expected unsuffixed literal or identifier, found value
-  --> $DIR/marker-attribute-with-values.rs:12:10
+error: attribute must be of the form `#[marker]`
+  --> $DIR/marker-attribute-with-values.rs:11:1
    |
-LL | #[marker(key = value)]
-   |          ^^^
+LL | #[marker(key = "value")]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to 3 previous errors
 
diff --git a/src/test/ui/parser/attr-bad-meta.rs b/src/test/ui/parser/attr-bad-meta.rs
index 7fe54272491..8001977f5a3 100644
--- a/src/test/ui/parser/attr-bad-meta.rs
+++ b/src/test/ui/parser/attr-bad-meta.rs
@@ -1,4 +1,2 @@
-#![feature(unrestricted_attribute_tokens)]
-
 #[path*] //~ ERROR expected one of `(`, `::`, `=`, `[`, `]`, or `{`, found `*`
 mod m {}
diff --git a/src/test/ui/parser/attr-bad-meta.stderr b/src/test/ui/parser/attr-bad-meta.stderr
index 7351702ec9d..693da95017d 100644
--- a/src/test/ui/parser/attr-bad-meta.stderr
+++ b/src/test/ui/parser/attr-bad-meta.stderr
@@ -1,5 +1,5 @@
 error: expected one of `(`, `::`, `=`, `[`, `]`, or `{`, found `*`
-  --> $DIR/attr-bad-meta.rs:3:7
+  --> $DIR/attr-bad-meta.rs:1:7
    |
 LL | #[path*] //~ ERROR expected one of `(`, `::`, `=`, `[`, `]`, or `{`, found `*`
    |       ^ expected one of `(`, `::`, `=`, `[`, `]`, or `{` here
diff --git a/src/test/ui/proc-macro/proc-macro-attributes.rs b/src/test/ui/proc-macro/proc-macro-attributes.rs
index 1cc824e943c..062053453ee 100644
--- a/src/test/ui/proc-macro/proc-macro-attributes.rs
+++ b/src/test/ui/proc-macro/proc-macro-attributes.rs
@@ -8,7 +8,6 @@ extern crate derive_b;
 #[B(D)] //~ ERROR `B` is ambiguous
 #[B(E = "foo")] //~ ERROR `B` is ambiguous
 #[B(arbitrary tokens)] //~ ERROR `B` is ambiguous
-                       //~^ ERROR expected one of `(`, `)`, `,`, `::`, or `=`, found `tokens`
 #[derive(B)]
 struct B;
 
diff --git a/src/test/ui/proc-macro/proc-macro-attributes.stderr b/src/test/ui/proc-macro/proc-macro-attributes.stderr
index 7ac44c9354d..a5ec787ac67 100644
--- a/src/test/ui/proc-macro/proc-macro-attributes.stderr
+++ b/src/test/ui/proc-macro/proc-macro-attributes.stderr
@@ -13,7 +13,7 @@ LL | #[B] //~ ERROR `B` is ambiguous
    |   ^ ambiguous name
    |
 note: `B` could refer to the derive helper attribute defined here
-  --> $DIR/proc-macro-attributes.rs:12:10
+  --> $DIR/proc-macro-attributes.rs:11:10
    |
 LL | #[derive(B)]
    |          ^
@@ -30,7 +30,7 @@ LL | #[B(D)] //~ ERROR `B` is ambiguous
    |   ^ ambiguous name
    |
 note: `B` could refer to the derive helper attribute defined here
-  --> $DIR/proc-macro-attributes.rs:12:10
+  --> $DIR/proc-macro-attributes.rs:11:10
    |
 LL | #[derive(B)]
    |          ^
@@ -47,7 +47,7 @@ LL | #[B(E = "foo")] //~ ERROR `B` is ambiguous
    |   ^ ambiguous name
    |
 note: `B` could refer to the derive helper attribute defined here
-  --> $DIR/proc-macro-attributes.rs:12:10
+  --> $DIR/proc-macro-attributes.rs:11:10
    |
 LL | #[derive(B)]
    |          ^
@@ -64,7 +64,7 @@ LL | #[B(arbitrary tokens)] //~ ERROR `B` is ambiguous
    |   ^ ambiguous name
    |
 note: `B` could refer to the derive helper attribute defined here
-  --> $DIR/proc-macro-attributes.rs:12:10
+  --> $DIR/proc-macro-attributes.rs:11:10
    |
 LL | #[derive(B)]
    |          ^
@@ -74,13 +74,7 @@ note: `B` could also refer to the derive macro imported here
 LL | #[macro_use]
    | ^^^^^^^^^^^^
 
-error: expected one of `(`, `)`, `,`, `::`, or `=`, found `tokens`
-  --> $DIR/proc-macro-attributes.rs:10:15
-   |
-LL | #[B(arbitrary tokens)] //~ ERROR `B` is ambiguous
-   |               ^^^^^^ expected one of `(`, `)`, `,`, `::`, or `=` here
-
-error: aborting due to 6 previous errors
+error: aborting due to 5 previous errors
 
 Some errors occurred: E0658, E0659.
 For more information about an error, try `rustc --explain E0658`.
diff --git a/src/test/ui/unrestricted-attribute-tokens.rs b/src/test/ui/unrestricted-attribute-tokens.rs
index 9d8ba03eca5..4798f7b396c 100644
--- a/src/test/ui/unrestricted-attribute-tokens.rs
+++ b/src/test/ui/unrestricted-attribute-tokens.rs
@@ -1,6 +1,8 @@
 // compile-pass
 
-#![feature(custom_attribute, unrestricted_attribute_tokens)]
+#![feature(custom_attribute)]
 
 #[my_attr(a b c d)]
+#[my_attr[a b c d]]
+#[my_attr{a b c d}]
 fn main() {}