diff options
author | John Hodge <tpg@mutabah.net> | 2016-09-26 16:16:13 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-09-26 16:16:13 +0800 |
commit | 0ec707867945e7ab3d9fa5d2298c9d65edc743ac (patch) | |
tree | b5f67e7d8112960d44ebf732948f6c19aa4b4a15 /src/expand/cfg.cpp | |
parent | ed7739376e494ac4bd788cc9ec383dd645f7552b (diff) | |
download | mrust-0ec707867945e7ab3d9fa5d2298c9d65edc743ac.tar.gz |
Expand cfg - Support cfg() on struct fields and enum variants
Diffstat (limited to 'src/expand/cfg.cpp')
-rw-r--r-- | src/expand/cfg.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/expand/cfg.cpp b/src/expand/cfg.cpp index c79e9872..746fd513 100644 --- a/src/expand/cfg.cpp +++ b/src/expand/cfg.cpp @@ -155,6 +155,25 @@ class CCfgHandler: impl.type() = ::TypeRef(); } } + + void handle(const Span& sp, const AST::MetaItem& mi, AST::Crate& crate, ::AST::StructItem& si) const override { + DEBUG("#[cfg] struct item - " << mi); + if( !check_cfg(sp, mi) ) { + si.m_name = ""; + } + } + void handle(const Span& sp, const AST::MetaItem& mi, AST::Crate& crate, ::AST::TupleItem& i) const override { + DEBUG("#[cfg] tuple item - " << mi); + if( !check_cfg(sp, mi) ) { + i.m_type = ::TypeRef(); + } + } + void handle(const Span& sp, const AST::MetaItem& mi, AST::Crate& crate, ::AST::EnumVariant& i) const override { + DEBUG("#[cfg] enum variant - " << mi); + if( !check_cfg(sp, mi) ) { + i.m_name = ""; + } + } }; STATIC_MACRO("cfg", CCfgExpander); |