about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/attr.rs57
-rw-r--r--src/libsyntax/config.rs16
-rw-r--r--src/libsyntax/ext/cfg.rs28
-rw-r--r--src/libsyntax/test.rs20
4 files changed, 22 insertions, 99 deletions
diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs
index 1491f02b3f5..148d986399d 100644
--- a/src/libsyntax/attr.rs
+++ b/src/libsyntax/attr.rs
@@ -316,11 +316,10 @@ pub fn cfg_matches(diagnostic: &SpanHandler, cfgs: &[P<MetaItem>], cfg: &ast::Me
             mis.iter().all(|mi| cfg_matches(diagnostic, cfgs, &**mi)),
         ast::MetaList(ref pred, ref mis) if pred.get() == "not" => {
             if mis.len() != 1 {
-                diagnostic.span_warn(cfg.span, "the use of multiple cfgs in the same `not` \
-                                                statement is deprecated. Change `not(a, b)` to \
-                                                `not(all(a, b))`.");
+                diagnostic.span_err(cfg.span, "expected 1 cfg-pattern");
+                return false;
             }
-            !mis.iter().all(|mi| cfg_matches(diagnostic, cfgs, &**mi))
+            !cfg_matches(diagnostic, cfgs, &*mis[0])
         }
         ast::MetaList(ref pred, _) => {
             diagnostic.span_err(cfg.span, format!("invalid predicate `{}`", pred).as_slice());
@@ -330,56 +329,6 @@ pub fn cfg_matches(diagnostic: &SpanHandler, cfgs: &[P<MetaItem>], cfg: &ast::Me
     }
 }
 
-/// Tests if any `cfg(...)` meta items in `metas` match `cfg`. e.g.
-///
-/// test_cfg(`[foo="a", bar]`, `[cfg(foo), cfg(bar)]`) == true
-/// test_cfg(`[foo="a", bar]`, `[cfg(not(bar))]`) == false
-/// test_cfg(`[foo="a", bar]`, `[cfg(bar, foo="a")]`) == true
-/// test_cfg(`[foo="a", bar]`, `[cfg(bar, foo="b")]`) == false
-pub fn test_cfg<'a, AM: AttrMetaMethods, It: Iterator<&'a AM>>
-    (cfg: &[P<MetaItem>], mut metas: It) -> bool {
-    // having no #[cfg(...)] attributes counts as matching.
-    let mut no_cfgs = true;
-
-    // this would be much nicer as a chain of iterator adaptors, but
-    // this doesn't work.
-    let some_cfg_matches = metas.fold(false, |matches, mi| {
-        debug!("testing name: {}", mi.name());
-        let this_matches = if mi.check_name("cfg") { // it is a #[cfg()] attribute
-            debug!("is cfg");
-            no_cfgs = false;
-             // only #[cfg(...)] ones are understood.
-            match mi.meta_item_list() {
-                Some(cfg_meta) => {
-                    debug!("is cfg(...)");
-                    cfg_meta.iter().all(|cfg_mi| {
-                        debug!("cfg({}[...])", cfg_mi.name());
-                        match cfg_mi.node {
-                            ast::MetaList(ref s, ref not_cfgs)
-                            if s.equiv(&("not")) => {
-                                debug!("not!");
-                                // inside #[cfg(not(...))], so these need to all
-                                // not match.
-                                !not_cfgs.iter().all(|mi| {
-                                    debug!("cfg(not({}[...]))", mi.name());
-                                    contains(cfg, &**mi)
-                                })
-                            }
-                            _ => contains(cfg, &**cfg_mi)
-                        }
-                    })
-                }
-                None => false
-            }
-        } else {
-            false
-        };
-        matches || this_matches
-    });
-    debug!("test_cfg (no_cfgs={}, some_cfg_matches={})", no_cfgs, some_cfg_matches);
-    no_cfgs || some_cfg_matches
-}
-
 /// Represents the #[deprecated="foo"] and friends attributes.
 #[deriving(Encodable,Decodable,Clone,Show)]
 pub struct Stability {
diff --git a/src/libsyntax/config.rs b/src/libsyntax/config.rs
index a53be6097fd..8824a937038 100644
--- a/src/libsyntax/config.rs
+++ b/src/libsyntax/config.rs
@@ -259,20 +259,20 @@ fn in_cfg(diagnostic: &SpanHandler, cfg: &[P<ast::MetaItem>], attrs: &[ast::Attr
         };
 
         if mis.len() != 1 {
-            diagnostic.span_warn(attr.span, "The use of multiple cfgs in the top level of \
-                                             `#[cfg(..)]` is deprecated. Change `#[cfg(a, b)]` to \
-                                             `#[cfg(all(a, b))]`.");
+            diagnostic.span_err(attr.span, "expected 1 cfg-pattern");
+            return false;
         }
 
         if seen_cfg {
-            diagnostic.span_warn(attr.span, "The semantics of multiple `#[cfg(..)]` attributes on \
-                                             same item are changing from the union of the cfgs to \
-                                             the intersection of the cfgs. Change `#[cfg(a)] \
-                                             #[cfg(b)]` to `#[cfg(any(a, b))]`.");
+            diagnostic.span_err(attr.span, "The semantics of multiple `#[cfg(..)]` attributes on \
+                                            same item are changing from the union of the cfgs to \
+                                            the intersection of the cfgs. Change `#[cfg(a)] \
+                                            #[cfg(b)]` to `#[cfg(any(a, b))]`.");
+            return false;
         }
 
         seen_cfg = true;
-        in_cfg |= mis.iter().all(|mi| attr::cfg_matches(diagnostic, cfg, &**mi));
+        in_cfg |= attr::cfg_matches(diagnostic, cfg, &*mis[0]);
     }
     in_cfg | !seen_cfg
 }
diff --git a/src/libsyntax/ext/cfg.rs b/src/libsyntax/ext/cfg.rs
index 74039da6cab..f697acb417d 100644
--- a/src/libsyntax/ext/cfg.rs
+++ b/src/libsyntax/ext/cfg.rs
@@ -8,11 +8,9 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-/**
-The compiler code necessary to support the cfg! extension, which
-expands to a literal `true` or `false` based on whether the given cfgs
-match the current compilation environment.
-*/
+/// The compiler code necessary to support the cfg! extension, which expands to
+/// a literal `true` or `false` based on whether the given cfg matches the
+/// current compilation environment.
 
 use ast;
 use codemap::Span;
@@ -24,28 +22,18 @@ use attr::*;
 use parse::attr::ParserAttr;
 use parse::token;
 
-
 pub fn expand_cfg<'cx>(cx: &mut ExtCtxt,
                        sp: Span,
                        tts: &[ast::TokenTree])
                        -> Box<base::MacResult+'static> {
     let mut p = cx.new_parser_from_tts(tts);
