diff options
author | John Hodge <tpg@mutabah.net> | 2017-08-27 23:23:29 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2017-08-31 16:31:24 +0800 |
commit | 0f3b5722d594bec8c425dd64cecbd63e3b5ca228 (patch) | |
tree | ab8ddd40667ca1d974c6c778cbd9506c9d7a23ed /src/expand/mod.cpp | |
parent | ac76c324ab657c58c37af983a31ec7f6c06270e1 (diff) | |
download | mrust-0f3b5722d594bec8c425dd64cecbd63e3b5ca228.tar.gz |
Expand - #[cfg] on struct literals
Diffstat (limited to 'src/expand/mod.cpp')
-rw-r--r-- | src/expand/mod.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/expand/mod.cpp b/src/expand/mod.cpp index 9137cc02..7bcf0774 100644 --- a/src/expand/mod.cpp +++ b/src/expand/mod.cpp @@ -656,8 +656,18 @@ struct CExpandExpr: this->visit_nodelete(node, node.m_base_value); for(auto& val : node.m_values) { - // TODO: Attributes on struct literal items (#[cfg] only?) + Expand_Attrs(val.attrs, AttrStage::Pre , [&](const auto& sp, const auto& d, const auto& a){ d.handle(sp, a, crate, val); }); + if( !val.value ) + continue ; this->visit_nodelete(node, val.value); + Expand_Attrs(val.attrs, AttrStage::Post, [&](const auto& sp, const auto& d, const auto& a){ d.handle(sp, a, crate, val); }); + } + for(auto it = node.m_values.begin(); it != node.m_values.end(); ) + { + if( it->value ) + ++it; + else + it = node.m_values.erase(it); } } void visit(::AST::ExprNode_Array& node) override { |