Skip to content

Commit 85f08b5

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 17dfce0 commit 85f08b5

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
@@ -1245,20 +1245,12 @@ impl<'a> Resolver<'a> {
12451245
}
12461246
}
12471247

1248-
pub fn reserve_node_ids(&mut self, count: usize) -> ast::NodeId {
1249-
let id = self.next_node_id;
1250-
1251-
match id.as_usize().checked_add(count) {
1252-
Some(next) => {
1253-
self.next_node_id = ast::NodeId::from_usize(next);
1254-
}
1255-
None => panic!("input too large; ran out of node-IDs!"),
1256-
}
1257-
1258-
id
1259-
}
12601248
pub fn next_node_id(&mut self) -> NodeId {
1261-
self.reserve_node_ids(1)
1249+
let next = self.next_node_id.as_usize()
1250+
.checked_add(1)
1251+
.expect("input too large; ran out of NodeIds");
1252+
self.next_node_id = ast::NodeId::from_usize(next);
1253+
self.next_node_id
12621254
}
12631255

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

0 commit comments

Comments
 (0)