Skip to content

Commit

Permalink
Refactor out mark.as_placeholder_id().
Browse files Browse the repository at this point in the history
  • Loading branch information
jseyfried committed Dec 18, 2016
1 parent 6f040b4 commit 745ddf2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/libsyntax/ext/expand.rs
Expand Up @@ -275,7 +275,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
if expansions.len() < depth {
expansions.push(Vec::new());
}
expansions[depth - 1].push((mark.as_u32(), expansion));
expansions[depth - 1].push((mark, expansion));
if !self.cx.ecfg.single_step {
invocations.extend(new_invocations.into_iter().rev());
}
Expand All @@ -286,7 +286,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
let mut placeholder_expander = PlaceholderExpander::new(self.cx, self.monotonic);
while let Some(expansions) = expansions.pop() {
for (mark, expansion) in expansions.into_iter().rev() {
placeholder_expander.add(ast::NodeId::from_u32(mark), expansion);
placeholder_expander.add(mark.as_placeholder_id(), expansion);
}
}

Expand Down Expand Up @@ -586,7 +586,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
..self.cx.current_expansion.clone()
},
});
placeholder(expansion_kind, ast::NodeId::from_u32(mark.as_u32()))
placeholder(expansion_kind, mark.as_placeholder_id())
}

fn collect_bang(&mut self, mac: ast::Mac, span: Span, kind: ExpansionKind) -> Expansion {
Expand Down Expand Up @@ -748,7 +748,7 @@ impl<'a, 'b> Folder for InvocationCollector<'a, 'b> {

item.and_then(|mut item| match item.node {
ItemKind::Mac(_) if is_macro_def => {
item.id = ast::NodeId::from_u32(Mark::fresh().as_u32());
item.id = Mark::fresh().as_placeholder_id();
SmallVector::one(P(item))
}
ItemKind::Mac(mac) => {
Expand Down
6 changes: 5 additions & 1 deletion src/libsyntax/ext/hygiene.rs
Expand Up @@ -51,7 +51,11 @@ impl Mark {
Mark(id.as_u32())
}

pub fn as_u32(&self) -> u32 {
pub fn as_placeholder_id(self) -> NodeId {
NodeId::from_u32(self.0)
}

pub fn as_u32(self) -> u32 {
self.0
}
}
Expand Down

0 comments on commit 745ddf2

Please sign in to comment.