summaryrefslogtreecommitdiff
path: root/src/expand/cfg.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-10-18 18:34:44 +0800
committerJohn Hodge <tpg@mutabah.net>2016-10-18 18:37:08 +0800
commit1f37dcc2455aacd0fe797613efea712c57948835 (patch)
tree81715347fdaaa4f527e80945577e2e3d74a6fff6 /src/expand/cfg.cpp
parent633183d0e322efc0d2e3f924420acc851539c868 (diff)
downloadmrust-1f37dcc2455aacd0fe797613efea712c57948835.tar.gz
Expand/cfg - Support #[cfg] on crates by nuking all items
Diffstat (limited to 'src/expand/cfg.cpp')
-rw-r--r--src/expand/cfg.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/expand/cfg.cpp b/src/expand/cfg.cpp
index e4b5c49c..897c952a 100644
--- a/src/expand/cfg.cpp
+++ b/src/expand/cfg.cpp
@@ -6,6 +6,7 @@
#include <parse/common.hpp>
#include "cfg.hpp"
#include <ast/expr.hpp> // Needed to clear a ExprNodeP
+#include <ast/crate.hpp>
#include <map>
#include <set>
@@ -108,6 +109,15 @@ class CCfgHandler:
AttrStage stage() const override { return AttrStage::Pre; }
+ void handle(const Span& sp, const AST::MetaItem& mi, AST::Crate& crate) const override {
+ DEBUG("#[cfg] crate - " << mi);
+ // Ignore, as #[cfg] on a crate is handled in expand/mod.cpp
+ if( check_cfg(sp, mi) ) {
+ }
+ else {
+ crate.m_root_module.items().clear();
+ }
+ }
void handle(const Span& sp, const AST::MetaItem& mi, ::AST::Crate& crate, const AST::Path& path, AST::Module& mod, AST::Item&i) const override {
TRACE_FUNCTION_FR("#[cfg] item - " << mi, (i.is_None() ? "Deleted" : ""));
if( check_cfg(sp, mi) ) {