Skip to content

Commit 745ddf2

Browse files
committed
Refactor out mark.as_placeholder_id().
1 parent 6f040b4 commit 745ddf2

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/libsyntax/ext/expand.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
275275
if expansions.len() < depth {
276276
expansions.push(Vec::new());
277277
}
278-
expansions[depth - 1].push((mark.as_u32(), expansion));
278+
expansions[depth - 1].push((mark, expansion));
279279
if !self.cx.ecfg.single_step {
280280
invocations.extend(new_invocations.into_iter().rev());
281281
}
@@ -286,7 +286,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
286286
let mut placeholder_expander = PlaceholderExpander::new(self.cx, self.monotonic);
287287
while let Some(expansions) = expansions.pop() {
288288
for (mark, expansion) in expansions.into_iter().rev() {
289-
placeholder_expander.add(ast::NodeId::from_u32(mark), expansion);
289+
placeholder_expander.add(mark.as_placeholder_id(), expansion);
290290
}
291291
}
292292

@@ -586,7 +586,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
586586
..self.cx.current_expansion.clone()
587587
},
588588
});
589-
placeholder(expansion_kind, ast::NodeId::from_u32(mark.as_u32()))
589+
placeholder(expansion_kind, mark.as_placeholder_id())
590590
}
591591

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

749749
item.and_then(|mut item| match item.node {
750750
ItemKind::Mac(_) if is_macro_def => {
751-
item.id = ast::NodeId::from_u32(Mark::fresh().as_u32());
751+
item.id = Mark::fresh().as_placeholder_id();
752752
SmallVector::one(P(item))
753753
}
754754
ItemKind::Mac(mac) => {

src/libsyntax/ext/hygiene.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ impl Mark {
5151
Mark(id.as_u32())
5252
}
5353

54-
pub fn as_u32(&self) -> u32 {
54+
pub fn as_placeholder_id(self) -> NodeId {
55+
NodeId::from_u32(self.0)
56+
}
57+
58+
pub fn as_u32(self) -> u32 {
5559
self.0
5660
}
5761
}

0 commit comments

Comments
 (0)