Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allocate HIR on an arena 2/4 -- Expr & Pat #66936

Merged
merged 7 commits into from
Dec 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/librustc/arena.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,25 @@ macro_rules! arena_types {

// HIR types
[few] hir_forest: rustc::hir::map::Forest<$tcx>,
[] arm: rustc::hir::Arm<$tcx>,
[] attribute: syntax::ast::Attribute,
[] block: rustc::hir::Block<$tcx>,
[few] global_asm: rustc::hir::GlobalAsm,
[] expr: rustc::hir::Expr<$tcx>,
[] field: rustc::hir::Field<$tcx>,
[] field_pat: rustc::hir::FieldPat<$tcx>,
[] fn_decl: rustc::hir::FnDecl,
[] foreign_item: rustc::hir::ForeignItem<$tcx>,
[] impl_item_ref: rustc::hir::ImplItemRef,
[] inline_asm: rustc::hir::InlineAsm<$tcx>,
[] local: rustc::hir::Local<$tcx>,
[few] macro_def: rustc::hir::MacroDef<$tcx>,
[] param: rustc::hir::Param,
[] param: rustc::hir::Param<$tcx>,
[] pat: rustc::hir::Pat<$tcx>,
[] path: rustc::hir::Path,
[] path_segment: rustc::hir::PathSegment,
[] qpath: rustc::hir::QPath,
[] stmt: rustc::hir::Stmt<$tcx>,
[] struct_field: rustc::hir::StructField<$tcx>,
[] trait_item_ref: rustc::hir::TraitItemRef,
[] ty: rustc::hir::Ty,
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/hir/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ impl CheckAttrVisitor<'tcx> {
.emit();
}

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

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

fn visit_stmt(&mut self, stmt: &'tcx hir::Stmt) {
fn visit_stmt(&mut self, stmt: &'tcx hir::Stmt<'tcx>) {
self.check_stmt_attributes(stmt);
intravisit::walk_stmt(self, stmt)
}

fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) {
self.check_expr_attributes(expr);
intravisit::walk_expr(self, expr)
}
Expand Down
60 changes: 30 additions & 30 deletions src/librustc/hir/intravisit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ pub trait Visitor<'v>: Sized {
}
}

