Skip to content

Commit a04c789

Browse files
committed
Auto merge of #66936 - cjgillot:hirene-expr, r=Zoxc
Allocate HIR on an arena 2/4 -- Expr & Pat This is the second PR in the series started by #66931 This time, commits don't really make sense on their own. They are mostly split by type of compile error. The additional diff is here: cjgillot/rust@hirene-preamble...hirene-expr
2 parents 3e0a1c0 + fb100e5 commit a04c789

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1189
-995
lines changed

src/librustc/arena.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,25 @@ macro_rules! arena_types {
125125

126126
// HIR types
127127
[few] hir_forest: rustc::hir::map::Forest<$tcx>,
128+
[] arm: rustc::hir::Arm<$tcx>,
128129
[] attribute: syntax::ast::Attribute,
130+
[] block: rustc::hir::Block<$tcx>,
129131
[few] global_asm: rustc::hir::GlobalAsm,
132+
[] expr: rustc::hir::Expr<$tcx>,
133+
[] field: rustc::hir::Field<$tcx>,
134+
[] field_pat: rustc::hir::FieldPat<$tcx>,
130135
[] fn_decl: rustc::hir::FnDecl,
131136
[] foreign_item: rustc::hir::ForeignItem<$tcx>,
132137
[] impl_item_ref: rustc::hir::ImplItemRef,
138+
[] inline_asm: rustc::hir::InlineAsm<$tcx>,
139+
[] local: rustc::hir::Local<$tcx>,
133140
[few] macro_def: rustc::hir::MacroDef<$tcx>,
134-
[] param: rustc::hir::Param,
141+
[] param: rustc::hir::Param<$tcx>,
142+
[] pat: rustc::hir::Pat<$tcx>,
135143
[] path: rustc::hir::Path,
144+
[] path_segment: rustc::hir::PathSegment,
145+
[] qpath: rustc::hir::QPath,
146+
[] stmt: rustc::hir::Stmt<$tcx>,
136147
[] struct_field: rustc::hir::StructField<$tcx>,
137148
[] trait_item_ref: rustc::hir::TraitItemRef,
138149
[] ty: rustc::hir::Ty,

src/librustc/hir/check_attr.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ impl CheckAttrVisitor<'tcx> {
458458
.emit();
459459
}
460460

