]> git.lizzy.rs Git - rust.git/commitdiff
Ease the transition to requiring features by just warning if there's no feature list
authorOliver Scherer <github35764891676564198441@oli-obk.de>
Sun, 3 Feb 2019 12:57:03 +0000 (13:57 +0100)
committerOliver Scherer <github35764891676564198441@oli-obk.de>
Mon, 11 Feb 2019 14:08:17 +0000 (15:08 +0100)
while we could make this change (it's all unstable after all), there are crates.io crates that use the feature and that the compiler depends upon. We can instead roll out this feature while still supporting the old way.

src/libsyntax/ext/tt/macro_rules.rs
src/libsyntax/feature_gate.rs
src/libsyntax_pos/lib.rs

index 4409bf13b6c7b1be3bd460ef4f520072834e4a9c..a79f3271fcb180da46f69e3080ce77c834005e70 100644 (file)
@@ -379,14 +379,20 @@ pub fn compile(
         let allow_internal_unstable = attr::find_by_name(&def.attrs, "allow_internal_unstable")
             .map_or(Vec::new(), |attr| attr
                 .meta_item_list()
-                .unwrap_or_else(|| sess.span_diagnostic.span_bug(
-                    attr.span, "allow_internal_unstable expects list of feature names",
-                ))
-                .iter()
-                .map(|it| it.name().unwrap_or_else(|| sess.span_diagnostic.span_bug(
-                    it.span, "allow internal unstable expects feature names",
-                )))
-                .collect()
+                .map(|list| list.iter()
+                    .map(|it| it.name().unwrap_or_else(|| sess.span_diagnostic.span_bug(
+                        it.span, "allow internal unstable expects feature names",
+                    )))
+                    .collect()
+                )
+                .unwrap_or_else(|| {
+                    sess.span_diagnostic.span_warn(
+                        attr.span, "allow_internal_unstable expects list of feature names. In the \
+                        future this will become a hard error. Please use `allow_internal_unstable(\
+                        foo, bar)` to only allow the `foo` and `bar` features",
+                    );
+                    vec![Symbol::intern("allow_internal_unstable_backcompat_hack")]
+                })
             );
         let allow_internal_unsafe = attr::contains_name(&def.attrs, "allow_internal_unsafe");
         let mut local_inner_macros = false;
index 1e1b315824f1eb26bba725547d035994b69cace0..08f1473200c1eedcb32631a0c48224f641d00382 100644 (file)
@@ -1091,7 +1091,8 @@ pub fn is_builtin_attr(attr: &ast::Attribute) -> bool {
                                               stable",
                                              cfg_fn!(profiler_runtime))),
 
-    ("allow_internal_unstable", Normal, template!(List: "feat1, feat2"), Gated(Stability::Unstable,
+    ("allow_internal_unstable", Normal, template!(Word, List: "feat1, feat2"),
+                                              Gated(Stability::Unstable,
                                               "allow_internal_unstable",
                                               EXPLAIN_ALLOW_INTERNAL_UNSTABLE,
                                               cfg_fn!(allow_internal_unstable))),
index efb21e06f34cc8edcf57d9d4bf98777eea737481..87c4d02fa4f3aa797787c873b41a1f456f66a0e9 100644 (file)
@@ -387,7 +387,10 @@ fn source_callee(info: ExpnInfo) -> ExpnInfo {
     /// `#[allow_internal_unstable]`).
     pub fn allows_unstable(&self, feature: &str) -> bool {
         match self.ctxt().outer().expn_info() {
-            Some(info) => info.allow_internal_unstable.iter().any(|&f| f == feature),
+            Some(info) => info
+                .allow_internal_unstable
+                .iter()
+                .any(|&f| f == feature || f == "allow_internal_unstable_backcompat_hack"),
             None => false,
         }
     }