Skip to content

Commit 43a7405

Browse files
Inline reserve_node_ids
This function was only ever called with 1 so there's little point in it; this isn't an expensive operation (essentially a checked add) so we're not really "reserving" anything either.
1 parent dd6df0d commit 43a7405

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

src/librustc_resolve/lib.rs

+5-13
Original file line numberDiff line numberDiff line change
@@ -1236,20 +1236,12 @@ impl<'a> Resolver<'a> {
12361236
}
12371237
}
12381238

1239-
pub fn reserve_node_ids(&mut self, count: usize) -> ast::NodeId {
1240-
let id = self.next_node_id;
1241-
1242-
match id.as_usize().checked_add(count) {
1243-
Some(next) => {
1244-
self.next_node_id = ast::NodeId::from_usize(next);
1245-
}
1246-
None => panic!("input too large; ran out of node-IDs!"),
1247-
}
1248-
1249-
id
1250-
}
12511239
pub fn next_node_id(&mut self) -> NodeId {
1252-
self.reserve_node_ids(1)
1240+
let next = self.next_node_id.as_usize()
1241+
.checked_add(1)
1242+
.expect("input too large; ran out of NodeIds");
1243+
self.next_node_id = ast::NodeId::from_usize(next);
1244+
self.next_node_id
12531245
}
12541246

12551247
pub fn lint_buffer(&mut self) -> &mut lint::LintBuffer {

0 commit comments

Comments
 (0)