summary refs log tree commit diff
path: root/src/libsyntax/test.rs
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-11-04 14:59:42 -0800
committerAlex Crichton <alex@alexcrichton.com>2014-11-07 12:04:28 -0800
commit3dbd32854f6bdee94c98c5e3e5da58fb79d79fd9 (patch)
treec38be4cf6f5ffdf89a3983635849a90b502d87fb /src/libsyntax/test.rs
parent45cbdec4174778bf915f17561ef971c068a7fcbc (diff)
downloadrust-3dbd32854f6bdee94c98c5e3e5da58fb79d79fd9.tar.gz
rust-3dbd32854f6bdee94c98c5e3e5da58fb79d79fd9.zip
rustc: Process #[cfg]/#[cfg_attr] on crates
This commit implements processing these two attributes at the crate level as
well as at the item level. When #[cfg] is applied at the crate level, then the
entire crate will be omitted if the cfg doesn't match. The #[cfg_attr] attribute
is processed as usual in that the attribute is included or not depending on
whether the cfg matches.

This was spurred on by motivations of #18585 where #[cfg_attr] annotations will
be applied at the crate-level.

cc #18585
Diffstat (limited to 'src/libsyntax/test.rs')
-rw-r--r--src/libsyntax/test.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs
index a7db8e800a9..29637e88dd5 100644
--- a/src/libsyntax/test.rs
+++ b/src/libsyntax/test.rs
@@ -108,7 +108,10 @@ impl<'a> fold::Folder for TestHarnessGenerator<'a> {
     }
 
     fn fold_item(&mut self, i: P<ast::Item>) -> SmallVector<P<ast::Item>> {
-        self.cx.path.push(i.ident);
+        let ident = i.ident;
+        if ident.name != token::special_idents::invalid.name {
+            self.cx.path.push(ident);
+        }
         debug!("current path: {}",
                ast_util::path_name_i(self.cx.path.as_slice()));
 
@@ -143,7 +146,9 @@ impl<'a> fold::Folder for TestHarnessGenerator<'a> {
             ast::ItemMod(..) => fold::noop_fold_item(i, self),
             _ => SmallVector::one(i),
         };
-        self.cx.path.pop();
+        if ident.name != token::special_idents::invalid.name {
+            self.cx.path.pop();
+        }
         res
     }