diff options
| author | David Wood <david@davidtw.co> | 2019-03-12 17:00:20 +0100 |
|---|---|---|
| committer | David Wood <david@davidtw.co> | 2019-04-21 16:46:32 +0100 |
| commit | 879abb1641d97be798010f52a875b9fc83881323 (patch) | |
| tree | 795d9bd80cf7f29b8f52244386aabcc1240adb61 /src/libsyntax/ext | |
| parent | 41c6bb1096abb026d496c2136bb18c001eca46fe (diff) | |
| download | rust-879abb1641d97be798010f52a875b9fc83881323.tar.gz rust-879abb1641d97be798010f52a875b9fc83881323.zip | |
Add `AsyncArgument` to AST.
This commit adds an `AsyncArgument` struct to the AST that contains the generated argument and statement that will be used in HIR lowering, name resolution and def collection.
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/placeholders.rs | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/libsyntax/ext/placeholders.rs b/src/libsyntax/ext/placeholders.rs index 3e60dd81a3b..68cd3c28676 100644 --- a/src/libsyntax/ext/placeholders.rs +++ b/src/libsyntax/ext/placeholders.rs @@ -102,6 +102,13 @@ impl<'a, 'b> PlaceholderExpander<'a, 'b> { fn remove(&mut self, id: ast::NodeId) -> AstFragment { self.expanded_fragments.remove(&id).unwrap() } + + fn next_id(&mut self, id: &mut ast::NodeId) { + if self.monotonic { + assert_eq!(*id, ast::DUMMY_NODE_ID); + *id = self.cx.resolver.next_node_id() + } + } } impl<'a, 'b> MutVisitor for PlaceholderExpander<'a, 'b> { @@ -183,9 +190,16 @@ impl<'a, 'b> MutVisitor for PlaceholderExpander<'a, 'b> { 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(); + self.next_id(&mut stmt.id); + } + } + + fn visit_asyncness(&mut self, a: &mut ast::IsAsync) { + noop_visit_asyncness(a, self); + + if let ast::IsAsync::Async { ref mut arguments, .. } = a { + for argument in arguments.iter_mut() { + self.next_id(&mut argument.stmt.id); } } } |