-    let mut cfgs = Vec::new();
-    // parse `cfg!(meta_item, meta_item(x,y), meta_item="foo", ...)`
-    while p.token != token::EOF {
-        cfgs.push(p.parse_meta_item());
-        if p.eat(&token::EOF) { break } // trailing comma is optional,.
-        p.expect(&token::COMMA);
-    }
+    let cfg = p.parse_meta_item();
 
-    if cfgs.len() != 1 {
-        cx.span_warn(sp, "The use of multiple cfgs at the top level of `cfg!` \
-                          is deprecated. Change `cfg!(a, b)` to \
-                          `cfg!(all(a, b))`.");
+    if !p.eat(&token::EOF) {
+        cx.span_err(sp, "expected 1 cfg-pattern");
+        return DummyResult::expr(sp);
     }
 
-    let matches_cfg = cfgs.iter().all(|cfg| attr::cfg_matches(&cx.parse_sess.span_diagnostic,
-                                                              cx.cfg.as_slice(), &**cfg));
-
+    let matches_cfg = attr::cfg_matches(&cx.parse_sess.span_diagnostic, cx.cfg.as_slice(), &*cfg);
     MacExpr::new(cx.expr_bool(sp, matches_cfg))
 }
diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs
index 9fb5742bb9b..37586f6abd7 100644
--- a/src/libsyntax/test.rs
+++ b/src/libsyntax/test.rs
@@ -126,7 +126,7 @@ impl<'a> fold::Folder for TestHarnessGenerator<'a> {
                         span: i.span,
                         path: self.cx.path.clone(),
                         bench: is_bench_fn(&self.cx, &*i),
-                        ignore: is_ignored(&self.cx, &*i),
+                        ignore: is_ignored(&*i),
                         should_fail: should_fail(&*i)
                     };
                     self.cx.testfns.push(test);
@@ -343,22 +343,8 @@ fn is_bench_fn(cx: &TestCtxt, i: &ast::Item) -> bool {
     return has_bench_attr && has_test_signature(i);
 }
 
-fn is_ignored(cx: &TestCtxt, i: &ast::Item) -> bool {
-    i.attrs.iter().any(|attr| {
-        // check ignore(cfg(foo, bar))
-        attr.check_name("ignore") && match attr.meta_item_list() {
-            Some(ref cfgs) => {
-                if cfgs.iter().any(|cfg| cfg.check_name("cfg")) {
-                    cx.span_diagnostic.span_warn(attr.span,
-                            "The use of cfg filters in #[ignore] is \
-                             deprecated. Use #[cfg_attr(<cfg pattern>, \
-                             ignore)] instead.");
-                }
-                attr::test_cfg(cx.config.as_slice(), cfgs.iter())
-            }
-            None => true
-        }
-    })
+fn is_ignored(i: &ast::Item) -> bool {
+    i.attrs.iter().any(|attr| attr.check_name("ignore"))
 }
 
 fn should_fail(i: &ast::Item) -> bool {