]> git.lizzy.rs Git - rust.git/commitdiff
rustc: feature-gate `concat_idents!`.
authorHuon Wilson <dbau.pp+github@gmail.com>
Thu, 3 Apr 2014 23:24:21 +0000 (10:24 +1100)
committerHuon Wilson <dbau.pp+github@gmail.com>
Fri, 4 Apr 2014 09:25:50 +0000 (20:25 +1100)
concat_idents! is not as useful as it could be, due to macros only being
allowed in limited places, and hygiene, so lets feature gate it until we
make a decision about it.

cc #13294

src/librustc/front/feature_gate.rs
src/libstd/lib.rs
src/test/compile-fail/gated-concat_idents.rs [new file with mode: 0644]
src/test/compile-fail/macros-nonfatal-errors.rs
src/test/compile-fail/syntax-extension-minor.rs

index 22de214cc12ca2c5bb9d928de509ab7dfe77f363..5c0b9c8956519b0a24eb16cb25531e645935ee31 100644 (file)
@@ -49,6 +49,8 @@
     ("macro_registrar", Active),
     ("log_syntax", Active),
     ("trace_macros", Active),
+    ("concat_idents", Active),
+
     ("simd", Active),
     ("default_type_params", Active),
     ("quote", Active),
@@ -229,6 +231,11 @@ fn visit_mac(&mut self, macro: &ast::Mac, _: ()) {
                 stable enough for use and is subject to change");
         }
 
+        else if id == token::str_to_ident("concat_idents") {
+            self.gate_feature("concat_idents", path.span, "`concat_idents` is not \
+                stable enough for use and is subject to change");
+        }
+
         else {
             for &quote in quotes.iter() {
                 if id == token::str_to_ident(quote) {
index 75d6b83803f9fda994bacb8c7e0cdb4c0b009a90..b1cf4cf7d566b708d894f2fd58193214eb88128b 100644 (file)
@@ -52,7 +52,7 @@
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
        html_root_url = "http://static.rust-lang.org/doc/master")]
 #![feature(macro_rules, globs, asm, managed_boxes, thread_local, link_args,
-           simd, linkage, default_type_params, phase)]
+           simd, linkage, default_type_params, phase, concat_idents)]
 
 // Don't link to std. We are std.
 #![no_std]
@@ -60,6 +60,7 @@
 // #![deny(missing_doc)] // NOTE: uncomment after a stage0 snap
 #![allow(missing_doc)] // NOTE: remove after a stage0 snap
 #![allow(visible_private_types)] // NOTE: remove after a stage0 snap
+#![allow(unknown_features)] // NOTE: remove after a stage0 snap
 
 // When testing libstd, bring in libuv as the I/O backend so tests can print
 // things and all of the std::io tests have an I/O interface to run on top
diff --git a/src/test/compile-fail/gated-concat_idents.rs b/src/test/compile-fail/gated-concat_idents.rs
new file mode 100644 (file)
index 0000000..054e70f
--- /dev/null
@@ -0,0 +1,13 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn main() {
+    concat_idents!(a, b); //~ ERROR `concat_idents` is not stable enough
+}
index 4cfa5b8926c2d35e1576ae89503963f4dd998203..df2c40657c814bd84108f4d7b60943a1d831ce89 100644 (file)
@@ -12,7 +12,7 @@
 // immediately, so that we get more errors listed at a time.
 
 #![feature(asm)]
-#![feature(trace_macros)]
+#![feature(trace_macros, concat_idents)]
 
 #[deriving(Default, //~ ERROR
            Rand, //~ ERROR
index e65b1c0bf3afa61b7ebf6462f852f54f0bdcc85b..2dc24753b0aec3141b085f6f00cdf310d13a9638 100644 (file)
@@ -10,6 +10,7 @@
 
 // this now fails (correctly, I claim) because hygiene prevents
 // the assembled identifier from being a reference to the binding.
+#![feature(concat_idents)]
 
 pub fn main() {
     let asdf_fdsa = ~"<.<";