Skip to content

Commit 3ebf7b4

Browse files
committed
rustc: Assert that the parser doesn't assign node id 0
It is reserved for indicating the crate, but doesn't exist in the AST
1 parent 20b8509 commit 3ebf7b4

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/comp/syntax/parse/parser.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ type parse_sess = @{
3131
fn next_node_id(sess: parse_sess) -> node_id {
3232
let rv = sess.next_id;
3333
sess.next_id += 1;
34+
// ID 0 is reserved for the crate and doesn't actually exist in the AST
35+
assert rv != 0;
3436
ret rv;
3537
}
3638

0 commit comments

Comments
 (0)