diff options
Diffstat (limited to 'gcc/rust/expand/rust-cfg-strip.cc')
-rw-r--r-- | gcc/rust/expand/rust-cfg-strip.cc | 57 |
1 files changed, 41 insertions, 16 deletions
diff --git a/gcc/rust/expand/rust-cfg-strip.cc b/gcc/rust/expand/rust-cfg-strip.cc index 0db6122..58d8071 100644 --- a/gcc/rust/expand/rust-cfg-strip.cc +++ b/gcc/rust/expand/rust-cfg-strip.cc @@ -1765,16 +1765,17 @@ CfgStrip::visit (AST::Module &module) return; } - // A loaded module might have inner attributes - if (module.get_kind () == AST::Module::ModuleKind::LOADED) + if (module.get_kind () == AST::Module::UNLOADED) { - // strip test based on inner attrs - expand_cfg_attrs (module.get_inner_attrs ()); - if (fails_cfg_with_expand (module.get_inner_attrs ())) - { - module.mark_for_strip (); - return; - } + module.load_items (); + } + + // strip test based on inner attrs + expand_cfg_attrs (module.get_inner_attrs ()); + if (fails_cfg_with_expand (module.get_inner_attrs ())) + { + module.mark_for_strip (); + return; } // strip items if required @@ -2267,7 +2268,7 @@ CfgStrip::visit (AST::IdentifierPattern &pattern) AST::DefaultASTVisitor::visit (pattern); - auto &sub_pattern = pattern.get_pattern_to_bind (); + auto &sub_pattern = pattern.get_subpattern (); if (sub_pattern.is_marked_for_strip ()) rust_error_at (sub_pattern.get_locus (), "cannot strip pattern in this position"); @@ -2477,20 +2478,44 @@ CfgStrip::visit (AST::GroupedPattern &pattern) } void -CfgStrip::visit (AST::SlicePattern &pattern) +CfgStrip::visit (AST::SlicePatternItemsNoRest &items) { - AST::DefaultASTVisitor::visit (pattern); + AST::DefaultASTVisitor::visit (items); // can't strip individual patterns, only sub-patterns - for (auto &item : pattern.get_items ()) + for (auto &pattern : items.get_patterns ()) { - if (item->is_marked_for_strip ()) - rust_error_at (item->get_locus (), + if (pattern->is_marked_for_strip ()) + rust_error_at (pattern->get_locus (), "cannot strip pattern in this position"); - // TODO: quit stripping now? or keep going? } } void +CfgStrip::visit (AST::SlicePatternItemsHasRest &items) +{ + AST::DefaultASTVisitor::visit (items); + // can't strip individual patterns, only sub-patterns + for (auto &pattern : items.get_lower_patterns ()) + { + if (pattern->is_marked_for_strip ()) + rust_error_at (pattern->get_locus (), + "cannot strip pattern in this position"); + } + for (auto &pattern : items.get_upper_patterns ()) + { + if (pattern->is_marked_for_strip ()) + rust_error_at (pattern->get_locus (), + "cannot strip pattern in this position"); + } +} + +void +CfgStrip::visit (AST::SlicePattern &pattern) +{ + AST::DefaultASTVisitor::visit (pattern); +} + +void CfgStrip::visit (AST::AltPattern &pattern) { AST::DefaultASTVisitor::visit (pattern); |