diff options
| author | Aaron Hill <aa1ronham@gmail.com> | 2021-08-04 19:41:13 -0500 |
|---|---|---|
| committer | Aaron Hill <aa1ronham@gmail.com> | 2021-08-06 09:30:47 -0500 |
| commit | a35d7f2bb32c35a5da3c7e7ba0d68af1e33f0619 (patch) | |
| tree | 0ac6032a9a4514a6623c38ad9f54727abdd4d2a5 /compiler/rustc_expand/src/placeholders.rs | |
| parent | 1f94abcda6884893d4723304102089198caa0839 (diff) | |
| download | rust-a35d7f2bb32c35a5da3c7e7ba0d68af1e33f0619.tar.gz rust-a35d7f2bb32c35a5da3c7e7ba0d68af1e33f0619.zip | |
Remove special case for statement `NodeId` assignment
We now let `noop_flat_map_stmt` assign `NodeId`s (via `visit_id`), just as we do for other AST nodes.
Diffstat (limited to 'compiler/rustc_expand/src/placeholders.rs')
| -rw-r--r-- | compiler/rustc_expand/src/placeholders.rs | 25 |
1 files changed, 4 insertions, 21 deletions
diff --git a/compiler/rustc_expand/src/placeholders.rs b/compiler/rustc_expand/src/placeholders.rs index 6586ba138fb..8e78fcbb8db 100644 --- a/compiler/rustc_expand/src/placeholders.rs +++ b/compiler/rustc_expand/src/placeholders.rs @@ -1,4 +1,3 @@ -use crate::base::ExtCtxt; use crate::expand::{AstFragment, AstFragmentKind}; use rustc_ast as ast; @@ -175,17 +174,12 @@ pub fn placeholder( } } -pub struct PlaceholderExpander<'a, 'b> { +#[derive(Default)] +pub struct PlaceholderExpander { expanded_fragments: FxHashMap<ast::NodeId, AstFragment>, - cx: &'a mut ExtCtxt<'b>, - monotonic: bool, } -impl<'a, 'b> PlaceholderExpander<'a, 'b> { - pub fn new(cx: &'a mut ExtCtxt<'b>, monotonic: bool) -> Self { - PlaceholderExpander { cx, expanded_fragments: FxHashMap::default(), monotonic } - } - +impl PlaceholderExpander { pub fn add(&mut self, id: ast::NodeId, mut fragment: AstFragment) { fragment.mut_visit_with(self); self.expanded_fragments.insert(id, fragment); @@ -196,7 +190,7 @@ impl<'a, 'b> PlaceholderExpander<'a, 'b> { } } -impl<'a, 'b> MutVisitor for PlaceholderExpander<'a, 'b> { +impl MutVisitor for PlaceholderExpander { fn flat_map_arm(&mut self, arm: ast::Arm) -> SmallVec<[ast::Arm; 1]> { if arm.is_placeholder { self.remove(arm.id).make_arms() @@ -360,15 +354,4 @@ impl<'a, 'b> MutVisitor for PlaceholderExpander<'a, 'b> { _ => noop_visit_ty(ty, self), } } - - fn visit_block(&mut self, block: &mut P<ast::Block>) { - noop_visit_block(block, self); - - for stmt in block.stmts.iter_mut() { - if self.monotonic { - assert_eq!(stmt.id, ast::DUMMY_NODE_ID); - stmt.id = self.cx.resolver.next_node_id(); - } - } - } } |