fn visit_param(&mut self, param: &'v Param) {
fn visit_param(&mut self, param: &'v Param<'v>) {
walk_param(self, param)
}

Expand Down Expand Up @@ -253,25 +253,25 @@ pub trait Visitor<'v>: Sized {
fn visit_foreign_item(&mut self, i: &'v ForeignItem<'v>) {
walk_foreign_item(self, i)
}
fn visit_local(&mut self, l: &'v Local) {
fn visit_local(&mut self, l: &'v Local<'v>) {
walk_local(self, l)
}
fn visit_block(&mut self, b: &'v Block) {
fn visit_block(&mut self, b: &'v Block<'v>) {
walk_block(self, b)
}
fn visit_stmt(&mut self, s: &'v Stmt) {
fn visit_stmt(&mut self, s: &'v Stmt<'v>) {
walk_stmt(self, s)
}
fn visit_arm(&mut self, a: &'v Arm) {
fn visit_arm(&mut self, a: &'v Arm<'v>) {
walk_arm(self, a)
}
fn visit_pat(&mut self, p: &'v Pat) {
fn visit_pat(&mut self, p: &'v Pat<'v>) {
walk_pat(self, p)
}
fn visit_anon_const(&mut self, c: &'v AnonConst) {
walk_anon_const(self, c)
}
fn visit_expr(&mut self, ex: &'v Expr) {
fn visit_expr(&mut self, ex: &'v Expr<'v>) {
walk_expr(self, ex)
}
fn visit_ty(&mut self, t: &'v Ty) {
Expand Down Expand Up @@ -409,7 +409,7 @@ pub fn walk_body<'v, V: Visitor<'v>>(visitor: &mut V, body: &'v Body<'v>) {
visitor.visit_expr(&body.value);
}

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

pub fn walk_param<'v, V: Visitor<'v>>(visitor: &mut V, param: &'v Param) {
pub fn walk_param<'v, V: Visitor<'v>>(visitor: &mut V, param: &'v Param<'v>) {
visitor.visit_id(param.hir_id);
visitor.visit_pat(&param.pat);
walk_list!(visitor, visit_attribute, &param.attrs);
walk_list!(visitor, visit_attribute, param.attrs);
}

pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) {
Expand Down Expand Up @@ -684,26 +684,26 @@ pub fn walk_assoc_type_binding<'v, V: Visitor<'v>>(visitor: &mut V, type_binding
}
}

pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat) {
pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat<'v>) {
visitor.visit_id(pattern.hir_id);
match pattern.kind {
PatKind::TupleStruct(ref qpath, ref children, _) => {
PatKind::TupleStruct(ref qpath, children, _) => {
visitor.visit_qpath(qpath, pattern.hir_id, pattern.span);
walk_list!(visitor, visit_pat, children);
}
PatKind::Path(ref qpath) => {
visitor.visit_qpath(qpath, pattern.hir_id, pattern.span);
}
PatKind::Struct(ref qpath, ref fields, _) => {
PatKind::Struct(ref qpath, fields, _) => {
visitor.visit_qpath(qpath, pattern.hir_id, pattern.span);
for field in fields {
visitor.visit_id(field.hir_id);
visitor.visit_ident(field.ident);
visitor.visit_pat(&field.pat)
}
}
PatKind::Or(ref pats) => walk_list!(visitor, visit_pat, pats),
PatKind::Tuple(ref tuple_elements, _) => {
PatKind::Or(pats) => walk_list!(visitor, visit_pat, pats),
PatKind::Tuple(tuple_elements, _) => {
walk_list!(visitor, visit_pat, tuple_elements);
}
PatKind::Box(ref subpattern) | PatKind::Ref(ref subpattern, _) => {
Expand All @@ -719,7 +719,7 @@ pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat) {
visitor.visit_expr(upper_bound)
}
PatKind::Wild => (),
PatKind::Slice(ref prepatterns, ref slice_pattern, ref postpatterns) => {
PatKind::Slice(prepatterns, ref slice_pattern, postpatterns) => {
walk_list!(visitor, visit_pat, prepatterns);
walk_list!(visitor, visit_pat, slice_pattern);
walk_list!(visitor, visit_pat, postpatterns);
Expand Down Expand Up @@ -955,13 +955,13 @@ pub fn walk_struct_field<'v, V: Visitor<'v>>(visitor: &mut V, struct_field: &'v
walk_list!(visitor, visit_attribute, struct_field.attrs);
}

pub fn walk_block<'v, V: Visitor<'v>>(visitor: &mut V, block: &'v Block) {
pub fn walk_block<'v, V: Visitor<'v>>(visitor: &mut V, block: &'v Block<'v>) {
visitor.visit_id(block.hir_id);
walk_list!(visitor, visit_stmt, &block.stmts);
walk_list!(visitor, visit_stmt, block.stmts);
walk_list!(visitor, visit_expr, &block.expr);
}

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

pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>) {
visitor.visit_id(expression.hir_id);
walk_list!(visitor, visit_attribute, expression.attrs.iter());
match expression.kind {
ExprKind::Box(ref subexpression) => visitor.visit_expr(subexpression),
ExprKind::Array(ref subexpressions) => {
ExprKind::Array(subexpressions) => {
walk_list!(visitor, visit_expr, subexpressions);
}
ExprKind::Repeat(ref element, ref count) => {
visitor.visit_expr(element);
visitor.visit_anon_const(count)
}
ExprKind::Struct(ref qpath, ref fields, ref optional_base) => {
ExprKind::Struct(ref qpath, fields, ref optional_base) => {
visitor.visit_qpath(qpath, expression.hir_id, expression.span);
for field in fields {
visitor.visit_id(field.hir_id);
Expand All @@ -998,14 +998,14 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
}
walk_list!(visitor, visit_expr, optional_base);
}
ExprKind::Tup(ref subexpressions) => {
ExprKind::Tup(subexpressions) => {
walk_list!(visitor, visit_expr, subexpressions);
}
ExprKind::Call(ref callee_expression, ref arguments) => {
ExprKind::Call(ref callee_expression, arguments) => {
visitor.visit_expr(callee_expression);
walk_list!(visitor, visit_expr, arguments);
}
ExprKind::MethodCall(ref segment, _, ref arguments) => {
ExprKind::MethodCall(ref segment, _, arguments) => {
visitor.visit_path_segment(expression.span, segment);
walk_list!(visitor, visit_expr, arguments);
}
Expand All @@ -1027,7 +1027,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
walk_list!(visitor, visit_label, opt_label);
visitor.visit_block(block);
}
ExprKind::Match(ref subexpression, ref arms, _) => {
ExprKind::Match(ref subexpression, arms, _) => {
visitor.visit_expr(subexpression);
walk_list!(visitor, visit_arm, arms);
}
Expand Down Expand Up @@ -1077,8 +1077,8 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
walk_list!(visitor, visit_expr, optional_expression);
}
ExprKind::InlineAsm(ref asm) => {
walk_list!(visitor, visit_expr, &asm.outputs_exprs);
walk_list!(visitor, visit_expr, &asm.inputs_exprs);
walk_list!(visitor, visit_expr, asm.outputs_exprs);
walk_list!(visitor, visit_expr, asm.inputs_exprs);
}
ExprKind::Yield(ref subexpression, _) => {
visitor.visit_expr(subexpression);
Expand All @@ -1087,7 +1087,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
}
}

pub fn walk_arm<'v, V: Visitor<'v>>(visitor: &mut V, arm: &'v Arm) {
pub fn walk_arm<'v, V: Visitor<'v>>(visitor: &mut V, arm: &'v Arm<'v>) {
visitor.visit_id(arm.hir_id);
visitor.visit_pat(&arm.pat);
if let Some(ref g) = arm.guard {
Expand All @@ -1096,7 +1096,7 @@ pub fn walk_arm<'v, V: Visitor<'v>>(visitor: &mut V, arm: &'v Arm) {
}
}
visitor.visit_expr(&arm.body);
walk_list!(visitor, visit_attribute, &arm.attrs);
walk_list!(visitor, visit_attribute, arm.attrs);
}

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