Move next_node_id to Resolver
This doesn't migrate the pretty-printing everybody loops, which will be done in the next few commits.
This commit is contained in:
parent
5a5027519a
commit
516a817dbd
12 changed files with 64 additions and 64 deletions
|
|
@ -449,7 +449,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
|
|||
name: kw::PathRoot,
|
||||
span: source.ident.span,
|
||||
},
|
||||
id: Some(self.r.session.next_node_id()),
|
||||
id: Some(self.r.next_node_id()),
|
||||
});
|
||||
source.ident.name = crate_name;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -961,6 +961,8 @@ pub struct Resolver<'a> {
|
|||
variant_vis: DefIdMap<ty::Visibility>,
|
||||
|
||||
lint_buffer: lint::LintBuffer,
|
||||
|
||||
next_node_id: NodeId,
|
||||
}
|
||||
|
||||
/// Nothing really interesting here; it just provides memory for the rest of the crate.
|
||||
|
|
@ -1078,6 +1080,10 @@ impl<'a> hir::lowering::Resolver for Resolver<'a> {
|
|||
fn lint_buffer(&mut self) -> &mut lint::LintBuffer {
|
||||
&mut self.lint_buffer
|
||||
}
|
||||
|
||||
fn next_node_id(&mut self) -> NodeId {
|
||||
self.next_node_id()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Resolver<'a> {
|
||||
|
|
@ -1226,9 +1232,26 @@ impl<'a> Resolver<'a> {
|
|||
.collect(),
|
||||
variant_vis: Default::default(),
|
||||
lint_buffer: lint::LintBuffer::default(),
|
||||
next_node_id: NodeId::from_u32(1),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn reserve_node_ids(&mut self, count: usize) -> ast::NodeId {
|
||||
let id = self.next_node_id;
|
||||
|
||||
match id.as_usize().checked_add(count) {
|
||||
Some(next) => {
|
||||
self.next_node_id = ast::NodeId::from_usize(next);
|
||||
}
|
||||
None => panic!("input too large; ran out of node-IDs!"),
|
||||
}
|
||||
|
||||
id
|
||||
}
|
||||
pub fn next_node_id(&mut self) -> NodeId {
|
||||
self.reserve_node_ids(1)
|
||||
}
|
||||
|
||||
pub fn lint_buffer(&mut self) -> &mut lint::LintBuffer {
|
||||
&mut self.lint_buffer
|
||||
}
|
||||
|
|
@ -2827,9 +2850,9 @@ impl<'a> Resolver<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn new_ast_path_segment(&self, ident: Ident) -> ast::PathSegment {
|
||||
fn new_ast_path_segment(&mut self, ident: Ident) -> ast::PathSegment {
|
||||
let mut seg = ast::PathSegment::from_ident(ident);
|
||||
seg.id = self.session.next_node_id();
|
||||
seg.id = self.next_node_id();
|
||||
seg
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ fn fast_print_path(path: &ast::Path) -> Symbol {
|
|||
|
||||
impl<'a> base::Resolver for Resolver<'a> {
|
||||
fn next_node_id(&mut self) -> NodeId {
|
||||
self.session.next_node_id()
|
||||
self.next_node_id()
|
||||
}
|
||||
|
||||
fn resolve_dollar_crates(&mut self) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue