Skip to content

Commit 2a8ad09

Browse files
committed
in which a hir_id field is added to remaining HIR nodes lacking it
This shouldn't really be doing any more work (except taking more memory to store the extra field)—we were already generating a `HirId` and immediately throwing it away whenever we said `.lower_node_id(id).node_id` (respectively `.next_id(id).node_id`) during lowering; this commit is just keeping the `HirId`, too. (But this doesn't include, e.g., changing the representation of `BodyId`.) This is for the HirIdification initiative no. 50928.
1 parent 6af9f91 commit 2a8ad09

File tree

18 files changed

+247
-129
lines changed

18 files changed

+247
-129
lines changed

src/librustc/cfg/construct.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,13 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
111111
fn stmt(&mut self, stmt: &hir::Stmt, pred: CFGIndex) -> CFGIndex {
112112
let hir_id = self.tcx.hir.node_to_hir_id(stmt.node.id());
113113
match stmt.node {
114-
hir::StmtDecl(ref decl, _) => {
114+
hir::StmtDecl(ref decl, _, _) => {
115115
let exit = self.decl(&decl, pred);
116116
self.add_ast_node(hir_id.local_id, &[exit])
117117
}
118118

119-
hir::StmtExpr(ref expr, _) |
120-
hir::StmtSemi(ref expr, _) => {
119+
hir::StmtExpr(ref expr, _, _) |
120+
hir::StmtSemi(ref expr, _, _) => {
121121
let exit = self.expr(&expr, pred);
122122
self.add_ast_node(hir_id.local_id, &[exit])
123123
}

src/librustc/hir/check_attr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> {
269269

270270
fn check_stmt_attributes(&self, stmt: &hir::Stmt) {
271271
// When checking statements ignore expressions, they will be checked later
272-
if let hir::Stmt_::StmtDecl(_, _) = stmt.node {
272+
if let hir::Stmt_::StmtDecl(..) = stmt.node {
273273
for attr in stmt.node.attrs() {
274274
if attr.check_name("inline") {
275275
self.check_inline(attr, &stmt.span, Target::Statement);
@@ -348,7 +348,7 @@ fn is_c_like_enum(item: &hir::Item) -> bool {
348348
if let hir::ItemEnum(ref def, _) = item.node {
349349
for variant in &def.variants {
350350
match variant.node.data {
351-
hir::VariantData::Unit(_) => { /* continue */ }
351+
hir::VariantData::Unit(..) => { /* continue */ }
352352
_ => { return false; }
353353
}
354354
}

src/librustc/hir/intravisit.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ pub trait Visitor<'v> : Sized {
238238

239239
///////////////////////////////////////////////////////////////////////////
240240

241+
// FIXME (#50928): should this take a HirId, or should we introduce `visit_hir_id`?
241242
fn visit_id(&mut self, _node_id: NodeId) {
242243
// Nothing to do.
243244
}
@@ -942,12 +943,12 @@ pub fn walk_block<'v, V: Visitor<'v>>(visitor: &mut V, block: &'v Block) {
942943

943944
pub fn walk_stmt<'v, V: Visitor<'v>>(visitor: &mut V, statement: &'v Stmt) {
944945
match statement.node {
945-
StmtDecl(ref declaration, id) => {
946+
StmtDecl(ref declaration, id, _hir_id) => {
946947
visitor.visit_id(id);
947948
visitor.visit_decl(declaration)
948949
}
949-
StmtExpr(ref expression, id) |
950-
StmtSemi(ref expression, id) => {
950+
StmtExpr(ref expression, id, _hir_id) |
951+
StmtSemi(ref expression, id, _hir_id) => {
951952
visitor.visit_id(id);
952953
visitor.visit_expr(expression)
953954
}

0 commit comments

Comments
 (0)