about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-02-12 20:03:50 +0000
committerbors <bors@rust-lang.org>2015-02-12 20:03:50 +0000
commit39b463f15328f448c13fa990f9fc8897e0af55c2 (patch)
tree84e7a693dfc0575f10699fc6de0876995d894ebd /src/libsyntax
parentcca1cf613b8e535ab274d6ce5aecadf4708990bf (diff)
parenta25ed227a7887454bd1717286a7ada4f8a8d9a00 (diff)
downloadrust-39b463f15328f448c13fa990f9fc8897e0af55c2.tar.gz
rust-39b463f15328f448c13fa990f9fc8897e0af55c2.zip
Auto merge of #22182 - nikomatsakis:cycles-in-collect, r=nikomatsakis
This resolves a number of bugs that trigger stack overflows or other cyclic errors.

r? @nick29581 (it is based on work that you started)
f? @jroesch (also based on your branch)
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ast.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index 5979d339e17..d6778be553e 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -366,6 +366,14 @@ pub struct DefId {
     pub node: NodeId,
 }
 
+impl DefId {
+    /// Read the node id, asserting that this def-id is krate-local.
+    pub fn local_id(&self) -> NodeId {
+        assert_eq!(self.krate, LOCAL_CRATE);
+        self.node
+    }
+}
+
 /// Item definitions in the currently-compiled crate would have the CrateNum
 /// LOCAL_CRATE in their DefId.
 pub const LOCAL_CRATE: CrateNum = 0;