461-
fn check_stmt_attributes(&self, stmt: &hir::Stmt) {
461+
fn check_stmt_attributes(&self, stmt: &hir::Stmt<'_>) {
462462
// When checking statements ignore expressions, they will be checked later
463463
if let hir::StmtKind::Local(ref l) = stmt.kind {
464464
for attr in l.attrs.iter() {
@@ -477,7 +477,7 @@ impl CheckAttrVisitor<'tcx> {
477477
}
478478
}
479479

480-
fn check_expr_attributes(&self, expr: &hir::Expr) {
480+
fn check_expr_attributes(&self, expr: &hir::Expr<'_>) {
481481
let target = match expr.kind {
482482
hir::ExprKind::Closure(..) => Target::Closure,
483483
_ => Target::Expression,
@@ -537,12 +537,12 @@ impl Visitor<'tcx> for CheckAttrVisitor<'tcx> {
537537
intravisit::walk_impl_item(self, impl_item)
538538
}
539539

540-
fn visit_stmt(&mut self, stmt: &'tcx hir::Stmt) {
540+
fn visit_stmt(&mut self, stmt: &'tcx hir::Stmt<'tcx>) {
541541
self.check_stmt_attributes(stmt);
542542
intravisit::walk_stmt(self, stmt)
543543
}
544544

545-
fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
545+
fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) {
546546
self.check_expr_attributes(expr);
547547
intravisit::walk_expr(self, expr)
548548
}

src/librustc/hir/intravisit.rs

+30-30
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ pub trait Visitor<'v>: Sized {
212212
}
213213
}
214214

215-
fn visit_param(&mut self, param: &'v Param) {
215+
fn visit_param(&mut self, param: &'v Param<'v>) {
216216
walk_param(self, param)
217217
}
218218

@@ -253,25 +253,25 @@ pub trait Visitor<'v>: Sized {
253253
fn visit_foreign_item(&mut self, i: &'v ForeignItem<'v>) {
254254
walk_foreign_item(self, i)
255255
}
256-
fn visit_local(&mut self, l: &'v Local) {
256+
fn visit_local(&mut self, l: &'v Local<'v>) {
257257
walk_local(self, l)
258258
}
259-
fn visit_block(&mut self, b: &'v Block) {
259+
fn visit_block(&mut self, b: &'v Block<'v>) {
260260
walk_block(self, b)
261261
}
262-
fn visit_stmt(&mut self, s: &'v Stmt) {
262+
fn visit_stmt(&mut self, s: &'v Stmt<'v>) {
263263
walk_stmt(self, s)
264264
}
265-
fn visit_arm(&mut self, a: &'v Arm) {
265+
fn visit_arm(&mut self, a: &'v Arm<'v>) {
266266
walk_arm(self, a)
267267
}
268-
fn visit_pat(&mut self, p: &'v Pat) {
268+
fn visit_pat(&mut self, p: &'v Pat<'v>) {
269269
walk_pat(self, p)
270270
}
271271
fn visit_anon_const(&mut self, c: &'v AnonConst) {
272272
walk_anon_const(self, c)
273273
}
274-
fn visit_expr(&mut self, ex: &'v Expr) {
274+
fn visit_expr(&mut self, ex: &'v Expr<'v>) {
275275
walk_expr(self, ex)
276276
}
277277
fn visit_ty(&mut self, t: &'v Ty) {
@@ -409,7 +409,7 @@ pub fn walk_body<'v, V: Visitor<'v>>(visitor: &mut V, body: &'v Body<'v>) {
409409
visitor.visit_expr(&body.value);
410410
}
411411

412-
pub fn walk_local<'v, V: Visitor<'v>>(visitor: &mut V, local: &'v Local) {
412+
pub fn walk_local<'v, V: Visitor<'v>>(visitor: &mut V, local: &'v Local<'v>) {
413413
// Intentionally visiting the expr first - the initialization expr
414414
// dominates the local's definition.
415415
walk_list!(visitor, visit_expr, &local.init);
@@ -462,10 +462,10 @@ where
462462
visitor.visit_path(&trait_ref.path, trait_ref.hir_ref_id)
463463
}
464464

465-
pub fn walk_param<'v, V: Visitor<'v>>(visitor: &mut V, param: &'v Param) {
465+
pub fn walk_param<'v, V: Visitor<'v>>(visitor: &mut V, param: &'v Param<'v>) {
466466
visitor.visit_id(param.hir_id);
467467
visitor.visit_pat(&param.pat);
468-
walk_list!(visitor, visit_attribute, &param.attrs);
468+
walk_list!(visitor, visit_attribute, param.attrs);
469469
}
470470

471471
pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) {
@@ -684,26 +684,26 @@ pub fn walk_assoc_type_binding<'v, V: Visitor<'v>>(visitor: &mut V, type_binding
684684
}
685685
}
686686

687-
pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat) {
687+
pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat<'v>) {
688688
visitor.visit_id(pattern.hir_id);
689689
match pattern.kind {
690-
PatKind::TupleStruct(ref qpath, ref children, _) => {
690+
PatKind::TupleStruct(ref qpath, children, _) => {
691691
visitor.visit_qpath(qpath, pattern.hir_id, pattern.span);
692692
walk_list!(visitor, visit_pat, children);
693693
}
694694
PatKind::Path(ref qpath) => {
695695
visitor.visit_qpath(qpath, pattern.hir_id, pattern.span);
696696
}
697-
PatKind::Struct(ref qpath, ref fields, _) => {
697+
PatKind::Struct(ref qpath, fields, _) => {
698698
visitor.visit_qpath(qpath, pattern.hir_id, pattern.span);
699699
for field in fields {
700700
visitor.visit_id(field.hir_id);
701701
visitor.visit_ident(field.ident);
702702
visitor.visit_pat(&field.pat)
703703
}
704704
}
705-
PatKind::Or(ref pats) => walk_list!(visitor, visit_pat, pats),
706-
PatKind::Tuple(ref tuple_elements, _) => {
705+
PatKind::Or(pats) => walk_list!(visitor, visit_pat, pats),
706+
PatKind::Tuple(tuple_elements, _) => {
707707
walk_list!(visitor, visit_pat, tuple_elements);
708708
}
709709
PatKind::Box(ref subpattern) | PatKind::Ref(ref subpattern, _) => {
@@ -719,7 +719,7 @@ pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat) {
719719
visitor.visit_expr(upper_bound)
720720
}
721721
PatKind::Wild => (),
722-
PatKind::Slice(ref prepatterns, ref slice_pattern, ref postpatterns) => {
722+
PatKind::Slice(prepatterns, ref slice_pattern, postpatterns) => {
723723
walk_list!(visitor, visit_pat, prepatterns);
724724
walk_list!(visitor, visit_pat, slice_pattern);
725725
walk_list!(visitor, visit_pat, postpatterns);
@@ -955,13 +955,13 @@ pub fn walk_struct_field<'v, V: Visitor<'v>>(visitor: &mut V, struct_field: &'v
955955
walk_list!(visitor, visit_attribute, struct_field.attrs);
956956
}
957957

958-
pub fn walk_block<'v, V: Visitor<'v>>(visitor: &mut V, block: &'v Block) {
958+
pub fn walk_block<'v, V: Visitor<'v>>(visitor: &mut V, block: &'v Block<'v>) {
959959
visitor.visit_id(block.hir_id);
960-
walk_list!(visitor, visit_stmt, &block.stmts);
960+
walk_list!(visitor, visit_stmt, block.stmts);
961961
walk_list!(visitor, visit_expr, &block.expr);
962962
}
963963

964-
pub fn walk_stmt<'v, V: Visitor<'v>>(visitor: &mut V, statement: &'v Stmt) {
964+
pub fn walk_stmt<'v, V: Visitor<'v>>(visitor: &mut V, statement: &'v Stmt<'v>) {
965965
visitor.visit_id(statement.hir_id);
966966
match statement.kind {
967967
StmtKind::Local(ref local) => visitor.visit_local(local),
@@ -977,19 +977,19 @@ pub fn walk_anon_const<'v, V: Visitor<'v>>(visitor: &mut V, constant: &'v AnonCo
977977
visitor.visit_nested_body(constant.body);
978978
}
979979

980-
pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
980+
pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>) {
981981
visitor.visit_id(expression.hir_id);
982982
walk_list!(visitor, visit_attribute, expression.attrs.iter());
983983
match expression.kind {
984984
ExprKind::Box(ref subexpression) => visitor.visit_expr(subexpression),
985-
ExprKind::Array(ref subexpressions) => {
985+
ExprKind::Array(subexpressions) => {
986986
walk_list!(visitor, visit_expr, subexpressions);
987987
}
988988
ExprKind::Repeat(ref element, ref count) => {
989989
visitor.visit_expr(element);
990990
visitor.visit_anon_const(count)
991991
}
992-
ExprKind::Struct(ref qpath, ref fields, ref optional_base) => {
992+
ExprKind::Struct(ref qpath, fields, ref optional_base) => {
993993
visitor.visit_qpath(qpath, expression.hir_id, expression.span);
994994
for field in fields {
995995
visitor.visit_id(field.hir_id);
@@ -998,14 +998,14 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
998998
}
999999
walk_list!(visitor, visit_expr, optional_base);
10001000
}
1001-
ExprKind::Tup(ref subexpressions) => {
1001+
ExprKind::Tup(subexpressions) => {
10021002
walk_list!(visitor, visit_expr, subexpressions);
10031003
}
1004-
ExprKind::Call(ref callee_expression, ref arguments) => {
1004+
ExprKind::Call(ref callee_expression, arguments) => {
10051005
visitor.visit_expr(callee_expression);
10061006
walk_list!(visitor, visit_expr, arguments);
10071007
}
1008-
ExprKind::MethodCall(ref segment, _, ref arguments) => {
1008+
ExprKind::MethodCall(ref segment, _, arguments) => {
10091009
visitor.visit_path_segment(expression.span, segment);
10101010
walk_list!(visitor, visit_expr, arguments);
10111011
}
@@ -1027,7 +1027,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
10271027
walk_list!(visitor, visit_label, opt_label);
10281028
visitor.visit_block(block);
10291029
}
1030-
ExprKind::Match(ref subexpression, ref arms, _) => {
1030+
ExprKind::Match(ref subexpression, arms, _) => {
10311031
visitor.visit_expr(subexpression);
10321032
walk_list!(visitor, visit_arm, arms);
10331033
}
@@ -1077,8 +1077,8 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
10771077
walk_list!(visitor, visit_expr, optional_expression);
10781078
}
10791079
ExprKind::InlineAsm(ref asm) => {
1080-
walk_list!(visitor, visit_expr, &asm.outputs_exprs);
1081-
walk_list!(visitor, visit_expr, &asm.inputs_exprs);
1080+
walk_list!(visitor, visit_expr, asm.outputs_exprs);
1081+
walk_list!(visitor, visit_expr, asm.inputs_exprs);
10821082
}
10831083
ExprKind::Yield(ref subexpression, _) => {
10841084
visitor.visit_expr(subexpression);
@@ -1087,7 +1087,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
10871087
}
10881088
}
10891089

1090-
pub fn walk_arm<'v, V: Visitor<'v>>(visitor: &mut V, arm: &'v Arm) {
1090+
pub fn walk_arm<'v, V: Visitor<'v>>(visitor: &mut V, arm: &'v Arm<'v>) {
10911091
visitor.visit_id(arm.hir_id);
10921092
visitor.visit_pat(&arm.pat);
10931093
if let Some(ref g) = arm.guard {
@@ -1096,7 +1096,7 @@ pub fn walk_arm<'v, V: Visitor<'v>>(visitor: &mut V, arm: &'v Arm) {
10961096
}
10971097
}
10981098
visitor.visit_expr(&arm.body);
1099-
walk_list!(visitor, visit_attribute, &arm.attrs);
1099+
walk_list!(visitor, visit_attribute, arm.attrs);
11001100
}
11011101

11021102
pub fn walk_vis<'v, V: Visitor<'v>>(visitor: &mut V, vis: &'v Visibility) {

0 commit comments

Comments
 (0)