diff options
| author | Felix S. Klock II <pnkfelix@pnkfx.org> | 2014-05-08 15:50:54 +0200 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-05-15 13:50:42 -0700 |
| commit | 39b271f4a309b850c947f5c4e61c978a3cfbcd1e (patch) | |
| tree | 0119be5e5d81f8cff37734b5c91dbe04e94162a9 /src/libsyntax | |
| parent | b9e4fcbf04b21c39b5e704a1f24adbfe179f8814 (diff) | |
| download | rust-39b271f4a309b850c947f5c4e61c978a3cfbcd1e.tar.gz rust-39b271f4a309b850c947f5c4e61c978a3cfbcd1e.zip | |
Add `EntryPat` and `NodePat` variants to ast_map.
Add `EntryPat` and `NodePat` variants to ast_map, so that lookups for
id 1 in `let S{val: _x /* pat 2 */} /* pat 1 */ = ...` will actually
resolve to the pattern `S{ ... }`, rather than "unknown node", in a
function like `node_id_to_str`.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast_map.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index 333f876e479..6a7b913dce4 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -103,6 +103,7 @@ pub enum Node { NodeStmt(@Stmt), NodeArg(@Pat), NodeLocal(@Pat), + NodePat(@Pat), NodeBlock(P<Block>), /// NodeStructCtor represents a tuple struct. @@ -127,6 +128,7 @@ enum MapEntry { EntryStmt(NodeId, @Stmt), EntryArg(NodeId, @Pat), EntryLocal(NodeId, @Pat), + EntryPat(NodeId, @Pat), EntryBlock(NodeId, P<Block>), EntryStructCtor(NodeId, @StructDef), EntryLifetime(NodeId, @Lifetime), @@ -154,6 +156,7 @@ impl MapEntry { EntryStmt(id, _) => id, EntryArg(id, _) => id, EntryLocal(id, _) => id, + EntryPat(id, _) => id, EntryBlock(id, _) => id, EntryStructCtor(id, _) => id, EntryLifetime(id, _) => id, @@ -172,6 +175,7 @@ impl MapEntry { EntryStmt(_, p) => NodeStmt(p), EntryArg(_, p) => NodeArg(p), EntryLocal(_, p) => NodeLocal(p), + EntryPat(_, p) => NodePat(p), EntryBlock(_, p) => NodeBlock(p), EntryStructCtor(_, p) => NodeStructCtor(p), EntryLifetime(_, p) => NodeLifetime(p), @@ -399,6 +403,7 @@ impl Map { Some(NodeExpr(expr)) => expr.span, Some(NodeStmt(stmt)) => stmt.span, Some(NodeArg(pat)) | Some(NodeLocal(pat)) => pat.span, + Some(NodePat(pat)) => pat.span, Some(NodeBlock(block)) => block.span, Some(NodeStructCtor(_)) => self.expect_item(self.get_parent(id)).span, _ => fail!("node_span: could not find span for id {}", id), @@ -513,7 +518,9 @@ impl<'a, F: FoldOps> Folder for Ctx<'a, F> { // Note: this is at least *potentially* a pattern... self.insert(pat.id, EntryLocal(self.parent, pat)); } - _ => {} + _ => { + self.insert(pat.id, EntryPat(self.parent, pat)); + } } pat @@ -704,6 +711,9 @@ fn node_id_to_str(map: &Map, id: NodeId) -> StrBuf { (format!("local {} (id={})", pprust::pat_to_str(pat), id)).to_strbuf() } + Some(NodePat(pat)) => { + (format!("pat {} (id={})", pprust::pat_to_str(pat), id)).to_strbuf() + } Some(NodeBlock(block)) => { (format!("block {} (id={})", pprust::block_to_str(block), id)).to_strbuf() |
