diff options
99 files changed, 2062 insertions, 1972 deletions
diff --git a/src/librustc/cfg/construct.rs b/src/librustc/cfg/construct.rs index aab70456dc1..f1e27946915 100644 --- a/src/librustc/cfg/construct.rs +++ b/src/librustc/cfg/construct.rs @@ -111,13 +111,13 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { fn stmt(&mut self, stmt: &hir::Stmt, pred: CFGIndex) -> CFGIndex { let hir_id = self.tcx.hir.node_to_hir_id(stmt.node.id()); match stmt.node { - hir::StmtDecl(ref decl, _) => { + hir::StmtKind::Decl(ref decl, _) => { let exit = self.decl(&decl, pred); self.add_ast_node(hir_id.local_id, &[exit]) } - hir::StmtExpr(ref expr, _) | - hir::StmtSemi(ref expr, _) => { + hir::StmtKind::Expr(ref expr, _) | + hir::StmtKind::Semi(ref expr, _) => { let exit = self.expr(&expr, pred); self.add_ast_node(hir_id.local_id, &[exit]) } @@ -126,12 +126,12 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { fn decl(&mut self, decl: &hir::Decl, pred: CFGIndex) -> CFGIndex { match decl.node { - hir::DeclLocal(ref local) => { + hir::DeclKind::Local(ref local) => { let init_exit = self.opt_expr(&local.init, pred); self.pat(&local.pat, init_exit) } - hir::DeclItem(_) => pred, + hir::DeclKind::Item(_) => pred, } } @@ -179,12 +179,12 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { fn expr(&mut self, expr: &hir::Expr, pred: CFGIndex) -> CFGIndex { match expr.node { - hir::ExprBlock(ref blk, _) => { + hir::ExprKind::Block(ref blk, _) => { let blk_exit = self.block(&blk, pred); self.add_ast_node(expr.hir_id.local_id, &[blk_exit]) } - hir::ExprIf(ref cond, ref then, None) => { + hir::ExprKind::If(ref cond, ref then, None) => { // // [pred] // | @@ -204,7 +204,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { self.add_ast_node(expr.hir_id.local_id, &[cond_exit, then_exit]) // 3,4 } - hir::ExprIf(ref cond, ref then, Some(ref otherwise)) => { + hir::ExprKind::If(ref cond, ref then, Some(ref otherwise)) => { // // [pred] // | @@ -225,7 +225,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { self.add_ast_node(expr.hir_id.local_id, &[then_exit, else_exit]) // 4, 5 } - hir::ExprWhile(ref cond, ref body, _) => { + hir::ExprKind::While(ref cond, ref body, _) => { // // [pred] // | @@ -267,7 +267,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { expr_exit } - hir::ExprLoop(ref body, _, _) => { + hir::ExprKind::Loop(ref body, _, _) => { // // [pred] // | @@ -295,11 +295,11 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { expr_exit } - hir::ExprMatch(ref discr, ref arms, _) => { + hir::ExprKind::Match(ref discr, ref arms, _) => { self.match_(expr.hir_id.local_id, &discr, &arms, pred) } - hir::ExprBinary(op, ref l, ref r) if op.node.is_lazy() => { + hir::ExprKind::Binary(op, ref l, ref r) if op.node.is_lazy() => { // // [pred] // | @@ -319,14 +319,14 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { self.add_ast_node(expr.hir_id.local_id, &[l_exit, r_exit]) // 3,4 } - hir::ExprRet(ref v) => { + hir::ExprKind::Ret(ref v) => { let v_exit = self.opt_expr(v, pred); let b = self.add_ast_node(expr.hir_id.local_id, &[v_exit]); self.add_returning_edge(expr, b); self.add_unreachable_node() } - hir::ExprBreak(destination, ref opt_expr) => { + hir::ExprKind::Break(destination, ref opt_expr) => { let v = self.opt_expr(opt_expr, pred); let (target_scope, break_dest) = self.find_scope_edge(expr, destination, ScopeCfKind::Break); @@ -335,7 +335,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { self.add_unreachable_node() } - hir::ExprContinue(destination) => { + hir::ExprKind::Continue(destination) => { let (target_scope, cont_dest) = self.find_scope_edge(expr, destination, ScopeCfKind::Continue); let a = self.add_ast_node(expr.hir_id.local_id, &[pred]); @@ -343,66 +343,66 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { self.add_unreachable_node() } - hir::ExprArray(ref elems) => { + hir::ExprKind::Array(ref elems) => { self.straightline(expr, pred, elems.iter().map(|e| &*e)) } - hir::ExprCall(ref func, ref args) => { + hir::ExprKind::Call(ref func, ref args) => { self.call(expr, pred, &func, args.iter().map(|e| &*e)) } - hir::ExprMethodCall(.., ref args) => { + hir::ExprKind::MethodCall(.., ref args) => { self.call(expr, pred, &args[0], args[1..].iter().map(|e| &*e)) } - hir::ExprIndex(ref l, ref r) | - hir::ExprBinary(_, ref l, ref r) if self.tables.is_method_call(expr) => { + hir::ExprKind::Index(ref l, ref r) | + hir::ExprKind::Binary(_, ref l, ref r) if self.tables.is_method_call(expr) => { self.call(expr, pred, &l, Some(&**r).into_iter()) } - hir::ExprUnary(_, ref e) if self.tables.is_method_call(expr) => { + hir::ExprKind::Unary(_, ref e) if self.tables.is_method_call(expr) => { self.call(expr, pred, &e, None::<hir::Expr>.iter()) } - hir::ExprTup(ref exprs) => { + hir::ExprKind::Tup(ref exprs) => { self.straightline(expr, pred, exprs.iter().map(|e| &*e)) } - hir::ExprStruct(_, ref fields, ref base) => { + hir::ExprKind::Struct(_, ref fields, ref base) => { let field_cfg = self.straightline(expr, pred, fields.iter().map(|f| &*f.expr)); self.opt_expr(base, field_cfg) } - hir::ExprAssign(ref l, ref r) | - hir::ExprAssignOp(_, ref l, ref r) => { + hir::ExprKind::Assign(ref l, ref r) | + hir::ExprKind::AssignOp(_, ref l, ref r) => { self.straightline(expr, pred, [r, l].iter().map(|&e| &**e)) } - hir::ExprIndex(ref l, ref r) | - hir::ExprBinary(_, ref l, ref r) => { // NB: && and || handled earlier + hir::ExprKind::Index(ref l, ref r) | + hir::ExprKind::Binary(_, ref l, ref r) => { // NB: && and || handled earlier self.straightline(expr, pred, [l, r].iter().map(|&e| &**e)) } - hir::ExprBox(ref e) | - hir::ExprAddrOf(_, ref e) | - hir::ExprCast(ref e, _) | - hir::ExprType(ref e, _) | - hir::ExprUnary(_, ref e) | - hir::ExprField(ref e, _) | - hir::ExprYield(ref e) | - hir::ExprRepeat(ref e, _) => { + hir::ExprKind::Box(ref e) | + hir::ExprKind::AddrOf(_, ref e) | + hir::ExprKind::Cast(ref e, _) | + hir::ExprKind::Type(ref e, _) | + hir::ExprKind::Unary(_, ref e) | + hir::ExprKind::Field(ref e, _) | + hir::ExprKind::Yield(ref e) | + hir::ExprKind::Repeat(ref e, _) => { self.straightline(expr, pred, Some(&**e).into_iter()) } - hir::ExprInlineAsm(_, ref outputs, ref inputs) => { + hir::ExprKind::InlineAsm(_, ref outputs, ref inputs) => { let post_outputs = self.exprs(outputs.iter().map(|e| &*e), pred); let post_inputs = self.exprs(inputs.iter().map(|e| &*e), post_outputs); self.add_ast_node(expr.hir_id.local_id, &[post_inputs]) } - hir::ExprClosure(..) | - hir::ExprLit(..) | - hir::ExprPath(_) => { + hir::ExprKind::Closure(..) | + hir::ExprKind::Lit(..) | + hir::ExprKind::Path(_) => { self.straightline(expr, pred, None::<hir::Expr>.iter()) } } diff --git a/src/librustc/hir/check_attr.rs b/src/librustc/hir/check_attr.rs index 2d83c158fe0..3f6d34617c8 100644 --- a/src/librustc/hir/check_attr.rs +++ b/src/librustc/hir/check_attr.rs @@ -38,13 +38,13 @@ enum Target { impl Target { fn from_item(item: &hir::Item) -> Target { match item.node { - hir::ItemFn(..) => Target::Fn, - hir::ItemStruct(..) => Target::Struct, - hir::ItemUnion(..) => Target::Union, - hir::ItemEnum(..) => Target::Enum, - hir::ItemConst(..) => Target::Const, - hir::ItemForeignMod(..) => Target::ForeignMod, - hir::ItemStatic(..) => Target::Static, + hir::ItemKind::Fn(..) => Target::Fn, + hir::ItemKind::Struct(..) => Target::Struct, + hir::ItemKind::Union(..) => Target::Union, + hir::ItemKind::Enum(..) => Target::Enum, + hir::ItemKind::Const(..) => Target::Const, + hir::ItemKind::ForeignMod(..) => Target::ForeignMod, + hir::ItemKind::Static(..) => Target::Static, _ => Target::Other, } } @@ -264,7 +264,7 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> { fn check_stmt_attributes(&self, stmt: &hir::Stmt) { // When checking statements ignore expressions, they will be checked later - if let hir::Stmt_::StmtDecl(_, _) = stmt.node { + if let hir::StmtKind::Decl(_, _) = stmt.node { for attr in stmt.node.attrs() { if attr.check_name("inline") { self.check_inline(attr, &stmt.span, Target::Statement); @@ -283,7 +283,7 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> { fn check_expr_attributes(&self, expr: &hir::Expr) { let target = match expr.node { - hir::ExprClosure(..) => Target::Closure, + hir::ExprKind::Closure(..) => Target::Closure, _ => Target::Expression, }; for attr in expr.attrs.iter() { @@ -340,7 +340,7 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { } fn is_c_like_enum(item: &hir::Item) -> bool { - if let hir::ItemEnum(ref def, _) = item.node { + if let hir::ItemKind::Enum(ref def, _) = item.node { for variant in &def.variants { match variant.node.data { hir::VariantData::Unit(_) => { /* continue */ } diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index e2c0020db2f..2fefd2b3318 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -50,6 +50,7 @@ use super::itemlikevisit::DeepVisitor; use std::cmp; use std::u32; +use std::result::Result::Err; #[derive(Copy, Clone)] pub enum FnKind<'a> { @@ -462,23 +463,23 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) { visitor.visit_vis(&item.vis); visitor.visit_name(item.span, item.name); match item.node { - ItemExternCrate(orig_name) => { + ItemKind::ExternCrate(orig_name) => { visitor.visit_id(item.id); if let Some(orig_name) = orig_name { visitor.visit_name(item.span, orig_name); } } - ItemUse(ref path, _) => { + ItemKind::Use(ref path, _) => { visitor.visit_id(item.id); visitor.visit_path(path, item.id); } - ItemStatic(ref typ, _, body) | - ItemConst(ref typ, body) => { + ItemKind::Static(ref typ, _, body) | + ItemKind::Const(ref typ, body) => { visitor.visit_id(item.id); visitor.visit_ty(typ); visitor.visit_nested_body(body); } - ItemFn(ref declaration, header, ref generics, body_id) => { + ItemKind::Fn(ref declaration, header, ref generics, body_id) => { visitor.visit_fn(FnKind::ItemFn(item.name, generics, header, @@ -489,23 +490,23 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) { item.span, item.id) } - ItemMod(ref module) => { + ItemKind::Mod(ref module) => { // visit_mod() takes care of visiting the Item's NodeId visitor.visit_mod(module, item.span, item.id) } - ItemForeignMod(ref foreign_module) => { + ItemKind::ForeignMod(ref foreign_module) => { visitor.visit_id(item.id); walk_list!(visitor, visit_foreign_item, &foreign_module.items); } - ItemGlobalAsm(_) => { + ItemKind::GlobalAsm(_) => { visitor.visit_id(item.id); } - ItemTy(ref typ, ref type_parameters) => { + ItemKind::Ty(ref typ, ref type_parameters) => { visitor.visit_id(item.id); visitor.visit_ty(typ); visitor.visit_generics(type_parameters) } - ItemExistential(ExistTy {ref generics, ref bounds, impl_trait_fn}) => { + ItemKind::Existential(ExistTy {ref generics, ref bounds, impl_trait_fn}) => { visitor.visit_id(item.id); walk_generics(visitor, generics); walk_list!(visitor, visit_param_bound, bounds); @@ -513,31 +514,37 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) { visitor.visit_def_mention(Def::Fn(impl_trait_fn)) } } - ItemEnum(ref enum_definition, ref type_parameters) => { + ItemKind::Enum(ref enum_definition, ref type_parameters) => { visitor.visit_generics(type_parameters); // visit_enum_def() takes care of visiting the Item's NodeId visitor.visit_enum_def(enum_definition, type_parameters, item.id, item.span) } - ItemImpl(.., ref type_parameters, ref opt_trait_reference, ref typ, ref impl_item_refs) => { + ItemKind::Impl( + .., + ref type_parameters, + ref opt_trait_reference, + ref typ, + ref impl_item_refs + ) => { visitor.visit_id(item.id); visitor.visit_generics(type_parameters); walk_list!(visitor, visit_trait_ref, opt_trait_reference); visitor.visit_ty(typ); walk_list!(visitor, visit_impl_item_ref, impl_item_refs); } - ItemStruct(ref struct_definition, ref generics) | - ItemUnion(ref struct_definition, ref generics) => { + ItemKind::Struct(ref struct_definition, ref generics) | + ItemKind::Union(ref struct_definition, ref generics) => { visitor.visit_generics(generics); visitor.visit_id(item.id); visitor.visit_variant_data(struct_definition, item.name, generics, item.id, item.span); } - ItemTrait(.., ref generics, ref bounds, ref trait_item_refs) => { + ItemKind::Trait(.., ref generics, ref bounds, ref trait_item_refs) => { visitor.visit_id(item.id); visitor.visit_generics(generics); walk_list!(visitor, visit_param_bound, bounds); walk_list!(visitor, visit_trait_item_ref, trait_item_refs); } - ItemTraitAlias(ref generics, ref bounds) => { + ItemKind::TraitAlias(ref generics, ref bounds) => { visitor.visit_id(item.id); visitor.visit_generics(generics); walk_list!(visitor, visit_param_bound, bounds); @@ -576,41 +583,41 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) { visitor.visit_id(typ.id); match typ.node { - TySlice(ref ty) => { + TyKind::Slice(ref ty) => { visitor.visit_ty(ty) } - TyPtr(ref mutable_type) => { + TyKind::Ptr(ref mutable_type) => { visitor.visit_ty(&mutable_type.ty) } - TyRptr(ref lifetime, ref mutable_type) => { + TyKind::Rptr(ref lifetime, ref mutable_type) => { visitor.visit_lifetime(lifetime); visitor.visit_ty(&mutable_type.ty) } - TyNever => {}, - TyTup(ref tuple_element_types) => { + TyKind::Never => {}, + TyKind::Tup(ref tuple_element_types) => { walk_list!(visitor, visit_ty, tuple_element_types); } - TyBareFn(ref function_declaration) => { + TyKind::BareFn(ref function_declaration) => { walk_list!(visitor, visit_generic_param, &function_declaration.generic_params); visitor.visit_fn_decl(&function_declaration.decl); } - TyPath(ref qpath) => { + TyKind::Path(ref qpath) => { visitor.visit_qpath(qpath, typ.id, typ.span); } - TyArray(ref ty, ref length) => { + TyKind::Array(ref ty, ref length) => { visitor.visit_ty(ty); visitor.visit_anon_const(length) } - TyTraitObject(ref bounds, ref lifetime) => { + TyKind::TraitObject(ref bounds, ref lifetime) => { for bound in bounds { visitor.visit_poly_trait_ref(bound, TraitBoundModifier::None); } visitor.visit_lifetime(lifetime); } - TyTypeof(ref expression) => { + TyKind::Typeof(ref expression) => { visitor.visit_anon_const(expression) } - TyInfer | TyErr => {} + TyKind::Infer | TyKind::Err => {} } } @@ -709,15 +716,15 @@ pub fn walk_foreign_item<'v, V: Visitor<'v>>(visitor: &mut V, foreign_item: &'v visitor.visit_name(foreign_item.span, foreign_item.name); match foreign_item.node { - ForeignItemFn(ref function_declaration, ref param_names, ref generics) => { + ForeignItemKind::Fn(ref function_declaration, ref param_names, ref generics) => { visitor.visit_generics(generics); visitor.visit_fn_decl(function_declaration); for ¶m_name in param_names { visitor.visit_ident(param_name); } } - ForeignItemStatic(ref typ, _) => visitor.visit_ty(typ), - ForeignItemType => (), + ForeignItemKind::Static(ref typ, _) => visitor.visit_ty(typ), + ForeignItemKind::Type => (), } walk_list!(visitor, visit_attribute, &foreign_item.attrs); @@ -935,12 +942,12 @@ pub fn walk_block<'v, V: Visitor<'v>>(visitor: &mut V, block: &'v Block) { pub fn walk_stmt<'v, V: Visitor<'v>>(visitor: &mut V, statement: &'v Stmt) { match statement.node { - StmtDecl(ref declaration, id) => { + StmtKind::Decl(ref declaration, id) => { visitor.visit_id(id); visitor.visit_decl(declaration) } - StmtExpr(ref expression, id) | - StmtSemi(ref expression, id) => { + StmtKind::Expr(ref expression, id) | + StmtKind::Semi(ref expression, id) => { visitor.visit_id(id); visitor.visit_expr(expression) } @@ -949,8 +956,8 @@ pub fn walk_stmt<'v, V: Visitor<'v>>(visitor: &mut V, statement: &'v Stmt) { pub fn walk_decl<'v, V: Visitor<'v>>(visitor: &mut V, declaration: &'v Decl) { match declaration.node { - DeclLocal(ref local) => visitor.visit_local(local), - DeclItem(item) => visitor.visit_nested_item(item), + DeclKind::Local(ref local) => visitor.visit_local(local), + DeclKind::Item(item) => visitor.visit_nested_item(item), } } @@ -963,17 +970,17 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) { visitor.visit_id(expression.id); walk_list!(visitor, visit_attribute, expression.attrs.iter()); match expression.node { - ExprBox(ref subexpression) => { + ExprKind::Box(ref subexpression) => { visitor.visit_expr(subexpression) } - ExprArray(ref subexpressions) => { + ExprKind::Array(ref subexpressions) => { walk_list!(visitor, visit_expr, subexpressions); } - ExprRepeat(ref element, ref count) => { + ExprKind::Repeat(ref element, ref count) => { visitor.visit_expr(element); visitor.visit_anon_const(count) } - ExprStruct(ref qpath, ref fields, ref optional_base) => { + ExprKind::Struct(ref qpath, ref fields, ref optional_base) => { visitor.visit_qpath(qpath, expression.id, expression.span); for field in fields { visitor.visit_id(field.id); @@ -982,78 +989,78 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) { } walk_list!(visitor, visit_expr, optional_base); } - ExprTup(ref subexpressions) => { + ExprKind::Tup(ref subexpressions) => { walk_list!(visitor, visit_expr, subexpressions); } - ExprCall(ref callee_expression, ref arguments) => { + ExprKind::Call(ref callee_expression, ref arguments) => { visitor.visit_expr(callee_expression); walk_list!(visitor, visit_expr, arguments); } - ExprMethodCall(ref segment, _, ref arguments) => { + ExprKind::MethodCall(ref segment, _, ref arguments) => { visitor.visit_path_segment(expression.span, segment); walk_list!(visitor, visit_expr, arguments); } - ExprBinary(_, ref left_expression, ref right_expression) => { + ExprKind::Binary(_, ref left_expression, ref right_expression) => { visitor.visit_expr(left_expression); visitor.visit_expr(right_expression) } - ExprAddrOf(_, ref subexpression) | ExprUnary(_, ref subexpression) => { + ExprKind::AddrOf(_, ref subexpression) | ExprKind::Unary(_, ref subexpression) => { visitor.visit_expr(subexpression) } - ExprLit(_) => {} - ExprCast(ref subexpression, ref typ) | ExprType(ref subexpression, ref typ) => { + ExprKind::Lit(_) => {} + ExprKind::Cast(ref subexpression, ref typ) | ExprKind::Type(ref subexpression, ref typ) => { visitor.visit_expr(subexpression); visitor.visit_ty(typ) } - ExprIf(ref head_expression, ref if_block, ref optional_else) => { + ExprKind::If(ref head_expression, ref if_block, ref optional_else) => { visitor.visit_expr(head_expression); visitor.visit_expr(if_block); walk_list!(visitor, visit_expr, optional_else); } - ExprWhile(ref subexpression, ref block, ref opt_label) => { + ExprKind::While(ref subexpression, ref block, ref opt_label) => { walk_list!(visitor, visit_label, opt_label); visitor.visit_expr(subexpression); visitor.visit_block(block); } - ExprLoop(ref block, ref opt_label, _) => { + ExprKind::Loop(ref block, ref opt_label, _) => { walk_list!(visitor, visit_label, opt_label); visitor.visit_block(block); } - ExprMatch(ref subexpression, ref arms, _) => { + ExprKind::Match(ref subexpression, ref arms, _) => { visitor.visit_expr(subexpression); walk_list!(visitor, visit_arm, arms); } - ExprClosure(_, ref function_declaration, body, _fn_decl_span, _gen) => { + ExprKind::Closure(_, ref function_declaration, body, _fn_decl_span, _gen) => { visitor.visit_fn(FnKind::Closure(&expression.attrs), function_declaration, body, expression.span, expression.id) } - ExprBlock(ref block, ref opt_label) => { + ExprKind::Block(ref block, ref opt_label) => { walk_list!(visitor, visit_label, opt_label); visitor.visit_block(block); } - ExprAssign(ref left_hand_expression, ref right_hand_expression) => { + ExprKind::Assign(ref left_hand_expression, ref right_hand_expression) => { visitor.visit_expr(right_hand_expression); visitor.visit_expr(left_hand_expression) } - ExprAssignOp(_, ref left_expression, ref right_expression) => { + ExprKind::AssignOp(_, ref left_expression, ref right_expression) => { visitor.visit_expr(right_expression); visitor.visit_expr(left_expression) } - ExprField(ref subexpression, ident) => { + ExprKind::Field(ref subexpression, ident) => { visitor.visit_expr(subexpression); visitor.visit_ident(ident); } - ExprIndex(ref main_expression, ref index_expression) => { + ExprKind::Index(ref main_expression, ref index_expression) => { visitor.visit_expr(main_expression); visitor.visit_expr(index_expression) } - ExprPath(ref qpath) => { + ExprKind::Path(ref qpath) => { visitor.visit_qpath(qpath, expression.id, expression.span); } - ExprBreak(ref destination, ref opt_expr) => { + ExprKind::Break(ref destination, ref opt_expr) => { if let Some(ref label) = destination.label { visitor.visit_label(label); match destination.target_id { @@ -1063,7 +1070,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) { } walk_list!(visitor, visit_expr, opt_expr); } - ExprContinue(ref destination) => { + ExprKind::Continue(ref destination) => { if let Some(ref label) = destination.label { visitor.visit_label(label); match destination.target_id { @@ -1072,10 +1079,10 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) { }; } } - ExprRet(ref optional_expression) => { + ExprKind::Ret(ref optional_expression) => { walk_list!(visitor, visit_expr, optional_expression); } - ExprInlineAsm(_, ref outputs, ref inputs) => { + ExprKind::InlineAsm(_, ref outputs, ref inputs) => { for output in outputs { visitor.visit_expr(output) } @@ -1083,7 +1090,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) { visitor.visit_expr(input) } } - ExprYield(ref subexpression) => { + ExprKind::Yield(ref subexpression) => { visitor.visit_expr(subexpression); } } diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index cb53f963d41..722934ac39a 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -384,8 +384,8 @@ impl<'a> LoweringContext<'a> { if item_lowered { let item_generics = match self.lctx.items.get(&item.id).unwrap().node { - hir::Item_::ItemImpl(_, _, _, ref generics, ..) - | hir::Item_::ItemTrait(_, _, ref generics, ..) => { + hir::ItemKind::Impl(_, _, _, ref generics, ..) + | hir::ItemKind::Trait(_, _, ref generics, ..) => { generics.params.clone() } _ => HirVec::new(), @@ -853,7 +853,7 @@ impl<'a> LoweringContext<'a> { closure_node_id: NodeId, ret_ty: Option<&Ty>, body: impl FnOnce(&mut LoweringContext) -> hir::Expr, - ) -> hir::Expr_ { + ) -> hir::ExprKind { let prev_is_generator = mem::replace(&mut self.is_generator, true); let body_expr = body(self); let span = body_expr.span; @@ -875,7 +875,7 @@ impl<'a> LoweringContext<'a> { let generator = hir::Expr { id: closure_node_id, hir_id: closure_hir_id, - node: hir::ExprClosure(capture_clause, decl, body_id, span, + node: hir::ExprKind::Closure(capture_clause, decl, body_id, span, Some(hir::GeneratorMovability::Static)), span, attrs: ThinVec::new(), @@ -884,7 +884,7 @@ impl<'a> LoweringContext<'a> { let unstable_span = self.allow_internal_unstable(CompilerDesugaringKind::Async, span); let gen_future = self.expr_std_path( unstable_span, &["future", "from_generator"], None, ThinVec::new()); - hir::ExprCall(P(gen_future), hir_vec![generator]) + hir::ExprKind::Call(P(gen_future), hir_vec![generator]) } fn lower_body<F>(&mut self, decl: Option<&FnDecl>, f: F) -> hir::BodyId @@ -1080,17 +1080,17 @@ impl<'a> LoweringContext<'a> { fn lower_ty_direct(&mut self, t: &Ty, mut itctx: ImplTraitContext) -> hir::Ty { let kind = match t.node { - TyKind::Infer => hir::TyInfer, - TyKind::Err => hir::TyErr, - TyKind::Slice(ref ty) => hir::TySlice(self.lower_ty(ty, itctx)), - TyKind::Ptr(ref mt) => hir::TyPtr(self.lower_mt(mt, itctx)), + TyKind::Infer => hir::TyKind::Infer, + TyKind::Err => hir::TyKind::Err, + TyKind::Slice(ref ty) => hir::TyKind::Slice(self.lower_ty(ty, itctx)), + TyKind::Ptr(ref mt) => hir::TyKind::Ptr(self.lower_mt(mt, itctx)), TyKind::Rptr(ref region, ref mt) => { let span = t.span.shrink_to_lo(); let lifetime = match *region { Some(ref lt) => self.lower_lifetime(lt), None => self.elided_ref_lifetime(span), }; - hir::TyRptr(lifetime, self.lower_mt(mt, itctx)) + hir::TyKind::Rptr(lifetime, self.lower_mt(mt, itctx)) } TyKind::BareFn(ref f) => self.with_in_scope_lifetime_defs( &f.generic_params, @@ -1098,7 +1098,7 @@ impl<'a> LoweringContext<'a> { this.with_anonymous_lifetime_mode( AnonymousLifetimeMode::PassThrough, |this| { - hir::TyBareFn(P(hir::BareFnTy { + hir::TyKind::BareFn(P(hir::BareFnTy { generic_params: this.lower_generic_params( &f.generic_params, &NodeMap(), @@ -1113,9 +1113,9 @@ impl<'a> LoweringContext<'a> { ) }, ), - TyKind::Never => hir::TyNever, + TyKind::Never => hir::TyKind::Never, TyKind::Tup(ref tys) => { - hir::TyTup(tys.iter().map(|ty| { + hir::TyKind::Tup(tys.iter().map(|ty| { self.lower_ty_direct(ty, itctx.reborrow()) }).collect()) } @@ -1126,12 +1126,12 @@ impl<'a> LoweringContext<'a> { let id = self.lower_node_id(t.id); let qpath = self.lower_qpath(t.id, qself, path, ParamMode::Explicit, itctx); let ty = self.ty_path(id, t.span, qpath); - if let hir::TyTraitObject(..) = ty.node { + if let hir::TyKind::TraitObject(..) = ty.node { self.maybe_lint_bare_trait(t.span, t.id, qself.is_none() && path.is_global()); } return ty; } - TyKind::ImplicitSelf => hir::TyPath(hir::QPath::Resolved( + TyKind::ImplicitSelf => hir::TyKind::Path(hir::QPath::Resolved( None, P(hir::Path { def: self.expect_full_def(t.id), @@ -1140,10 +1140,10 @@ impl<'a> LoweringContext<'a> { }), )), TyKind::Array(ref ty, ref length) => { - hir::TyArray(self.lower_ty(ty, itctx), self.lower_anon_const(length)) + hir::TyKind::Array(self.lower_ty(ty, itctx), self.lower_anon_const(length)) } TyKind::Typeof(ref expr) => { - hir::TyTypeof(self.lower_anon_const(expr)) + hir::TyKind::Typeof(self.lower_anon_const(expr)) } TyKind::TraitObject(ref bounds, kind) => { let mut lifetime_bound = None; @@ -1167,7 +1167,7 @@ impl<'a> LoweringContext<'a> { if kind != TraitObjectSyntax::Dyn { self.maybe_lint_bare_trait(t.span, t.id, false); } - hir::TyTraitObject(bounds, lifetime_bound) + hir::TyKind::TraitObject(bounds, lifetime_bound) } TyKind::ImplTrait(def_node_id, ref bounds) => { let span = t.span; @@ -1206,7 +1206,7 @@ impl<'a> LoweringContext<'a> { } }); - hir::TyPath(hir::QPath::Resolved( + hir::TyKind::Path(hir::QPath::Resolved( None, P(hir::Path { span, @@ -1223,7 +1223,7 @@ impl<'a> LoweringContext<'a> { "`impl Trait` not allowed outside of function \ and inherent method return types" ); - hir::TyErr + hir::TyKind::Err } } } @@ -1245,7 +1245,7 @@ impl<'a> LoweringContext<'a> { fn_def_id: DefId, exist_ty_node_id: NodeId, lower_bounds: impl FnOnce(&mut LoweringContext) -> hir::GenericBounds, - ) -> hir::Ty_ { + ) -> hir::TyKind { // Make sure we know that some funky desugaring has been going on here. // This is a first: there is code in other places like for loop // desugaring that explicitly states that we don't want to track that. @@ -1274,7 +1274,7 @@ impl<'a> LoweringContext<'a> { ); self.with_hir_id_owner(exist_ty_node_id, |lctx| { - let exist_ty_item_kind = hir::ItemExistential(hir::ExistTy { + let exist_ty_item_kind = hir::ItemKind::Existential(hir::ExistTy { generics: hir::Generics { params: lifetime_defs, where_clause: hir::WhereClause { @@ -1320,7 +1320,7 @@ impl<'a> LoweringContext<'a> { })) }], }); - hir::TyPath(hir::QPath::Resolved(None, path)) + hir::TyKind::Path(hir::QPath::Resolved(None, path)) }) } @@ -1365,7 +1365,7 @@ impl<'a> LoweringContext<'a> { fn visit_ty(&mut self, t: &'v hir::Ty) { // Don't collect elided lifetimes used inside of `fn()` syntax - if let hir::Ty_::TyBareFn(_) = t.node { + if let hir::TyKind::BareFn(_) = t.node { let old_collect_elided_lifetimes = self.collect_elided_lifetimes; self.collect_elided_lifetimes = false; @@ -1507,7 +1507,7 @@ impl<'a> LoweringContext<'a> { fn lower_variant(&mut self, v: &Variant) -> hir::Variant { Spanned { - node: hir::Variant_ { + node: hir::VariantKind { name: v.node.ident.name, attrs: self.lower_attrs(&v.node.attrs), data: self.lower_variant_data(&v.node.data), @@ -1805,7 +1805,7 @@ impl<'a> LoweringContext<'a> { let inputs = inputs.iter().map(|ty| this.lower_ty_direct(ty, DISALLOWED)).collect(); let mk_tup = |this: &mut Self, tys, span| { let LoweredNodeId { node_id, hir_id } = this.next_id(); - hir::Ty { node: hir::TyTup(tys), id: node_id, hir_id, span } + hir::Ty { node: hir::TyKind::Tup(tys), id: node_id, hir_id, span } }; ( @@ -1985,7 +1985,7 @@ impl<'a> LoweringContext<'a> { fn visit_ty(&mut self, t: &'v hir::Ty) { // Don't collect elided lifetimes used inside of `fn()` syntax - if let &hir::Ty_::TyBareFn(_) = &t.node { + if let &hir::TyKind::BareFn(_) = &t.node { let old_collect_elided_lifetimes = self.collect_elided_lifetimes; self.collect_elided_lifetimes = false; @@ -2105,7 +2105,7 @@ impl<'a> LoweringContext<'a> { P(hir::Ty { id: node_id, hir_id: hir_id, - node: hir::TyTup(hir_vec![]), + node: hir::TyKind::Tup(hir_vec![]), span: *span, }) } @@ -2575,9 +2575,9 @@ impl<'a> LoweringContext<'a> { attrs: &hir::HirVec<Attribute>, vis: &mut hir::Visibility, i: &ItemKind, - ) -> hir::Item_ { + ) -> hir::ItemKind { match *i { - ItemKind::ExternCrate(orig_name) => hir::ItemExternCrate(orig_name), + ItemKind::ExternCrate(orig_name) => hir::ItemKind::ExternCrate(orig_name), ItemKind::Use(ref use_tree) => { // Start with an empty prefix let prefix = Path { @@ -2589,7 +2589,7 @@ impl<'a> LoweringContext<'a> { } ItemKind::Static(ref t, m, ref e) => { let value = self.lower_body(None, |this| this.lower_expr(e)); - hir::ItemStatic( + hir::ItemKind::Static( self.lower_ty(t, ImplTraitContext::Disallowed), self.lower_mutability(m), value, @@ -2597,7 +2597,7 @@ impl<'a> LoweringContext<'a> { } ItemKind::Const(ref t, ref e) => { let value = self.lower_body(None, |this| this.lower_expr(e)); - hir::ItemConst(self.lower_ty(t, ImplTraitContext::Disallowed), value) + hir::ItemKind::Const(self.lower_ty(t, ImplTraitContext::Disallowed), value) } ItemKind::Fn(ref decl, header, ref generics, ref body) => { let fn_def_id = self.resolver.definitions().local_def_id(id); @@ -2617,7 +2617,7 @@ impl<'a> LoweringContext<'a> { decl, Some((fn_def_id, idty)), true, header.asyncness.opt_return_id()), ); - hir::ItemFn( + hir::ItemKind::Fn( fn_decl, this.lower_fn_header(header), generics, @@ -2625,14 +2625,14 @@ impl<'a> LoweringContext<'a> { ) }) } - ItemKind::Mod(ref m) => hir::ItemMod(self.lower_mod(m)), - ItemKind::ForeignMod(ref nm) => hir::ItemForeignMod(self.lower_foreign_mod(nm)), - ItemKind::GlobalAsm(ref ga) => hir::ItemGlobalAsm(self.lower_global_asm(ga)), - ItemKind::Ty(ref t, ref generics) => hir::ItemTy( + ItemKind::Mod(ref m) => hir::ItemKind::Mod(self.lower_mod(m)), + ItemKind::ForeignMod(ref nm) => hir::ItemKind::ForeignMod(self.lower_foreign_mod(nm)), + ItemKind::GlobalAsm(ref ga) => hir::ItemKind::GlobalAsm(self.lower_global_asm(ga)), + ItemKind::Ty(ref t, ref generics) => hir::ItemKind::Ty( self.lower_ty(t, ImplTraitContext::Disallowed), self.lower_generics(generics, ImplTraitContext::Disallowed), ), - ItemKind::Enum(ref enum_definition, ref generics) => hir::ItemEnum( + ItemKind::Enum(ref enum_definition, ref generics) => hir::ItemKind::Enum( hir::EnumDef { variants: enum_definition .variants @@ -2644,14 +2644,14 @@ impl<'a> LoweringContext<'a> { ), ItemKind::Struct(ref struct_def, ref generics) => { let struct_def = self.lower_variant_data(struct_def); - hir::ItemStruct( + hir::ItemKind::Struct( struct_def, self.lower_generics(generics, ImplTraitContext::Disallowed), ) } ItemKind::Union(ref vdata, ref generics) => { let vdata = self.lower_variant_data(vdata); - hir::ItemUnion( + hir::ItemKind::Union( vdata, self.lower_generics(generics, ImplTraitContext::Disallowed), ) @@ -2711,7 +2711,7 @@ impl<'a> LoweringContext<'a> { }, ); - hir::ItemImpl( + hir::ItemKind::Impl( self.lower_unsafety(unsafety), self.lower_impl_polarity(polarity), self.lower_defaultness(defaultness, true /* [1] */), @@ -2727,7 +2727,7 @@ impl<'a> LoweringContext<'a> { .iter() .map(|item| self.lower_trait_item_ref(item)) .collect(); - hir::ItemTrait( + hir::ItemKind::Trait( self.lower_is_auto(is_auto), self.lower_unsafety(unsafety), self.lower_generics(generics, ImplTraitContext::Disallowed), @@ -2735,7 +2735,7 @@ impl<'a> LoweringContext<'a> { items, ) } - ItemKind::TraitAlias(ref generics, ref bounds) => hir::ItemTraitAlias( + ItemKind::TraitAlias(ref generics, ref bounds) => hir::ItemKind::TraitAlias( self.lower_generics(generics, ImplTraitContext::Disallowed), self.lower_param_bounds(bounds, ImplTraitContext::Disallowed), ), @@ -2754,7 +2754,7 @@ impl<'a> LoweringContext<'a> { vis: &mut hir::Visibility, name: &mut Name, attrs: &hir::HirVec<Attribute>, - ) -> hir::Item_ { + ) -> hir::ItemKind { let path = &tree.prefix; match tree.kind { @@ -2804,7 +2804,7 @@ impl<'a> LoweringContext<'a> { self.with_hir_id_owner(new_node_id, |this| { let new_id = this.lower_node_id(new_node_id); let path = this.lower_path_extra(def, &path, None, ParamMode::Explicit); - let item = hir::ItemUse(P(path), hir::UseKind::Single); + let item = hir::ItemKind::Use(P(path), hir::UseKind::Single); let vis_kind = match vis.node { hir::VisibilityKind::Public => hir::VisibilityKind::Public, hir::VisibilityKind::Crate(sugar) => hir::VisibilityKind::Crate(sugar), @@ -2835,7 +2835,7 @@ impl<'a> LoweringContext<'a> { } let path = P(self.lower_path_extra(ret_def, &path, None, ParamMode::Explicit)); - hir::ItemUse(path, hir::UseKind::Single) + hir::ItemKind::Use(path, hir::UseKind::Single) } UseTreeKind::Glob => { let path = P(self.lower_path( @@ -2851,7 +2851,7 @@ impl<'a> LoweringContext<'a> { }, ParamMode::Explicit, )); - hir::ItemUse(path, hir::UseKind::Glob) + hir::ItemKind::Use(path, hir::UseKind::Glob) } UseTreeKind::Nested(ref trees) => { let prefix = Path { @@ -2912,7 +2912,7 @@ impl<'a> LoweringContext<'a> { // a re-export by accident when `pub`, e.g. in documentation. let path = P(self.lower_path(id, &prefix, ParamMode::Explicit)); *vis = respan(prefix.span.shrink_to_lo(), hir::VisibilityKind::Inherited); - hir::ItemUse(path, hir::UseKind::ListStem) + hir::ItemKind::Use(path, hir::UseKind::ListStem) } } } @@ -3230,12 +3230,12 @@ impl<'a> LoweringContext<'a> { }, ); - hir::ForeignItemFn(fn_dec, fn_args, generics) + hir::ForeignItemKind::Fn(fn_dec, fn_args, generics) } ForeignItemKind::Static(ref t, m) => { - hir::ForeignItemStatic(self.lower_ty(t, ImplTraitContext::Disallowed), m) + hir::ForeignItemKind::Static(self.lower_ty(t, ImplTraitContext::Disallowed), m) } - ForeignItemKind::Ty => hir::ForeignItemType, + ForeignItemKind::Ty => hir::ForeignItemKind::Type, ForeignItemKind::Macro(_) => panic!("shouldn't exist here"), }, vis: self.lower_visibility(&i.vis, None), @@ -3314,24 +3314,24 @@ impl<'a> LoweringContext<'a> { fn lower_binop(&mut self, b: BinOp) -> hir::BinOp { Spanned { node: match b.node { - BinOpKind::Add => hir::BiAdd, - BinOpKind::Sub => hir::BiSub, - BinOpKind::Mul => hir::BiMul, - BinOpKind::Div => hir::BiDiv, - BinOpKind::Rem => hir::BiRem, - BinOpKind::And => hir::BiAnd, - BinOpKind::Or => hir::BiOr, - BinOpKind::BitXor => hir::BiBitXor, - BinOpKind::BitAnd => hir::BiBitAnd, - BinOpKind::BitOr => hir::BiBitOr, - BinOpKind::Shl => hir::BiShl, - BinOpKind::Shr => hir::BiShr, - BinOpKind::Eq => hir::BiEq, - BinOpKind::Lt => hir::BiLt, - BinOpKind::Le => hir::BiLe, - BinOpKind::Ne => hir::BiNe, - BinOpKind::Ge => hir::BiGe, - BinOpKind::Gt => hir::BiGt, + BinOpKind::Add => hir::BinOpKind::Add, + BinOpKind::Sub => hir::BinOpKind::Sub, + BinOpKind::Mul => hir::BinOpKind::Mul, + BinOpKind::Div => hir::BinOpKind::Div, + BinOpKind::Rem => hir::BinOpKind::Rem, + BinOpKind::And => hir::BinOpKind::And, + BinOpKind::Or => hir::BinOpKind::Or, + BinOpKind::BitXor => hir::BinOpKind::BitXor, + BinOpKind::BitAnd => hir::BinOpKind::BitAnd, + BinOpKind::BitOr => hir::BinOpKind::BitOr, + BinOpKind::Shl => hir::BinOpKind::Shl, + BinOpKind::Shr => hir::BinOpKind::Shr, + BinOpKind::Eq => hir::BinOpKind::Eq, + BinOpKind::Lt => hir::BinOpKind::Lt, + BinOpKind::Le => hir::BinOpKind::Le, + BinOpKind::Ne => hir::BinOpKind::Ne, + BinOpKind::Ge => hir::BinOpKind::Ge, + BinOpKind::Gt => hir::BinOpKind::Gt, }, span: b.span, } @@ -3468,25 +3468,25 @@ impl<'a> LoweringContext<'a> { fn lower_expr(&mut self, e: &Expr) -> hir::Expr { let kind = match e.node { - ExprKind::Box(ref inner) => hir::ExprBox(P(self.lower_expr(inner))), + ExprKind::Box(ref inner) => hir::ExprKind::Box(P(self.lower_expr(inner))), ExprKind::ObsoleteInPlace(..) => { self.sess.abort_if_errors(); span_bug!(e.span, "encountered ObsoleteInPlace expr during lowering"); } ExprKind::Array(ref exprs) => { - hir::ExprArray(exprs.iter().map(|x| self.lower_expr(x)).collect()) + hir::ExprKind::Array(exprs.iter().map(|x| self.lower_expr(x)).collect()) } ExprKind::Repeat(ref expr, ref count) => { let expr = P(self.lower_expr(expr)); let count = self.lower_anon_const(count); - hir::ExprRepeat(expr, count) + hir::ExprKind::Repeat(expr, count) } ExprKind::Tup(ref elts) => { - hir::ExprTup(elts.iter().map(|x| self.lower_expr(x)).collect()) + hir::ExprKind::Tup(elts.iter().map(|x| self.lower_expr(x)).collect()) } ExprKind::Call(ref f, ref args) => { let f = P(self.lower_expr(f)); - hir::ExprCall(f, args.iter().map(|x| self.lower_expr(x)).collect()) + hir::ExprKind::Call(f, args.iter().map(|x| self.lower_expr(x)).collect()) } ExprKind::MethodCall(ref seg, ref args) => { let hir_seg = self.lower_path_segment( @@ -3498,32 +3498,32 @@ impl<'a> LoweringContext<'a> { ImplTraitContext::Disallowed, ); let args = args.iter().map(|x| self.lower_expr(x)).collect(); - hir::ExprMethodCall(hir_seg, seg.ident.span, args) + hir::ExprKind::MethodCall(hir_seg, seg.ident.span, args) } ExprKind::Binary(binop, ref lhs, ref rhs) => { let binop = self.lower_binop(binop); let lhs = P(self.lower_expr(lhs)); let rhs = P(self.lower_expr(rhs)); - hir::ExprBinary(binop, lhs, rhs) + hir::ExprKind::Binary(binop, lhs, rhs) } ExprKind::Unary(op, ref ohs) => { let op = self.lower_unop(op); let ohs = P(self.lower_expr(ohs)); - hir::ExprUnary(op, ohs) + hir::ExprKind::Unary(op, ohs) } - ExprKind::Lit(ref l) => hir::ExprLit(P((**l).clone())), + ExprKind::Lit(ref l) => hir::ExprKind::Lit(P((**l).clone())), ExprKind::Cast(ref expr, ref ty) => { let expr = P(self.lower_expr(expr)); - hir::ExprCast(expr, self.lower_ty(ty, ImplTraitContext::Disallowed)) + hir::ExprKind::Cast(expr, self.lower_ty(ty, ImplTraitContext::Disallowed)) } ExprKind::Type(ref expr, ref ty) => { let expr = P(self.lower_expr(expr)); - hir::ExprType(expr, self.lower_ty(ty, ImplTraitContext::Disallowed)) + hir::ExprKind::Type(expr, self.lower_ty(ty, ImplTraitContext::Disallowed)) } ExprKind::AddrOf(m, ref ohs) => { let m = self.lower_mutability(m); let ohs = P(self.lower_expr(ohs)); - hir::ExprAddrOf(m, ohs) + hir::ExprKind::AddrOf(m, ohs) } // More complicated than you might expect because the else branch // might be `if let`. @@ -3554,17 +3554,17 @@ impl<'a> LoweringContext<'a> { let then_blk = self.lower_block(blk, false); let then_expr = self.expr_block(then_blk, ThinVec::new()); - hir::ExprIf(P(self.lower_expr(cond)), P(then_expr), else_opt) + hir::ExprKind::If(P(self.lower_expr(cond)), P(then_expr), else_opt) } ExprKind::While(ref cond, ref body, opt_label) => self.with_loop_scope(e.id, |this| { - hir::ExprWhile( + hir::ExprKind::While( this.with_loop_condition_scope(|this| P(this.lower_expr(cond))), this.lower_block(body, false), this.lower_label(opt_label), ) }), ExprKind::Loop(ref body, opt_label) => self.with_loop_scope(e.id, |this| { - hir::ExprLoop( + hir::ExprKind::Loop( this.lower_block(body, false), this.lower_label(opt_label), hir::LoopSource::Loop, @@ -3582,7 +3582,7 @@ impl<'a> LoweringContext<'a> { hir::Expr { id: node_id, span, - node: hir::ExprTup(hir_vec![]), + node: hir::ExprKind::Tup(hir_vec![]), attrs: ThinVec::new(), hir_id, } @@ -3591,10 +3591,10 @@ impl<'a> LoweringContext<'a> { ); block.expr = Some(this.wrap_in_try_constructor( "from_ok", tail, unstable_span)); - hir::ExprBlock(P(block), None) + hir::ExprKind::Block(P(block), None) }) } - ExprKind::Match(ref expr, ref arms) => hir::ExprMatch( + ExprKind::Match(ref expr, ref arms) => hir::ExprKind::Match( P(self.lower_expr(expr)), arms.iter().map(|x| self.lower_arm(x)).collect(), hir::MatchSource::Normal, @@ -3652,7 +3652,7 @@ impl<'a> LoweringContext<'a> { }); this.expr(fn_decl_span, async_body, ThinVec::new()) }); - hir::ExprClosure( + hir::ExprKind::Closure( this.lower_capture_clause(capture_clause), fn_decl, body_id, @@ -3696,7 +3696,7 @@ impl<'a> LoweringContext<'a> { } None }; - hir::ExprClosure( + hir::ExprKind::Closure( this.lower_capture_clause(capture_clause), fn_decl, body_id, @@ -3707,21 +3707,21 @@ impl<'a> LoweringContext<'a> { } } ExprKind::Block(ref blk, opt_label) => { - hir::ExprBlock(self.lower_block(blk, + hir::ExprKind::Block(self.lower_block(blk, opt_label.is_some()), self.lower_label(opt_label)) } ExprKind::Assign(ref el, ref er) => { - hir::ExprAssign(P(self.lower_expr(el)), P(self.lower_expr(er))) + hir::ExprKind::Assign(P(self.lower_expr(el)), P(self.lower_expr(er))) } - ExprKind::AssignOp(op, ref el, ref er) => hir::ExprAssignOp( + ExprKind::AssignOp(op, ref el, ref er) => hir::ExprKind::AssignOp( self.lower_binop(op), P(self.lower_expr(el)), P(self.lower_expr(er)), ), - ExprKind::Field(ref el, ident) => hir::ExprField(P(self.lower_expr(el)), ident), + ExprKind::Field(ref el, ident) => hir::ExprKind::Field(P(self.lower_expr(el)), ident), ExprKind::Index(ref el, ref er) => { - hir::ExprIndex(P(self.lower_expr(el)), P(self.lower_expr(er))) + hir::ExprKind::Index(P(self.lower_expr(el)), P(self.lower_expr(er))) } // Desugar `<start>..=<end>` to `std::ops::RangeInclusive::new(<start>, <end>)` ExprKind::Range(Some(ref e1), Some(ref e2), RangeLimits::Closed) => { @@ -3734,8 +3734,8 @@ impl<'a> LoweringContext<'a> { let ty = P(self.ty_path(id, span, hir::QPath::Resolved(None, ty_path))); let new_seg = P(hir::PathSegment::from_ident(Ident::from_str("new"))); let new_path = hir::QPath::TypeRelative(ty, new_seg); - let new = P(self.expr(span, hir::ExprPath(new_path), ThinVec::new())); - hir::ExprCall(new, hir_vec![e1, e2]) + let new = P(self.expr(span, hir::ExprKind::Path(new_path), ThinVec::new())); + hir::ExprKind::Call(new, hir_vec![e1, e2]) } ExprKind::Range(ref e1, ref e2, lims) => { use syntax::ast::RangeLimits::*; @@ -3779,15 +3779,15 @@ impl<'a> LoweringContext<'a> { id: node_id, hir_id, node: if is_unit { - hir::ExprPath(struct_path) + hir::ExprKind::Path(struct_path) } else { - hir::ExprStruct(struct_path, fields, None) + hir::ExprKind::Struct(struct_path, fields, None) }, span: unstable_span, attrs: e.attrs.clone(), }; } - ExprKind::Path(ref qself, ref path) => hir::ExprPath(self.lower_qpath( + ExprKind::Path(ref qself, ref path) => hir::ExprKind::Path(self.lower_qpath( e.id, qself, path, @@ -3803,13 +3803,13 @@ impl<'a> LoweringContext<'a> { } else { self.lower_loop_destination(opt_label.map(|label| (e.id, label))) }; - hir::ExprBreak( + hir::ExprKind::Break( destination, opt_expr.as_ref().map(|x| P(self.lower_expr(x))), ) } ExprKind::Continue(opt_label) => { - hir::ExprContinue(if self.is_in_loop_condition && opt_label.is_none() { + hir::ExprKind::Continue(if self.is_in_loop_condition && opt_label.is_none() { hir::Destination { label: None, target_id: Err(hir::LoopIdError::UnlabeledCfInWhileCondition).into(), @@ -3818,7 +3818,7 @@ impl<'a> LoweringContext<'a> { self.lower_loop_destination(opt_label.map(|label| (e.id, label))) }) } - ExprKind::Ret(ref e) => hir::ExprRet(e.as_ref().map(|x| P(self.lower_expr(x)))), + ExprKind::Ret(ref e) => hir::ExprKind::Ret(e.as_ref().map(|x| P(self.lower_expr(x)))), ExprKind::InlineAsm(ref asm) => { let hir_asm = hir::InlineAsm { inputs: asm.inputs.iter().map(|&(ref c, _)| c.clone()).collect(), @@ -3846,9 +3846,9 @@ impl<'a> LoweringContext<'a> { .iter() .map(|&(_, ref input)| self.lower_expr(input)) .collect(); - hir::ExprInlineAsm(P(hir_asm), outputs, inputs) + hir::ExprKind::InlineAsm(P(hir_asm), outputs, inputs) } - ExprKind::Struct(ref path, ref fields, ref maybe_expr) => hir::ExprStruct( + ExprKind::Struct(ref path, ref fields, ref maybe_expr) => hir::ExprKind::Struct( self.lower_qpath( e.id, &None, @@ -3877,8 +3877,10 @@ impl<'a> LoweringContext<'a> { let expr = opt_expr .as_ref() .map(|x| self.lower_expr(x)) - .unwrap_or_else(|| self.expr(e.span, hir::ExprTup(hir_vec![]), ThinVec::new())); - hir::ExprYield(P(expr)) + .unwrap_or_else(|| + self.expr(e.span, hir::ExprKind::Tup(hir_vec![]), ThinVec::new()) + ); + hir::ExprKind::Yield(P(expr)) } // Desugar ExprIfLet @@ -3917,7 +3919,7 @@ impl<'a> LoweringContext<'a> { let sub_expr = P(self.lower_expr(sub_expr)); - hir::ExprMatch( + hir::ExprKind::Match( sub_expr, arms.into(), hir::MatchSource::IfLetDesugar { @@ -3965,13 +3967,13 @@ impl<'a> LoweringContext<'a> { let arms = hir_vec![pat_arm, break_arm]; let match_expr = self.expr( sub_expr.span, - hir::ExprMatch(sub_expr, arms, hir::MatchSource::WhileLetDesugar), + hir::ExprKind::Match(sub_expr, arms, hir::MatchSource::WhileLetDesugar), ThinVec::new(), ); // `[opt_ident]: loop { ... }` let loop_block = P(self.block_expr(P(match_expr))); - let loop_expr = hir::ExprLoop( + let loop_expr = hir::ExprKind::Loop( loop_block, self.lower_label(opt_label), hir::LoopSource::WhileLet, @@ -3995,7 +3997,7 @@ impl<'a> LoweringContext<'a> { // ::std::option::Option::None => break // }; // let <pat> = __next; - // StmtExpr(<body>); + // StmtKind::Expr(<body>); // } // } // }; @@ -4023,7 +4025,7 @@ impl<'a> LoweringContext<'a> { let next_expr = P(self.expr_ident(pat.span, next_ident, next_pat.id)); let assign = P(self.expr( pat.span, - hir::ExprAssign(next_expr, val_expr), + hir::ExprKind::Assign(next_expr, val_expr), ThinVec::new(), )); let some_pat = self.pat_some(pat.span, val_pat); @@ -4053,11 +4055,18 @@ impl<'a> LoweringContext<'a> { P(self.expr( head_sp, - hir::ExprMatch(next_expr, arms, hir::MatchSource::ForLoopDesugar), + hir::ExprKind::Match( + next_expr, + arms, + hir::MatchSource::ForLoopDesugar + ), ThinVec::new(), )) }; - let match_stmt = respan(head_sp, hir::StmtExpr(match_expr, self.next_id().node_id)); + let match_stmt = respan( + head_sp, + hir::StmtKind::Expr(match_expr, self.next_id().node_id) + ); let next_expr = P(self.expr_ident(head_sp, next_ident, next_pat.id)); @@ -4076,7 +4085,10 @@ impl<'a> LoweringContext<'a> { let body_block = self.with_loop_scope(e.id, |this| this.lower_block(body, false)); let body_expr = P(self.expr_block(body_block, ThinVec::new())); - let body_stmt = respan(body.span, hir::StmtExpr(body_expr, self.next_id().node_id)); + let body_stmt = respan( + body.span, + hir::StmtKind::Expr(body_expr, self.next_id().node_id) + ); let loop_block = P(self.block_all( e.span, @@ -4085,7 +4097,7 @@ impl<'a> LoweringContext<'a> { )); // `[opt_ident]: loop { ... }` - let loop_expr = hir::ExprLoop( + let loop_expr = hir::ExprKind::Loop( loop_block, self.lower_label(opt_label), hir::LoopSource::ForLoop, @@ -4205,7 +4217,7 @@ impl<'a> LoweringContext<'a> { let ret_expr = if let Some(catch_node) = catch_scope { P(self.expr( e.span, - hir::ExprBreak( + hir::ExprKind::Break( hir::Destination { label: None, target_id: Ok(catch_node), @@ -4215,14 +4227,14 @@ impl<'a> LoweringContext<'a> { thin_attrs, )) } else { - P(self.expr(e.span, hir::Expr_::ExprRet(Some(from_err_expr)), thin_attrs)) + P(self.expr(e.span, hir::ExprKind::Ret(Some(from_err_expr)), thin_attrs)) }; let err_pat = self.pat_err(e.span, err_local); self.arm(hir_vec![err_pat], ret_expr) }; - hir::ExprMatch( + hir::ExprKind::Match( discr, hir_vec![err_arm, ok_arm], hir::MatchSource::TryDesugar, @@ -4246,9 +4258,9 @@ impl<'a> LoweringContext<'a> { fn lower_stmt(&mut self, s: &Stmt) -> SmallVector<hir::Stmt> { SmallVector::one(match s.node { StmtKind::Local(ref l) => Spanned { - node: hir::StmtDecl( + node: hir::StmtKind::Decl( P(Spanned { - node: hir::DeclLocal(self.lower_local(l)), + node: hir::DeclKind::Local(self.lower_local(l)), span: s.span, }), self.lower_node_id(s.id).node_id, @@ -4261,9 +4273,9 @@ impl<'a> LoweringContext<'a> { return self.lower_item_id(it) .into_iter() .map(|item_id| Spanned { - node: hir::StmtDecl( + node: hir::StmtKind::Decl( P(Spanned { - node: hir::DeclItem(item_id), + node: hir::DeclKind::Item(item_id), span: s.span, }), id.take() @@ -4275,11 +4287,11 @@ impl<'a> LoweringContext<'a> { .collect(); } StmtKind::Expr(ref e) => Spanned { - node: hir::StmtExpr(P(self.lower_expr(e)), self.lower_node_id(s.id).node_id), + node: hir::StmtKind::Expr(P(self.lower_expr(e)), self.lower_node_id(s.id).node_id), span: s.span, }, StmtKind::Semi(ref e) => Spanned { - node: hir::StmtSemi(P(self.lower_expr(e)), self.lower_node_id(s.id).node_id), + node: hir::StmtKind::Semi(P(self.lower_expr(e)), self.lower_node_id(s.id).node_id), span: s.span, }, StmtKind::Mac(..) => panic!("Shouldn't exist here"), @@ -4390,7 +4402,7 @@ impl<'a> LoweringContext<'a> { } fn expr_break(&mut self, span: Span, attrs: ThinVec<Attribute>) -> P<hir::Expr> { - let expr_break = hir::ExprBreak(self.lower_loop_destination(None), None); + let expr_break = hir::ExprKind::Break(self.lower_loop_destination(None), None); P(self.expr(span, expr_break, attrs)) } @@ -4400,7 +4412,7 @@ impl<'a> LoweringContext<'a> { e: P<hir::Expr>, args: hir::HirVec<hir::Expr>, ) -> hir::Expr { - self.expr(span, hir::ExprCall(e, args), ThinVec::new()) + self.expr(span, hir::ExprKind::Call(e, args), ThinVec::new()) } fn expr_ident(&mut self, span: Span, ident: Ident, binding: NodeId) -> hir::Expr { @@ -4414,7 +4426,7 @@ impl<'a> LoweringContext<'a> { binding: NodeId, attrs: ThinVec<Attribute>, ) -> hir::Expr { - let expr_path = hir::ExprPath(hir::QPath::Resolved( + let expr_path = hir::ExprKind::Path(hir::QPath::Resolved( None, P(hir::Path { span, @@ -4427,7 +4439,7 @@ impl<'a> LoweringContext<'a> { } fn expr_mut_addr_of(&mut self, span: Span, e: P<hir::Expr>) -> hir::Expr { - self.expr(span, hir::ExprAddrOf(hir::MutMutable, e), ThinVec::new()) + self.expr(span, hir::ExprKind::AddrOf(hir::MutMutable, e), ThinVec::new()) } fn expr_std_path( @@ -4440,7 +4452,7 @@ impl<'a> LoweringContext<'a> { let path = self.std_path(span, components, params, true); self.expr( span, - hir::ExprPath(hir::QPath::Resolved(None, P(path))), + hir::ExprKind::Path(hir::QPath::Resolved(None, P(path))), attrs, ) } @@ -4452,18 +4464,18 @@ impl<'a> LoweringContext<'a> { arms: hir::HirVec<hir::Arm>, source: hir::MatchSource, ) -> hir::Expr { - self.expr(span, hir::ExprMatch(arg, arms, source), ThinVec::new()) + self.expr(span, hir::ExprKind::Match(arg, arms, source), ThinVec::new()) } fn expr_block(&mut self, b: P<hir::Block>, attrs: ThinVec<Attribute>) -> hir::Expr { - self.expr(b.span, hir::ExprBlock(b, None), attrs) + self.expr(b.span, hir::ExprKind::Block(b, None), attrs) } fn expr_tuple(&mut self, sp: Span, exprs: hir::HirVec<hir::Expr>) -> P<hir::Expr> { - P(self.expr(sp, hir::ExprTup(exprs), ThinVec::new())) + P(self.expr(sp, hir::ExprKind::Tup(exprs), ThinVec::new())) } - fn expr(&mut self, span: Span, node: hir::Expr_, attrs: ThinVec<Attribute>) -> hir::Expr { + fn expr(&mut self, span: Span, node: hir::ExprKind, attrs: ThinVec<Attribute>) -> hir::Expr { let LoweredNodeId { node_id, hir_id } = self.next_id(); hir::Expr { id: node_id, @@ -4493,8 +4505,8 @@ impl<'a> LoweringContext<'a> { attrs: ThinVec::new(), source, }); - let decl = respan(sp, hir::DeclLocal(local)); - respan(sp, hir::StmtDecl(P(decl), self.next_id().node_id)) + let decl = respan(sp, hir::DeclKind::Local(local)); + respan(sp, hir::StmtKind::Decl(P(decl), self.next_id().node_id)) } fn stmt_let( @@ -4624,7 +4636,7 @@ impl<'a> LoweringContext<'a> { let mut id = id; let node = match qpath { hir::QPath::Resolved(None, path) => { - // Turn trait object paths into `TyTraitObject` instead. + // Turn trait object paths into `TyKind::TraitObject` instead. if let Def::Trait(_) = path.def { let principal = hir::PolyTraitRef { bound_generic_params: hir::HirVec::new(), @@ -4638,12 +4650,12 @@ impl<'a> LoweringContext<'a> { // The original ID is taken by the `PolyTraitRef`, // so the `Ty` itself needs a different one. id = self.next_id(); - hir::TyTraitObject(hir_vec![principal], self.elided_dyn_bound(span)) + hir::TyKind::TraitObject(hir_vec![principal], self.elided_dyn_bound(span)) } else { - hir::TyPath(hir::QPath::Resolved(None, path)) + hir::TyKind::Path(hir::QPath::Resolved(None, path)) } } - _ => hir::TyPath(qpath), + _ => hir::TyKind::Path(qpath), }; hir::Ty { id: id.node_id, diff --git a/src/librustc/hir/map/blocks.rs b/src/librustc/hir/map/blocks.rs index 930db8b0ccc..5a595d14db7 100644 --- a/src/librustc/hir/map/blocks.rs +++ b/src/librustc/hir/map/blocks.rs @@ -34,7 +34,7 @@ use syntax_pos::Span; /// More specifically, it is one of either: /// /// - A function item, -/// - A closure expr (i.e. an ExprClosure), or +/// - A closure expr (i.e. an ExprKind::Closure), or /// - The default implementation for a trait method. /// /// To construct one, use the `Code::from_node` function. @@ -47,7 +47,7 @@ pub trait MaybeFnLike { fn is_fn_like(&self) -> bool; } impl MaybeFnLike for ast::Item { fn is_fn_like(&self) -> bool { - match self.node { ast::ItemFn(..) => true, _ => false, } + match self.node { ast::ItemKind::Fn(..) => true, _ => false, } } } @@ -63,7 +63,7 @@ impl MaybeFnLike for ast::TraitItem { impl MaybeFnLike for ast::Expr { fn is_fn_like(&self) -> bool { match self.node { - ast::ExprClosure(..) => true, + ast::ExprKind::Closure(..) => true, _ => false, } } @@ -229,7 +229,7 @@ impl<'a> FnLikeNode<'a> { { match self.node { map::NodeItem(i) => match i.node { - ast::ItemFn(ref decl, header, ref generics, block) => + ast::ItemKind::Fn(ref decl, header, ref generics, block) => item_fn(ItemFnParts { id: i.id, name: i.name, @@ -260,7 +260,7 @@ impl<'a> FnLikeNode<'a> { } }, map::NodeExpr(e) => match e.node { - ast::ExprClosure(_, ref decl, block, _fn_decl_span, _gen) => + ast::ExprKind::Closure(_, ref decl, block, _fn_decl_span, _gen) => closure(ClosureParts::new(&decl, block, e.id, e.span, &e.attrs)), _ => bug!("expr FnLikeNode that is not fn-like"), }, diff --git a/src/librustc/hir/map/collector.rs b/src/librustc/hir/map/collector.rs index 3cc25bfd2d4..0150ba659c9 100644 --- a/src/librustc/hir/map/collector.rs +++ b/src/librustc/hir/map/collector.rs @@ -329,7 +329,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> { this.insert(i.id, NodeItem(i)); this.with_parent(i.id, |this| { match i.node { - ItemStruct(ref struct_def, _) => { + ItemKind::Struct(ref struct_def, _) => { // If this is a tuple-like struct, register the constructor. if !struct_def.is_struct() { this.insert(struct_def.id(), NodeStructCtor(struct_def)); diff --git a/src/librustc/hir/map/hir_id_validator.rs b/src/librustc/hir/map/hir_id_validator.rs index b90bca84ed6..656f325b4dd 100644 --- a/src/librustc/hir/map/hir_id_validator.rs +++ b/src/librustc/hir/map/hir_id_validator.rs @@ -179,7 +179,7 @@ impl<'a, 'hir: 'a> intravisit::Visitor<'hir> for HirIdValidator<'a, 'hir> { fn visit_impl_item_ref(&mut self, _: &'hir hir::ImplItemRef) { // Explicitly do nothing here. ImplItemRefs contain hir::Visibility - // values that actually belong to an ImplItem instead of the ItemImpl + // values that actually belong to an ImplItem instead of the ItemKind::Impl // we are currently in. So for those it's correct that they have a // different owner. } diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index 08a130f049b..d413a544c4e 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -33,6 +33,7 @@ use hir::svh::Svh; use util::nodemap::FxHashMap; use std::io; +use std::result::Result::Err; use ty::TyCtxt; pub mod blocks; @@ -174,7 +175,7 @@ impl<'hir> MapEntry<'hir> { match self { EntryItem(_, _, ref item) => { match item.node { - ItemFn(ref fn_decl, _, _, _) => Some(&fn_decl), + ItemKind::Fn(ref fn_decl, _, _, _) => Some(&fn_decl), _ => None, } } @@ -195,7 +196,7 @@ impl<'hir> MapEntry<'hir> { EntryExpr(_, _, ref expr) => { match expr.node { - ExprClosure(_, ref fn_decl, ..) => Some(&fn_decl), + ExprKind::Closure(_, ref fn_decl, ..) => Some(&fn_decl), _ => None, } } @@ -208,9 +209,9 @@ impl<'hir> MapEntry<'hir> { match self { EntryItem(_, _, item) => { match item.node { - ItemConst(_, body) | - ItemStatic(.., body) | - ItemFn(_, _, _, body) => Some(body), + ItemKind::Const(_, body) | + ItemKind::Static(.., body) | + ItemKind::Fn(_, _, _, body) => Some(body), _ => None, } } @@ -235,7 +236,7 @@ impl<'hir> MapEntry<'hir> { EntryExpr(_, _, expr) => { match expr.node { - ExprClosure(.., body, _, _) => Some(body), + ExprKind::Closure(.., body, _, _) => Some(body), _ => None, } } @@ -426,33 +427,33 @@ impl<'hir> Map<'hir> { }; match item.node { - ItemStatic(_, m, _) => Some(Def::Static(def_id(), + ItemKind::Static(_, m, _) => Some(Def::Static(def_id(), m == MutMutable)), - ItemConst(..) => Some(Def::Const(def_id())), - ItemFn(..) => Some(Def::Fn(def_id())), - ItemMod(..) => Some(Def::Mod(def_id())), - ItemGlobalAsm(..) => Some(Def::GlobalAsm(def_id())), - ItemExistential(..) => Some(Def::Existential(def_id())), - ItemTy(..) => Some(Def::TyAlias(def_id())), - ItemEnum(..) => Some(Def::Enum(def_id())), - ItemStruct(..) => Some(Def::Struct(def_id())), - ItemUnion(..) => Some(Def::Union(def_id())), - ItemTrait(..) => Some(Def::Trait(def_id())), - ItemTraitAlias(..) => { + ItemKind::Const(..) => Some(Def::Const(def_id())), + ItemKind::Fn(..) => Some(Def::Fn(def_id())), + ItemKind::Mod(..) => Some(Def::Mod(def_id())), + ItemKind::GlobalAsm(..) => Some(Def::GlobalAsm(def_id())), + ItemKind::Existential(..) => Some(Def::Existential(def_id())), + ItemKind::Ty(..) => Some(Def::TyAlias(def_id())), + ItemKind::Enum(..) => Some(Def::Enum(def_id())), + ItemKind::Struct(..) => Some(Def::Struct(def_id())), + ItemKind::Union(..) => Some(Def::Union(def_id())), + ItemKind::Trait(..) => Some(Def::Trait(def_id())), + ItemKind::TraitAlias(..) => { bug!("trait aliases are not yet implemented (see issue #41517)") }, - ItemExternCrate(_) | - ItemUse(..) | - ItemForeignMod(..) | - ItemImpl(..) => None, + ItemKind::ExternCrate(_) | + ItemKind::Use(..) | + ItemKind::ForeignMod(..) | + ItemKind::Impl(..) => None, } } NodeForeignItem(item) => { let def_id = self.local_def_id(item.id); match item.node { - ForeignItemFn(..) => Some(Def::Fn(def_id)), - ForeignItemStatic(_, m) => Some(Def::Static(def_id, m)), - ForeignItemType => Some(Def::TyForeign(def_id)), + ForeignItemKind::Fn(..) => Some(Def::Fn(def_id)), + ForeignItemKind::Static(_, m) => Some(Def::Static(def_id, m)), + ForeignItemKind::Type => Some(Def::TyForeign(def_id)), } } NodeTraitItem(item) => { @@ -586,13 +587,13 @@ impl<'hir> Map<'hir> { pub fn body_owner_kind(&self, id: NodeId) -> BodyOwnerKind { match self.get(id) { - NodeItem(&Item { node: ItemConst(..), .. }) | + NodeItem(&Item { node: ItemKind::Const(..), .. }) | NodeTraitItem(&TraitItem { node: TraitItemKind::Const(..), .. }) | NodeImplItem(&ImplItem { node: ImplItemKind::Const(..), .. }) | NodeAnonConst(_) => { BodyOwnerKind::Const } - NodeItem(&Item { node: ItemStatic(_, m, _), .. }) => { + NodeItem(&Item { node: ItemKind::Static(_, m, _), .. }) => { BodyOwnerKind::Static(m) } // Default to function if it's not a constant or static. @@ -602,7 +603,7 @@ impl<'hir> Map<'hir> { pub fn ty_param_owner(&self, id: NodeId) -> NodeId { match self.get(id) { - NodeItem(&Item { node: ItemTrait(..), .. }) => id, + NodeItem(&Item { node: ItemKind::Trait(..), .. }) => id, NodeGenericParam(_) => self.get_parent_node(id), _ => { bug!("ty_param_owner: {} not a type parameter", @@ -613,7 +614,7 @@ impl<'hir> Map<'hir> { pub fn ty_param_name(&self, id: NodeId) -> Name { match self.get(id) { - NodeItem(&Item { node: ItemTrait(..), .. }) => { + NodeItem(&Item { node: ItemKind::Trait(..), .. }) => { keywords::SelfType.name() } NodeGenericParam(param) => param.name.ident().name, @@ -671,14 +672,14 @@ impl<'hir> Map<'hir> { NodeTraitItem(ref trait_item) => Some(&trait_item.generics), NodeItem(ref item) => { match item.node { - ItemFn(_, _, ref generics, _) | - ItemTy(_, ref generics) | - ItemEnum(_, ref generics) | - ItemStruct(_, ref generics) | - ItemUnion(_, ref generics) | - ItemTrait(_, _, ref generics, ..) | - ItemTraitAlias(ref generics, _) | - ItemImpl(_, _, _, ref generics, ..) => Some(generics), + ItemKind::Fn(_, _, ref generics, _) | + ItemKind::Ty(_, ref generics) | + ItemKind::Enum(_, ref generics) | + ItemKind::Struct(_, ref generics) | + ItemKind::Union(_, ref generics) | + ItemKind::Trait(_, _, ref generics, ..) | + ItemKind::TraitAlias(ref generics, _) | + ItemKind::Impl(_, _, _, ref generics, ..) => Some(generics), _ => None, } } @@ -734,7 +735,7 @@ impl<'hir> Map<'hir> { Some(NodeImplItem(_)) => true, Some(NodeExpr(e)) => { match e.node { - ExprClosure(..) => true, + ExprKind::Closure(..) => true, _ => false, } } @@ -821,7 +822,7 @@ impl<'hir> Map<'hir> { match *node { NodeExpr(ref expr) => { match expr.node { - ExprWhile(..) | ExprLoop(..) => true, + ExprKind::While(..) | ExprKind::Loop(..) => true, _ => false, } } @@ -856,7 +857,7 @@ impl<'hir> Map<'hir> { /// module parent is in this map. pub fn get_module_parent(&self, id: NodeId) -> DefId { let id = match self.walk_parent_nodes(id, |node| match *node { - NodeItem(&Item { node: Item_::ItemMod(_), .. }) => true, + NodeItem(&Item { node: ItemKind::Mod(_), .. }) => true, _ => false, }, |_| false) { Ok(id) => id, @@ -892,7 +893,7 @@ impl<'hir> Map<'hir> { let abi = match self.find_entry(parent) { Some(EntryItem(_, _, i)) => { match i.node { - ItemForeignMod(ref nm) => Some(nm.abi), + ItemKind::ForeignMod(ref nm) => Some(nm.abi), _ => None } } @@ -933,8 +934,8 @@ impl<'hir> Map<'hir> { match self.find(id) { Some(NodeItem(i)) => { match i.node { - ItemStruct(ref struct_def, _) | - ItemUnion(ref struct_def, _) => struct_def, + ItemKind::Struct(ref struct_def, _) | + ItemKind::Union(ref struct_def, _) => struct_def, _ => { bug!("struct ID bound to non-struct {}", self.node_to_string(id)); @@ -1128,7 +1129,7 @@ impl<'a, 'hir> NodesMatchingSuffix<'a, 'hir> { fn item_is_mod(item: &Item) -> bool { match item.node { - ItemMod(_) => true, + ItemKind::Mod(_) => true, _ => false, } } @@ -1176,7 +1177,7 @@ impl<T:Named> Named for Spanned<T> { fn name(&self) -> Name { self.node.name() } impl Named for Item { fn name(&self) -> Name { self.name } } impl Named for ForeignItem { fn name(&self) -> Name { self.name } } -impl Named for Variant_ { fn name(&self) -> Name { self.name } } +impl Named for VariantKind { fn name(&self) -> Name { self.name } } impl Named for StructField { fn name(&self) -> Name { self.ident.name } } impl Named for TraitItem { fn name(&self) -> Name { self.ident.name } } impl Named for ImplItem { fn name(&self) -> Name { self.ident.name } } @@ -1313,22 +1314,22 @@ fn node_id_to_string(map: &Map, id: NodeId, include_id: bool) -> String { match map.find(id) { Some(NodeItem(item)) => { let item_str = match item.node { - ItemExternCrate(..) => "extern crate", - ItemUse(..) => "use", - ItemStatic(..) => "static", - ItemConst(..) => "const", - ItemFn(..) => "fn", - ItemMod(..) => "mod", - ItemForeignMod(..) => "foreign mod", - ItemGlobalAsm(..) => "global asm", - ItemTy(..) => "ty", - ItemExistential(..) => "existential", - ItemEnum(..) => "enum", - ItemStruct(..) => "struct", - ItemUnion(..) => "union", - ItemTrait(..) => "trait", - ItemTraitAlias(..) => "trait alias", - ItemImpl(..) => "impl", + ItemKind::ExternCrate(..) => "extern crate", + ItemKind::Use(..) => "use", + ItemKind::Static(..) => "static", + ItemKind::Const(..) => "const", + ItemKind::Fn(..) => "fn", + ItemKind::Mod(..) => "mod", + ItemKind::ForeignMod(..) => "foreign mod", + ItemKind::GlobalAsm(..) => "global asm", + ItemKind::Ty(..) => "ty", + ItemKind::Existential(..) => "existential", + ItemKind::Enum(..) => "enum", + ItemKind::Struct(..) => "struct", + ItemKind::Union(..) => "union", + ItemKind::Trait(..) => "trait", + ItemKind::TraitAlias(..) => "trait alias", + ItemKind::Impl(..) => "impl", }; format!("{} {}{}", item_str, path_str(), id_str) } diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index bf83fa15727..c1a885d80bf 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -10,18 +10,11 @@ // The Rust HIR. -pub use self::BinOp_::*; pub use self::BlockCheckMode::*; pub use self::CaptureClause::*; -pub use self::Decl_::*; -pub use self::Expr_::*; pub use self::FunctionRetTy::*; -pub use self::ForeignItem_::*; -pub use self::Item_::*; pub use self::Mutability::*; pub use self::PrimTy::*; -pub use self::Stmt_::*; -pub use self::Ty_::*; pub use self::UnOp::*; pub use self::UnsafeSource::*; @@ -443,7 +436,7 @@ impl GenericArgs { match arg { GenericArg::Lifetime(_) => {} GenericArg::Type(ref ty) => { - if let TyTup(ref tys) = ty.node { + if let TyKind::Tup(ref tys) = ty.node { return tys; } break; @@ -941,98 +934,103 @@ impl Mutability { } #[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy, Hash)] -pub enum BinOp_ { +pub enum BinOpKind { /// The `+` operator (addition) - BiAdd, + Add, /// The `-` operator (subtraction) - BiSub, + Sub, /// The `*` operator (multiplication) - BiMul, + Mul, /// The `/` operator (division) - BiDiv, + Div, /// The `%` operator (modulus) - BiRem, + Rem, /// The `&&` operator (logical and) - BiAnd, + And, /// The `||` operator (logical or) - BiOr, + Or, /// The `^` operator (bitwise xor) - BiBitXor, + BitXor, /// The `&` operator (bitwise and) - BiBitAnd, + BitAnd, /// The `|` operator (bitwise or) - BiBitOr, + BitOr, /// The `<<` operator (shift left) - BiShl, + Shl, /// The `>>` operator (shift right) - BiShr, + Shr, /// The `==` operator (equality) - BiEq, + Eq, /// The `<` operator (less than) - BiLt, + Lt, /// The `<=` operator (less than or equal to) - BiLe, + Le, /// The `!=` operator (not equal to) - BiNe, + Ne, /// The `>=` operator (greater than or equal to) - BiGe, + Ge, /// The `>` operator (greater than) - BiGt, + Gt, } -impl BinOp_ { +impl BinOpKind { pub fn as_str(self) -> &'static str { match self { - BiAdd => "+", - BiSub => "-", - BiMul => "*", - BiDiv => "/", - BiRem => "%", - BiAnd => "&&", - BiOr => "||", - BiBitXor => "^", - BiBitAnd => "&", - BiBitOr => "|", - BiShl => "<<", - BiShr => ">>", - BiEq => "==", - BiLt => "<", - BiLe => "<=", - BiNe => "!=", - BiGe => ">=", - BiGt => ">", + BinOpKind::Add => "+", + BinOpKind::Sub => "-", + BinOpKind::Mul => "*", + BinOpKind::Div => "/", + BinOpKind::Rem => "%", + BinOpKind::And => "&&", + BinOpKind::Or => "||", + BinOpKind::BitXor => "^", + BinOpKind::BitAnd => "&", + BinOpKind::BitOr => "|", + BinOpKind::Shl => "<<", + BinOpKind::Shr => ">>", + BinOpKind::Eq => "==", + BinOpKind::Lt => "<", + BinOpKind::Le => "<=", + BinOpKind::Ne => "!=", + BinOpKind::Ge => ">=", + BinOpKind::Gt => ">", } } pub fn is_lazy(self) -> bool { match self { - BiAnd | BiOr => true, + BinOpKind::And | BinOpKind::Or => true, _ => false, } } pub fn is_shift(self) -> bool { match self { - BiShl | BiShr => true, + BinOpKind::Shl | BinOpKind::Shr => true, _ => false, } } pub fn is_comparison(self) -> bool { match self { - BiEq | BiLt | BiLe | BiNe | BiGt | BiGe => true, - BiAnd | - BiOr | - BiAdd | - BiSub | - BiMul | - BiDiv | - BiRem | - BiBitXor | - BiBitAnd | - BiBitOr | - BiShl | - BiShr => false, + BinOpKind::Eq | + BinOpKind::Lt | + BinOpKind::Le | + BinOpKind::Ne | + BinOpKind::Gt | + BinOpKind::Ge => true, + BinOpKind::And | + BinOpKind::Or | + BinOpKind::Add | + BinOpKind::Sub | + BinOpKind::Mul | + BinOpKind::Div | + BinOpKind::Rem | + BinOpKind::BitXor | + BinOpKind::BitAnd | + BinOpKind::BitOr | + BinOpKind::Shl | + BinOpKind::Shr => false, } } @@ -1042,32 +1040,32 @@ impl BinOp_ { } } -impl Into<ast::BinOpKind> for BinOp_ { +impl Into<ast::BinOpKind> for BinOpKind { fn into(self) -> ast::BinOpKind { match self { - BiAdd => ast::BinOpKind::Add, - BiSub => ast::BinOpKind::Sub, - BiMul => ast::BinOpKind::Mul, - BiDiv => ast::BinOpKind::Div, - BiRem => ast::BinOpKind::Rem, - BiAnd => ast::BinOpKind::And, - BiOr => ast::BinOpKind::Or, - BiBitXor => ast::BinOpKind::BitXor, - BiBitAnd => ast::BinOpKind::BitAnd, - BiBitOr => ast::BinOpKind::BitOr, - BiShl => ast::BinOpKind::Shl, - BiShr => ast::BinOpKind::Shr, - BiEq => ast::BinOpKind::Eq, - BiLt => ast::BinOpKind::Lt, - BiLe => ast::BinOpKind::Le, - BiNe => ast::BinOpKind::Ne, - BiGe => ast::BinOpKind::Ge, - BiGt => ast::BinOpKind::Gt, + BinOpKind::Add => ast::BinOpKind::Add, + BinOpKind::Sub => ast::BinOpKind::Sub, + BinOpKind::Mul => ast::BinOpKind::Mul, + BinOpKind::Div => ast::BinOpKind::Div, + BinOpKind::Rem => ast::BinOpKind::Rem, + BinOpKind::And => ast::BinOpKind::And, + BinOpKind::Or => ast::BinOpKind::Or, + BinOpKind::BitXor => ast::BinOpKind::BitXor, + BinOpKind::BitAnd => ast::BinOpKind::BitAnd, + BinOpKind::BitOr => ast::BinOpKind::BitOr, + BinOpKind::Shl => ast::BinOpKind::Shl, + BinOpKind::Shr => ast::BinOpKind::Shr, + BinOpKind::Eq => ast::BinOpKind::Eq, + BinOpKind::Lt => ast::BinOpKind::Lt, + BinOpKind::Le => ast::BinOpKind::Le, + BinOpKind::Ne => ast::BinOpKind::Ne, + BinOpKind::Ge => ast::BinOpKind::Ge, + BinOpKind::Gt => ast::BinOpKind::Gt, } } } -pub type BinOp = Spanned<BinOp_>; +pub type BinOp = Spanned<BinOpKind>; #[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy, Hash)] pub enum UnOp { @@ -1098,9 +1096,9 @@ impl UnOp { } /// A statement -pub type Stmt = Spanned<Stmt_>; +pub type Stmt = Spanned<StmtKind>; -impl fmt::Debug for Stmt_ { +impl fmt::Debug for StmtKind { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { // Sadness. let spanned = codemap::dummy_spanned(self.clone()); @@ -1112,31 +1110,31 @@ impl fmt::Debug for Stmt_ { } #[derive(Clone, RustcEncodable, RustcDecodable)] -pub enum Stmt_ { +pub enum StmtKind { /// Could be an item or a local (let) binding: - StmtDecl(P<Decl>, NodeId), + Decl(P<Decl>, NodeId), /// Expr without trailing semi-colon (must have unit type): - StmtExpr(P<Expr>, NodeId), + Expr(P<Expr>, NodeId), /// Expr with trailing semi-colon (may have any type): - StmtSemi(P<Expr>, NodeId), + Semi(P<Expr>, NodeId), } -impl Stmt_ { +impl StmtKind { pub fn attrs(&self) -> &[Attribute] { match *self { - StmtDecl(ref d, _) => d.node.attrs(), - StmtExpr(ref e, _) | - StmtSemi(ref e, _) => &e.attrs, + StmtKind::Decl(ref d, _) => d.node.attrs(), + StmtKind::Expr(ref e, _) | + StmtKind::Semi(ref e, _) => &e.attrs, } } pub fn id(&self) -> NodeId { match *self { - StmtDecl(_, id) => id, - StmtExpr(_, id) => id, - StmtSemi(_, id) => id, + StmtKind::Decl(_, id) => id, + StmtKind::Expr(_, id) => id, + StmtKind::Semi(_, id) => id, } } } @@ -1155,27 +1153,27 @@ pub struct Local { pub source: LocalSource, } -pub type Decl = Spanned<Decl_>; +pub type Decl = Spanned<DeclKind>; #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] -pub enum Decl_ { +pub enum DeclKind { /// A local (let) binding: - DeclLocal(P<Local>), + Local(P<Local>), /// An item binding: - DeclItem(ItemId), + Item(ItemId), } -impl Decl_ { +impl DeclKind { pub fn attrs(&self) -> &[Attribute] { match *self { - DeclLocal(ref l) => &l.attrs, - DeclItem(_) => &[] + DeclKind::Local(ref l) => &l.attrs, + DeclKind::Item(_) => &[] } } pub fn is_local(&self) -> bool { match *self { - Decl_::DeclLocal(_) => true, + DeclKind::Local(_) => true, _ => false, } } @@ -1283,7 +1281,7 @@ pub struct AnonConst { pub struct Expr { pub id: NodeId, pub span: Span, - pub node: Expr_, + pub node: ExprKind, pub attrs: ThinVec<Attribute>, pub hir_id: HirId, } @@ -1291,34 +1289,34 @@ pub struct Expr { impl Expr { pub fn precedence(&self) -> ExprPrecedence { match self.node { - ExprBox(_) => ExprPrecedence::Box, - ExprArray(_) => ExprPrecedence::Array, - ExprCall(..) => ExprPrecedence::Call, - ExprMethodCall(..) => ExprPrecedence::MethodCall, - ExprTup(_) => ExprPrecedence::Tup, - ExprBinary(op, ..) => ExprPrecedence::Binary(op.node.into()), - ExprUnary(..) => ExprPrecedence::Unary, - ExprLit(_) => ExprPrecedence::Lit, - ExprType(..) | ExprCast(..) => ExprPrecedence::Cast, - ExprIf(..) => ExprPrecedence::If, - ExprWhile(..) => ExprPrecedence::While, - ExprLoop(..) => ExprPrecedence::Loop, - ExprMatch(..) => ExprPrecedence::Match, - ExprClosure(..) => ExprPrecedence::Closure, - ExprBlock(..) => ExprPrecedence::Block, - ExprAssign(..) => ExprPrecedence::Assign, - ExprAssignOp(..) => ExprPrecedence::AssignOp, - ExprField(..) => ExprPrecedence::Field, - ExprIndex(..) => ExprPrecedence::Index, - ExprPath(..) => ExprPrecedence::Path, - ExprAddrOf(..) => ExprPrecedence::AddrOf, - ExprBreak(..) => ExprPrecedence::Break, - ExprContinue(..) => ExprPrecedence::Continue, - ExprRet(..) => ExprPrecedence::Ret, - ExprInlineAsm(..) => ExprPrecedence::InlineAsm, - ExprStruct(..) => ExprPrecedence::Struct, - ExprRepeat(..) => ExprPrecedence::Repeat, - ExprYield(..) => ExprPrecedence::Yield, + ExprKind::Box(_) => ExprPrecedence::Box, + ExprKind::Array(_) => ExprPrecedence::Array, + ExprKind::Call(..) => ExprPrecedence::Call, + ExprKind::MethodCall(..) => ExprPrecedence::MethodCall, + ExprKind::Tup(_) => ExprPrecedence::Tup, + ExprKind::Binary(op, ..) => ExprPrecedence::Binary(op.node.into()), + ExprKind::Unary(..) => ExprPrecedence::Unary, + ExprKind::Lit(_) => ExprPrecedence::Lit, + ExprKind::Type(..) | ExprKind::Cast(..) => ExprPrecedence::Cast, + ExprKind::If(..) => ExprPrecedence::If, + ExprKind::While(..) => ExprPrecedence::While, + ExprKind::Loop(..) => ExprPrecedence::Loop, + ExprKind::Match(..) => ExprPrecedence::Match, + ExprKind::Closure(..) => ExprPrecedence::Closure, + ExprKind::Block(..) => ExprPrecedence::Block, + ExprKind::Assign(..) => ExprPrecedence::Assign, + ExprKind::AssignOp(..) => ExprPrecedence::AssignOp, + ExprKind::Field(..) => ExprPrecedence::Field, + ExprKind::Index(..) => ExprPrecedence::Index, + ExprKind::Path(..) => ExprPrecedence::Path, + ExprKind::AddrOf(..) => ExprPrecedence::AddrOf, + ExprKind::Break(..) => ExprPrecedence::Break, + ExprKind::Continue(..) => ExprPrecedence::Continue, + ExprKind::Ret(..) => ExprPrecedence::Ret, + ExprKind::InlineAsm(..) => ExprPrecedence::InlineAsm, + ExprKind::Struct(..) => ExprPrecedence::Struct, + ExprKind::Repeat(..) => ExprPrecedence::Repeat, + ExprKind::Yield(..) => ExprPrecedence::Yield, } } } @@ -1331,18 +1329,18 @@ impl fmt::Debug for Expr { } #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] -pub enum Expr_ { +pub enum ExprKind { /// A `box x` expression. - ExprBox(P<Expr>), + Box(P<Expr>), /// An array (`[a, b, c, d]`) - ExprArray(HirVec<Expr>), + Array(HirVec<Expr>), /// A function call /// - /// The first field resolves to the function itself (usually an `ExprPath`), + /// The first field resolves to the function itself (usually an `ExprKind::Path`), /// and the second field is the list of arguments. /// This also represents calling the constructor of /// tuple-like ADTs such as tuple structs and enum variants. - ExprCall(P<Expr>, HirVec<Expr>), + Call(P<Expr>, HirVec<Expr>), /// A method call (`x.foo::<'static, Bar, Baz>(a, b, c, d)`) /// /// The `PathSegment`/`Span` represent the method name and its generic arguments @@ -1352,83 +1350,83 @@ pub enum Expr_ { /// and the remaining elements are the rest of the arguments. /// Thus, `x.foo::<Bar, Baz>(a, b, c, d)` is represented as /// `ExprKind::MethodCall(PathSegment { foo, [Bar, Baz] }, [x, a, b, c, d])`. - ExprMethodCall(PathSegment, Span, HirVec<Expr>), + MethodCall(PathSegment, Span, HirVec<Expr>), /// A tuple (`(a, b, c ,d)`) - ExprTup(HirVec<Expr>), + Tup(HirVec<Expr>), /// A binary operation (For example: `a + b`, `a * b`) - ExprBinary(BinOp, P<Expr>, P<Expr>), + Binary(BinOp, P<Expr>, P<Expr>), /// A unary operation (For example: `!x`, `*x`) - ExprUnary(UnOp, P<Expr>), + Unary(UnOp, P<Expr>), /// A literal (For example: `1`, `"foo"`) - ExprLit(P<Lit>), + Lit(P<Lit>), /// A cast (`foo as f64`) - ExprCast(P<Expr>, P<Ty>), - ExprType(P<Expr>, P<Ty>), + Cast(P<Expr>, P<Ty>), + Type(P<Expr>, P<Ty>), /// An `if` block, with an optional else block /// /// `if expr { expr } else { expr }` - ExprIf(P<Expr>, P<Expr>, Option<P<Expr>>), + If(P<Expr>, P<Expr>, Option<P<Expr>>), /// A while loop, with an optional label /// /// `'label: while expr { block }` - ExprWhile(P<Expr>, P<Block>, Option<Label>), + While(P<Expr>, P<Block>, Option<Label>), /// Conditionless loop (can be exited with break, continue, or return) /// /// `'label: loop { block }` - ExprLoop(P<Block>, Option<Label>, LoopSource), + Loop(P<Block>, Option<Label>, LoopSource), /// A `match` block, with a source that indicates whether or not it is /// the result of a desugaring, and if so, which kind. - ExprMatch(P<Expr>, HirVec<Arm>, MatchSource), + Match(P<Expr>, HirVec<Arm>, MatchSource), /// A closure (for example, `move |a, b, c| {a + b + c}`). /// /// The final span is the span of the argument block `|...|` /// /// This may also be a generator literal, indicated by the final boolean, /// in that case there is an GeneratorClause. - ExprClosure(CaptureClause, P<FnDecl>, BodyId, Span, Option<GeneratorMovability>), + Closure(CaptureClause, P<FnDecl>, BodyId, Span, Option<GeneratorMovability>), /// A block (`'label: { ... }`) - ExprBlock(P<Block>, Option<Label>), + Block(P<Block>, Option<Label>), /// An assignment (`a = foo()`) - ExprAssign(P<Expr>, P<Expr>), + Assign(P<Expr>, P<Expr>), /// An assignment with an operator /// /// For example, `a += 1`. - ExprAssignOp(BinOp, P<Expr>, P<Expr>), + AssignOp(BinOp, P<Expr>, P<Expr>), /// Access of a named (`obj.foo`) or unnamed (`obj.0`) struct or tuple field - ExprField(P<Expr>, Ident), + Field(P<Expr>, Ident), /// An indexing operation (`foo[2]`) - ExprIndex(P<Expr>, P<Expr>), + Index(P<Expr>, P<Expr>), /// Path to a definition, possibly containing lifetime or type parameters. - ExprPath(QPath), + Path(QPath), /// A referencing operation (`&a` or `&mut a`) - ExprAddrOf(Mutability, P<Expr>), + AddrOf(Mutability, P<Expr>), /// A `break`, with an optional label to break - ExprBreak(Destination, Option<P<Expr>>), + Break(Destination, Option<P<Expr>>), /// A `continue`, with an optional label - ExprContinue(Destination), + Continue(Destination), /// A `return`, with an optional value to be returned - ExprRet(Option<P<Expr>>), + Ret(Option<P<Expr>>), /// Inline assembly (from `asm!`), with its outputs and inputs. - ExprInlineAsm(P<InlineAsm>, HirVec<Expr>, HirVec<Expr>), + InlineAsm(P<InlineAsm>, HirVec<Expr>, HirVec<Expr>), /// A struct or struct-like variant literal expression. /// /// For example, `Foo {x: 1, y: 2}`, or /// `Foo {x: 1, .. base}`, where `base` is the `Option<Expr>`. - ExprStruct(QPath, HirVec<Field>, Option<P<Expr>>), + Struct(QPath, HirVec<Field>, Option<P<Expr>>), /// An array literal constructed from one repeated element. /// /// For example, `[1; 5]`. The first expression is the element /// to be repeated; the second is the number of times to repeat it. - ExprRepeat(P<Expr>, AnonConst), + Repeat(P<Expr>, AnonConst), /// A suspension point for generators. This is `yield <expr>` in Rust. - ExprYield(P<Expr>), + Yield(P<Expr>), } /// Optionally `Self`-qualified value/type path or associated extension. @@ -1447,7 +1445,7 @@ pub enum QPath { /// /// UFCS source paths can desugar into this, with `Vec::new` turning into /// `<Vec>::new`, and `T::X::Y::method` into `<<<T>::X>::Y>::method`, - /// the `X` and `Y` nodes each being a `TyPath(QPath::TypeRelative(..))`. + /// the `X` and `Y` nodes each being a `TyKind::Path(QPath::TypeRelative(..))`. TypeRelative(P<Ty>, P<PathSegment>) } @@ -1478,7 +1476,7 @@ pub enum MatchSource { TryDesugar, } -/// The loop type that yielded an ExprLoop +/// The loop type that yielded an ExprKind::Loop #[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy)] pub enum LoopSource { /// A `loop { .. }` loop @@ -1637,7 +1635,7 @@ pub struct TypeBinding { #[derive(Clone, RustcEncodable, RustcDecodable)] pub struct Ty { pub id: NodeId, - pub node: Ty_, + pub node: TyKind, pub span: Span, pub hir_id: HirId, } @@ -1678,36 +1676,36 @@ pub struct ExistTy { #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] /// The different kinds of types recognized by the compiler -pub enum Ty_ { +pub enum TyKind { /// A variable length slice (`[T]`) - TySlice(P<Ty>), + Slice(P<Ty>), /// A fixed length array (`[T; n]`) - TyArray(P<Ty>, AnonConst), + Array(P<Ty>, AnonConst), /// A raw pointer (`*const T` or `*mut T`) - TyPtr(MutTy), + Ptr(MutTy), /// A reference (`&'a T` or `&'a mut T`) - TyRptr(Lifetime, MutTy), + Rptr(Lifetime, MutTy), /// A bare function (e.g. `fn(usize) -> bool`) - TyBareFn(P<BareFnTy>), + BareFn(P<BareFnTy>), /// The never type (`!`) - TyNever, + Never, /// A tuple (`(A, B, C, D,...)`) - TyTup(HirVec<Ty>), + Tup(HirVec<Ty>), /// A path to a type definition (`module::module::...::Type`), or an /// associated type, e.g. `<Vec<T> as Trait>::Type` or `<T>::Target`. /// /// Type parameters may be stored in each `PathSegment`. - TyPath(QPath), + Path(QPath), /// A trait object type `Bound1 + Bound2 + Bound3` /// where `Bound` is a trait or a lifetime. - TyTraitObject(HirVec<PolyTraitRef>, Lifetime), + TraitObject(HirVec<PolyTraitRef>, Lifetime), /// Unused for now - TyTypeof(AnonConst), - /// TyInfer means the type should be inferred instead of it having been + Typeof(AnonConst), + /// TyKind::Infer means the type should be inferred instead of it having been /// specified. This can appear anywhere in a type. - TyInfer, + Infer, /// Placeholder for a type that has failed to be defined. - TyErr, + Err, } #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] @@ -1876,7 +1874,7 @@ pub struct EnumDef { } #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] -pub struct Variant_ { +pub struct VariantKind { pub name: Name, pub attrs: HirVec<Attribute>, pub data: VariantData, @@ -1884,7 +1882,7 @@ pub struct Variant_ { pub disr_expr: Option<AnonConst>, } -pub type Variant = Spanned<Variant_>; +pub type Variant = Spanned<VariantKind>; #[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug)] pub enum UseKind { @@ -2041,7 +2039,7 @@ pub struct Item { pub id: NodeId, pub hir_id: HirId, pub attrs: HirVec<Attribute>, - pub node: Item_, + pub node: ItemKind, pub vis: Visibility, pub span: Span, } @@ -2055,96 +2053,96 @@ pub struct FnHeader { } #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] -pub enum Item_ { +pub enum ItemKind { /// An `extern crate` item, with optional *original* crate name if the crate was renamed. /// /// E.g. `extern crate foo` or `extern crate foo_bar as foo` - ItemExternCrate(Option<Name>), + ExternCrate(Option<Name>), /// `use foo::bar::*;` or `use foo::bar::baz as quux;` /// /// or just /// /// `use foo::bar::baz;` (with `as baz` implicitly on the right) - ItemUse(P<Path>, UseKind), + Use(P<Path>, UseKind), /// A `static` item - ItemStatic(P<Ty>, Mutability, BodyId), + Static(P<Ty>, Mutability, BodyId), /// A `const` item - ItemConst(P<Ty>, BodyId), + Const(P<Ty>, BodyId), /// A function declaration - ItemFn(P<FnDecl>, FnHeader, Generics, BodyId), + Fn(P<FnDecl>, FnHeader, Generics, BodyId), /// A module - ItemMod(Mod), + Mod(Mod), /// An external module - ItemForeignMod(ForeignMod), + ForeignMod(ForeignMod), /// Module-level inline assembly (from global_asm!) - ItemGlobalAsm(P<GlobalAsm>), + GlobalAsm(P<GlobalAsm>), /// A type alias, e.g. `type Foo = Bar<u8>` - ItemTy(P<Ty>, Generics), + Ty(P<Ty>, Generics), /// A type alias, e.g. `type Foo = Bar<u8>` - ItemExistential(ExistTy), + Existential(ExistTy), /// An enum definition, e.g. `enum Foo<A, B> {C<A>, D<B>}` - ItemEnum(EnumDef, Generics), + Enum(EnumDef, Generics), /// A struct definition, e.g. `struct Foo<A> {x: A}` - ItemStruct(VariantData, Generics), + Struct(VariantData, Generics), /// A union definition, e.g. `union Foo<A, B> {x: A, y: B}` - ItemUnion(VariantData, Generics), + Union(VariantData, Generics), /// Represents a Trait Declaration - ItemTrait(IsAuto, Unsafety, Generics, GenericBounds, HirVec<TraitItemRef>), + Trait(IsAuto, Unsafety, Generics, GenericBounds, HirVec<TraitItemRef>), /// Represents a Trait Alias Declaration - ItemTraitAlias(Generics, GenericBounds), + TraitAlias(Generics, GenericBounds), /// An implementation, eg `impl<A> Trait for Foo { .. }` - ItemImpl(Unsafety, - ImplPolarity, - Defaultness, - Generics, - Option<TraitRef>, // (optional) trait this impl implements - P<Ty>, // self - HirVec<ImplItemRef>), + Impl(Unsafety, + ImplPolarity, + Defaultness, + Generics, + Option<TraitRef>, // (optional) trait this impl implements + P<Ty>, // self + HirVec<ImplItemRef>), } -impl Item_ { +impl ItemKind { pub fn descriptive_variant(&self) -> &str { match *self { - ItemExternCrate(..) => "extern crate", - ItemUse(..) => "use", - ItemStatic(..) => "static item", - ItemConst(..) => "constant item", - ItemFn(..) => "function", - ItemMod(..) => "module", - ItemForeignMod(..) => "foreign module", - ItemGlobalAsm(..) => "global asm", - ItemTy(..) => "type alias", - ItemExistential(..) => "existential type", - ItemEnum(..) => "enum", - ItemStruct(..) => "struct", - ItemUnion(..) => "union", - ItemTrait(..) => "trait", - ItemTraitAlias(..) => "trait alias", - ItemImpl(..) => "item", + ItemKind::ExternCrate(..) => "extern crate", + ItemKind::Use(..) => "use", + ItemKind::Static(..) => "static item", + ItemKind::Const(..) => "constant item", + ItemKind::Fn(..) => "function", + ItemKind::Mod(..) => "module", + ItemKind::ForeignMod(..) => "foreign module", + ItemKind::GlobalAsm(..) => "global asm", + ItemKind::Ty(..) => "type alias", + ItemKind::Existential(..) => "existential type", + ItemKind::Enum(..) => "enum", + ItemKind::Struct(..) => "struct", + ItemKind::Union(..) => "union", + ItemKind::Trait(..) => "trait", + ItemKind::TraitAlias(..) => "trait alias", + ItemKind::Impl(..) => "item", } } pub fn adt_kind(&self) -> Option<AdtKind> { match *self { - ItemStruct(..) => Some(AdtKind::Struct), - ItemUnion(..) => Some(AdtKind::Union), - ItemEnum(..) => Some(AdtKind::Enum), + ItemKind::Struct(..) => Some(AdtKind::Struct), + ItemKind::Union(..) => Some(AdtKind::Union), + ItemKind::Enum(..) => Some(AdtKind::Enum), _ => None, } } pub fn generics(&self) -> Option<&Generics> { Some(match *self { - ItemFn(_, _, ref generics, _) | - ItemTy(_, ref generics) | - ItemEnum(_, ref generics) | - ItemStruct(_, ref generics) | - ItemUnion(_, ref generics) | - ItemTrait(_, _, ref generics, _, _) | - ItemImpl(_, _, _, ref generics, _, _, _)=> generics, + ItemKind::Fn(_, _, ref generics, _) | + ItemKind::Ty(_, ref generics) | + ItemKind::Enum(_, ref generics) | + ItemKind::Struct(_, ref generics) | + ItemKind::Union(_, ref generics) | + ItemKind::Trait(_, _, ref generics, _, _) | + ItemKind::Impl(_, _, _, ref generics, _, _, _)=> generics, _ => return None }) } @@ -2192,7 +2190,7 @@ pub enum AssociatedItemKind { pub struct ForeignItem { pub name: Name, pub attrs: HirVec<Attribute>, - pub node: ForeignItem_, + pub node: ForeignItemKind, pub id: NodeId, pub span: Span, pub vis: Visibility, @@ -2200,22 +2198,22 @@ pub struct ForeignItem { /// An item within an `extern` block #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] -pub enum ForeignItem_ { +pub enum ForeignItemKind { /// A foreign function - ForeignItemFn(P<FnDecl>, HirVec<Ident>, Generics), + Fn(P<FnDecl>, HirVec<Ident>, Generics), /// A foreign static item (`static ext: u8`), with optional mutability /// (the boolean is true when mutable) - ForeignItemStatic(P<Ty>, bool), + Static(P<Ty>, bool), /// A foreign type - ForeignItemType, + Type, } -impl ForeignItem_ { +impl ForeignItemKind { pub fn descriptive_variant(&self) -> &str { match *self { - ForeignItemFn(..) => "foreign function", - ForeignItemStatic(..) => "foreign static item", - ForeignItemType => "foreign type", + ForeignItemKind::Fn(..) => "foreign function", + ForeignItemKind::Static(..) => "foreign static item", + ForeignItemKind::Type => "foreign type", } } } diff --git a/src/librustc/hir/print.rs b/src/librustc/hir/print.rs index 377990ef561..e637a18d1cd 100644 --- a/src/librustc/hir/print.rs +++ b/src/librustc/hir/print.rs @@ -367,12 +367,12 @@ impl<'a> State<'a> { self.maybe_print_comment(ty.span.lo())?; self.ibox(0)?; match ty.node { - hir::TySlice(ref ty) => { + hir::TyKind::Slice(ref ty) => { self.s.word("[")?; self.print_type(&ty)?; self.s.word("]")?; } - hir::TyPtr(ref mt) => { + hir::TyKind::Ptr(ref mt) => { self.s.word("*")?; match mt.mutbl { hir::MutMutable => self.word_nbsp("mut")?, @@ -380,15 +380,15 @@ impl<'a> State<'a> { } self.print_type(&mt.ty)?; } - hir::TyRptr(ref lifetime, ref mt) => { + hir::TyKind::Rptr(ref lifetime, ref mt) => { self.s.word("&")?; self.print_opt_lifetime(lifetime)?; self.print_mt(mt)?; } - hir::TyNever => { + hir::TyKind::Never => { self.s.word("!")?; }, - hir::TyTup(ref elts) => { + hir::TyKind::Tup(ref elts) => { self.popen()?; self.commasep(Inconsistent, &elts[..], |s, ty| s.print_type(&ty))?; if elts.len() == 1 { @@ -396,14 +396,14 @@ impl<'a> State<'a> { } self.pclose()?; } - hir::TyBareFn(ref f) => { + hir::TyKind::BareFn(ref f) => { self.print_ty_fn(f.abi, f.unsafety, &f.decl, None, &f.generic_params, &f.arg_names[..])?; } - hir::TyPath(ref qpath) => { + hir::TyKind::Path(ref qpath) => { self.print_qpath(qpath, false)? } - hir::TyTraitObject(ref bounds, ref lifetime) => { + hir::TyKind::TraitObject(ref bounds, ref lifetime) => { let mut first = true; for bound in bounds { if first { @@ -420,22 +420,22 @@ impl<'a> State<'a> { self.print_lifetime(lifetime)?; } } - hir::TyArray(ref ty, ref length) => { + hir::TyKind::Array(ref ty, ref length) => { self.s.word("[")?; self.print_type(&ty)?; self.s.word("; ")?; self.print_anon_const(length)?; self.s.word("]")?; } - hir::TyTypeof(ref e) => { + hir::TyKind::Typeof(ref e) => { self.s.word("typeof(")?; self.print_anon_const(e)?; self.s.word(")")?; } - hir::TyInfer => { + hir::TyKind::Infer => { self.s.word("_")?; } - hir::TyErr => { + hir::TyKind::Err => { self.s.word("?")?; } } @@ -447,7 +447,7 @@ impl<'a> State<'a> { self.maybe_print_comment(item.span.lo())?; self.print_outer_attributes(&item.attrs)?; match item.node { - hir::ForeignItemFn(ref decl, ref arg_names, ref generics) => { + hir::ForeignItemKind::Fn(ref decl, ref arg_names, ref generics) => { self.head("")?; self.print_fn(decl, hir::FnHeader { @@ -465,7 +465,7 @@ impl<'a> State<'a> { self.s.word(";")?; self.end() // end the outer fn box } - hir::ForeignItemStatic(ref t, m) => { + hir::ForeignItemKind::Static(ref t, m) => { self.head(&visibility_qualified(&item.vis, "static"))?; if m { self.word_space("mut")?; @@ -477,7 +477,7 @@ impl<'a> State<'a> { self.end()?; // end the head-ibox self.end() // end the outer cbox } - hir::ForeignItemType => { + hir::ForeignItemKind::Type => { self.head(&visibility_qualified(&item.vis, "type"))?; self.print_name(item.name)?; self.s.word(";")?; @@ -531,7 +531,7 @@ impl<'a> State<'a> { self.print_outer_attributes(&item.attrs)?; self.ann.pre(self, NodeItem(item))?; match item.node { - hir::ItemExternCrate(orig_name) => { + hir::ItemKind::ExternCrate(orig_name) => { self.head(&visibility_qualified(&item.vis, "extern crate"))?; if let Some(orig_name) = orig_name { self.print_name(orig_name)?; @@ -544,7 +544,7 @@ impl<'a> State<'a> { self.end()?; // end inner head-block self.end()?; // end outer head-block } - hir::ItemUse(ref path, kind) => { + hir::ItemKind::Use(ref path, kind) => { self.head(&visibility_qualified(&item.vis, "use"))?; self.print_path(path, false)?; @@ -563,7 +563,7 @@ impl<'a> State<'a> { self.end()?; // end inner head-block self.end()?; // end outer head-block } - hir::ItemStatic(ref ty, m, expr) => { + hir::ItemKind::Static(ref ty, m, expr) => { self.head(&visibility_qualified(&item.vis, "static"))?; if m == hir::MutMutable { self.word_space("mut")?; @@ -579,7 +579,7 @@ impl<'a> State<'a> { self.s.word(";")?; self.end()?; // end the outer cbox } - hir::ItemConst(ref ty, expr) => { + hir::ItemKind::Const(ref ty, expr) => { self.head(&visibility_qualified(&item.vis, "const"))?; self.print_name(item.name)?; self.word_space(":")?; @@ -592,7 +592,7 @@ impl<'a> State<'a> { self.s.word(";")?; self.end()?; // end the outer cbox } - hir::ItemFn(ref decl, header, ref typarams, body) => { + hir::ItemKind::Fn(ref decl, header, ref typarams, body) => { self.head("")?; self.print_fn(decl, header, @@ -606,7 +606,7 @@ impl<'a> State<'a> { self.end()?; // need to close a box self.ann.nested(self, Nested::Body(body))?; } - hir::ItemMod(ref _mod) => { + hir::ItemKind::Mod(ref _mod) => { self.head(&visibility_qualified(&item.vis, "mod"))?; self.print_name(item.name)?; self.nbsp()?; @@ -614,19 +614,19 @@ impl<'a> State<'a> { self.print_mod(_mod, &item.attrs)?; self.bclose(item.span)?; } - hir::ItemForeignMod(ref nmod) => { + hir::ItemKind::ForeignMod(ref nmod) => { self.head("extern")?; self.word_nbsp(&nmod.abi.to_string())?; self.bopen()?; self.print_foreign_mod(nmod, &item.attrs)?; self.bclose(item.span)?; } - hir::ItemGlobalAsm(ref ga) => { + hir::ItemKind::GlobalAsm(ref ga) => { self.head(&visibility_qualified(&item.vis, "global asm"))?; self.s.word(&ga.asm.as_str())?; self.end()? } - hir::ItemTy(ref ty, ref generics) => { + hir::ItemKind::Ty(ref ty, ref generics) => { self.ibox(indent_unit)?; self.ibox(0)?; self.word_nbsp(&visibility_qualified(&item.vis, "type"))?; @@ -641,7 +641,7 @@ impl<'a> State<'a> { self.s.word(";")?; self.end()?; // end the outer ibox } - hir::ItemExistential(ref exist) => { + hir::ItemKind::Existential(ref exist) => { self.ibox(indent_unit)?; self.ibox(0)?; self.word_nbsp(&visibility_qualified(&item.vis, "existential type"))?; @@ -666,18 +666,18 @@ impl<'a> State<'a> { self.s.word(";")?; self.end()?; // end the outer ibox } - hir::ItemEnum(ref enum_definition, ref params) => { + hir::ItemKind::Enum(ref enum_definition, ref params) => { self.print_enum_def(enum_definition, params, item.name, item.span, &item.vis)?; } - hir::ItemStruct(ref struct_def, ref generics) => { + hir::ItemKind::Struct(ref struct_def, ref generics) => { self.head(&visibility_qualified(&item.vis, "struct"))?; self.print_struct(struct_def, generics, item.name, item.span, true)?; } - hir::ItemUnion(ref struct_def, ref generics) => { + hir::ItemKind::Union(ref struct_def, ref generics) => { self.head(&visibility_qualified(&item.vis, "union"))?; self.print_struct(struct_def, generics, item.name, item.span, true)?; } - hir::ItemImpl(unsafety, + hir::ItemKind::Impl(unsafety, polarity, defaultness, ref generics, @@ -722,7 +722,7 @@ impl<'a> State<'a> { } self.bclose(item.span)?; } - hir::ItemTrait(is_auto, unsafety, ref generics, ref bounds, ref trait_items) => { + hir::ItemKind::Trait(is_auto, unsafety, ref generics, ref bounds, ref trait_items) => { self.head("")?; self.print_visibility(&item.vis)?; self.print_is_auto(is_auto)?; @@ -749,7 +749,7 @@ impl<'a> State<'a> { } self.bclose(item.span)?; } - hir::ItemTraitAlias(ref generics, ref bounds) => { + hir::ItemKind::TraitAlias(ref generics, ref bounds) => { self.head("")?; self.print_visibility(&item.vis)?; self.word_nbsp("trait")?; @@ -1001,14 +1001,14 @@ impl<'a> State<'a> { pub fn print_stmt(&mut self, st: &hir::Stmt) -> io::Result<()> { self.maybe_print_comment(st.span.lo())?; match st.node { - hir::StmtDecl(ref decl, _) => { + hir::StmtKind::Decl(ref decl, _) => { self.print_decl(&decl)?; } - hir::StmtExpr(ref expr, _) => { + hir::StmtKind::Expr(ref expr, _) => { self.space_if_not_bol()?; self.print_expr(&expr)?; } - hir::StmtSemi(ref expr, _) => { + hir::StmtKind::Semi(ref expr, _) => { self.space_if_not_bol()?; self.print_expr(&expr)?; self.s.word(";")?; @@ -1080,7 +1080,7 @@ impl<'a> State<'a> { Some(_else) => { match _else.node { // "another else-if" - hir::ExprIf(ref i, ref then, ref e) => { + hir::ExprKind::If(ref i, ref then, ref e) => { self.cbox(indent_unit - 1)?; self.ibox(0)?; self.s.word(" else if ")?; @@ -1090,7 +1090,7 @@ impl<'a> State<'a> { self.print_else(e.as_ref().map(|e| &**e)) } // "final else" - hir::ExprBlock(ref b, _) => { + hir::ExprKind::Block(ref b, _) => { self.cbox(indent_unit - 1)?; self.ibox(0)?; self.s.word(" else ")?; @@ -1162,9 +1162,9 @@ impl<'a> State<'a> { let needs_par = match expr.node { // These cases need parens due to the parse error observed in #26461: `if return {}` // parses as the erroneous construct `if (return {})`, not `if (return) {}`. - hir::ExprClosure(..) | - hir::ExprRet(..) | - hir::ExprBreak(..) => true, + hir::ExprKind::Closure(..) | + hir::ExprKind::Ret(..) | + hir::ExprKind::Break(..) => true, _ => contains_exterior_struct_lit(expr), }; @@ -1247,7 +1247,7 @@ impl<'a> State<'a> { fn print_expr_call(&mut self, func: &hir::Expr, args: &[hir::Expr]) -> io::Result<()> { let prec = match func.node { - hir::ExprField(..) => parser::PREC_FORCE_PAREN, + hir::ExprKind::Field(..) => parser::PREC_FORCE_PAREN, _ => parser::PREC_POSTFIX, }; @@ -1292,8 +1292,8 @@ impl<'a> State<'a> { // These cases need parens: `x as i32 < y` has the parser thinking that `i32 < y` is // the beginning of a path type. It starts trying to parse `x as (i32 < y ...` instead // of `(x as i32) < ...`. We need to convince it _not_ to do that. - (&hir::ExprCast { .. }, hir::BinOp_::BiLt) | - (&hir::ExprCast { .. }, hir::BinOp_::BiShl) => parser::PREC_FORCE_PAREN, + (&hir::ExprKind::Cast { .. }, hir::BinOpKind::Lt) | + (&hir::ExprKind::Cast { .. }, hir::BinOpKind::Shl) => parser::PREC_FORCE_PAREN, _ => left_prec, }; @@ -1323,57 +1323,57 @@ impl<'a> State<'a> { self.ibox(indent_unit)?; self.ann.pre(self, NodeExpr(expr))?; match expr.node { - hir::ExprBox(ref expr) => { + hir::ExprKind::Box(ref expr) => { self.word_space("box")?; self.print_expr_maybe_paren(expr, parser::PREC_PREFIX)?; } - hir::ExprArray(ref exprs) => { + hir::ExprKind::Array(ref exprs) => { self.print_expr_vec(exprs)?; } - hir::ExprRepeat(ref element, ref count) => { + hir::ExprKind::Repeat(ref element, ref count) => { self.print_expr_repeat(&element, count)?; } - hir::ExprStruct(ref qpath, ref fields, ref wth) => { + hir::ExprKind::Struct(ref qpath, ref fields, ref wth) => { self.print_expr_struct(qpath, &fields[..], wth)?; } - hir::ExprTup(ref exprs) => { + hir::ExprKind::Tup(ref exprs) => { self.print_expr_tup(exprs)?; } - hir::ExprCall(ref func, ref args) => { + hir::ExprKind::Call(ref func, ref args) => { self.print_expr_call(&func, args)?; } - hir::ExprMethodCall(ref segment, _, ref args) => { + hir::ExprKind::MethodCall(ref segment, _, ref args) => { self.print_expr_method_call(segment, args)?; } - hir::ExprBinary(op, ref lhs, ref rhs) => { + hir::ExprKind::Binary(op, ref lhs, ref rhs) => { self.print_expr_binary(op, &lhs, &rhs)?; } - hir::ExprUnary(op, ref expr) => { + hir::ExprKind::Unary(op, ref expr) => { self.print_expr_unary(op, &expr)?; } - hir::ExprAddrOf(m, ref expr) => { + hir::ExprKind::AddrOf(m, ref expr) => { self.print_expr_addr_of(m, &expr)?; } - hir::ExprLit(ref lit) => { + hir::ExprKind::Lit(ref lit) => { self.print_literal(&lit)?; } - hir::ExprCast(ref expr, ref ty) => { + hir::ExprKind::Cast(ref expr, ref ty) => { let prec = AssocOp::As.precedence() as i8; self.print_expr_maybe_paren(&expr, prec)?; self.s.space()?; self.word_space("as")?; self.print_type(&ty)?; } - hir::ExprType(ref expr, ref ty) => { + hir::ExprKind::Type(ref expr, ref ty) => { let prec = AssocOp::Colon.precedence() as i8; self.print_expr_maybe_paren(&expr, prec)?; self.word_space(":")?; self.print_type(&ty)?; } - hir::ExprIf(ref test, ref blk, ref elseopt) => { + hir::ExprKind::If(ref test, ref blk, ref elseopt) => { self.print_if(&test, &blk, elseopt.as_ref().map(|e| &**e))?; } - hir::ExprWhile(ref test, ref blk, opt_label) => { + hir::ExprKind::While(ref test, ref blk, opt_label) => { if let Some(label) = opt_label { self.print_ident(label.ident)?; self.word_space(":")?; @@ -1383,7 +1383,7 @@ impl<'a> State<'a> { self.s.space()?; self.print_block(&blk)?; } - hir::ExprLoop(ref blk, opt_label, _) => { + hir::ExprKind::Loop(ref blk, opt_label, _) => { if let Some(label) = opt_label { self.print_ident(label.ident)?; self.word_space(":")?; @@ -1392,7 +1392,7 @@ impl<'a> State<'a> { self.s.space()?; self.print_block(&blk)?; } - hir::ExprMatch(ref expr, ref arms, _) => { + hir::ExprKind::Match(ref expr, ref arms, _) => { self.cbox(indent_unit)?; self.ibox(4)?; self.word_nbsp("match")?; @@ -1404,7 +1404,7 @@ impl<'a> State<'a> { } self.bclose_(expr.span, indent_unit)?; } - hir::ExprClosure(capture_clause, ref decl, body, _fn_decl_span, _gen) => { + hir::ExprKind::Closure(capture_clause, ref decl, body, _fn_decl_span, _gen) => { self.print_capture_clause(capture_clause)?; self.print_closure_args(&decl, body)?; @@ -1419,7 +1419,7 @@ impl<'a> State<'a> { // empty box to satisfy the close. self.ibox(0)?; } - hir::ExprBlock(ref blk, opt_label) => { + hir::ExprKind::Block(ref blk, opt_label) => { if let Some(label) = opt_label { self.print_ident(label.ident)?; self.word_space(":")?; @@ -1430,14 +1430,14 @@ impl<'a> State<'a> { self.ibox(0)?; self.print_block(&blk)?; } - hir::ExprAssign(ref lhs, ref rhs) => { + hir::ExprKind::Assign(ref lhs, ref rhs) => { let prec = AssocOp::Assign.precedence() as i8; self.print_expr_maybe_paren(&lhs, prec + 1)?; self.s.space()?; self.word_space("=")?; self.print_expr_maybe_paren(&rhs, prec)?; } - hir::ExprAssignOp(op, ref lhs, ref rhs) => { + hir::ExprKind::AssignOp(op, ref lhs, ref rhs) => { let prec = AssocOp::Assign.precedence() as i8; self.print_expr_maybe_paren(&lhs, prec + 1)?; self.s.space()?; @@ -1445,21 +1445,21 @@ impl<'a> State<'a> { self.word_space("=")?; self.print_expr_maybe_paren(&rhs, prec)?; } - hir::ExprField(ref expr, ident) => { + hir::ExprKind::Field(ref expr, ident) => { self.print_expr_maybe_paren(expr, parser::PREC_POSTFIX)?; self.s.word(".")?; self.print_ident(ident)?; } - hir::ExprIndex(ref expr, ref index) => { + hir::ExprKind::Index(ref expr, ref index) => { self.print_expr_maybe_paren(&expr, parser::PREC_POSTFIX)?; self.s.word("[")?; self.print_expr(&index)?; self.s.word("]")?; } - hir::ExprPath(ref qpath) => { + hir::ExprKind::Path(ref qpath) => { self.print_qpath(qpath, true)? } - hir::ExprBreak(destination, ref opt_expr) => { + hir::ExprKind::Break(destination, ref opt_expr) => { self.s.word("break")?; self.s.space()?; if let Some(label) = destination.label { @@ -1471,7 +1471,7 @@ impl<'a> State<'a> { self.s.space()?; } } - hir::ExprContinue(destination) => { + hir::ExprKind::Continue(destination) => { self.s.word("continue")?; self.s.space()?; if let Some(label) = destination.label { @@ -1479,7 +1479,7 @@ impl<'a> State<'a> { self.s.space()? } } - hir::ExprRet(ref result) => { + hir::ExprKind::Ret(ref result) => { self.s.word("return")?; match *result { Some(ref expr) => { @@ -1489,7 +1489,7 @@ impl<'a> State<'a> { _ => (), } } - hir::ExprInlineAsm(ref a, ref outputs, ref inputs) => { + hir::ExprKind::InlineAsm(ref a, ref outputs, ref inputs) => { self.s.word("asm!")?; self.popen()?; self.print_string(&a.asm.as_str(), a.asm_str_style)?; @@ -1554,7 +1554,7 @@ impl<'a> State<'a> { self.pclose()?; } - hir::ExprYield(ref expr) => { + hir::ExprKind::Yield(ref expr) => { self.word_space("yield")?; self.print_expr_maybe_paren(&expr, parser::PREC_JUMP)?; } @@ -1575,7 +1575,7 @@ impl<'a> State<'a> { pub fn print_decl(&mut self, decl: &hir::Decl) -> io::Result<()> { self.maybe_print_comment(decl.span.lo())?; match decl.node { - hir::DeclLocal(ref loc) => { + hir::DeclKind::Local(ref loc) => { self.space_if_not_bol()?; self.ibox(indent_unit)?; self.word_nbsp("let")?; @@ -1590,7 +1590,7 @@ impl<'a> State<'a> { } self.end() } - hir::DeclItem(item) => { + hir::DeclKind::Item(item) => { self.ann.nested(self, Nested::Item(item)) } } @@ -1959,7 +1959,7 @@ impl<'a> State<'a> { self.word_space("=>")?; match arm.body.node { - hir::ExprBlock(ref blk, opt_label) => { + hir::ExprKind::Block(ref blk, opt_label) => { if let Some(label) = opt_label { self.print_ident(label.ident)?; self.word_space(":")?; @@ -2035,7 +2035,7 @@ impl<'a> State<'a> { s.ann.nested(s, Nested::BodyArgPat(body_id, i))?; i += 1; - if let hir::TyInfer = ty.node { + if let hir::TyKind::Infer = ty.node { // Print nothing } else { s.s.word(":")?; @@ -2384,11 +2384,11 @@ impl<'a> State<'a> { /// isn't parsed as (if true {...} else {...} | x) | 5 fn expr_requires_semi_to_be_stmt(e: &hir::Expr) -> bool { match e.node { - hir::ExprIf(..) | - hir::ExprMatch(..) | - hir::ExprBlock(..) | - hir::ExprWhile(..) | - hir::ExprLoop(..) => false, + hir::ExprKind::If(..) | + hir::ExprKind::Match(..) | + hir::ExprKind::Block(..) | + hir::ExprKind::While(..) | + hir::ExprKind::Loop(..) => false, _ => true, } } @@ -2396,47 +2396,47 @@ fn expr_requires_semi_to_be_stmt(e: &hir::Expr) -> bool { /// this statement requires a semicolon after it. /// note that in one case (stmt_semi), we've already /// seen the semicolon, and thus don't need another. -fn stmt_ends_with_semi(stmt: &hir::Stmt_) -> bool { +fn stmt_ends_with_semi(stmt: &hir::StmtKind) -> bool { match *stmt { - hir::StmtDecl(ref d, _) => { + hir::StmtKind::Decl(ref d, _) => { match d.node { - hir::DeclLocal(_) => true, - hir::DeclItem(_) => false, + hir::DeclKind::Local(_) => true, + hir::DeclKind::Item(_) => false, } } - hir::StmtExpr(ref e, _) => { + hir::StmtKind::Expr(ref e, _) => { expr_requires_semi_to_be_stmt(&e) } - hir::StmtSemi(..) => { + hir::StmtKind::Semi(..) => { false } } } -fn bin_op_to_assoc_op(op: hir::BinOp_) -> AssocOp { - use hir::BinOp_::*; +fn bin_op_to_assoc_op(op: hir::BinOpKind) -> AssocOp { + use hir::BinOpKind::*; match op { - BiAdd => AssocOp::Add, - BiSub => AssocOp::Subtract, - BiMul => AssocOp::Multiply, - BiDiv => AssocOp::Divide, - BiRem => AssocOp::Modulus, - - BiAnd => AssocOp::LAnd, - BiOr => AssocOp::LOr, - - BiBitXor => AssocOp::BitXor, - BiBitAnd => AssocOp::BitAnd, - BiBitOr => AssocOp::BitOr, - BiShl => AssocOp::ShiftLeft, - BiShr => AssocOp::ShiftRight, - - BiEq => AssocOp::Equal, - BiLt => AssocOp::Less, - BiLe => AssocOp::LessEqual, - BiNe => AssocOp::NotEqual, - BiGe => AssocOp::GreaterEqual, - BiGt => AssocOp::Greater, + Add => AssocOp::Add, + Sub => AssocOp::Subtract, + Mul => AssocOp::Multiply, + Div => AssocOp::Divide, + Rem => AssocOp::Modulus, + + And => AssocOp::LAnd, + Or => AssocOp::LOr, + + BitXor => AssocOp::BitXor, + BitAnd => AssocOp::BitAnd, + BitOr => AssocOp::BitOr, + Shl => AssocOp::ShiftLeft, + Shr => AssocOp::ShiftRight, + + Eq => AssocOp::Equal, + Lt => AssocOp::Less, + Le => AssocOp::LessEqual, + Ne => AssocOp::NotEqual, + Ge => AssocOp::GreaterEqual, + Gt => AssocOp::Greater, } } @@ -2445,24 +2445,24 @@ fn bin_op_to_assoc_op(op: hir::BinOp_) -> AssocOp { /// `X { y: 1 } == foo` all do, but `(X { y: 1 }) == foo` does not. fn contains_exterior_struct_lit(value: &hir::Expr) -> bool { match value.node { - hir::ExprStruct(..) => true, + hir::ExprKind::Struct(..) => true, - hir::ExprAssign(ref lhs, ref rhs) | - hir::ExprAssignOp(_, ref lhs, ref rhs) | - hir::ExprBinary(_, ref lhs, ref rhs) => { + hir::ExprKind::Assign(ref lhs, ref rhs) | + hir::ExprKind::AssignOp(_, ref lhs, ref rhs) | + hir::ExprKind::Binary(_, ref lhs, ref rhs) => { // X { y: 1 } + X { y: 2 } contains_exterior_struct_lit(&lhs) || contains_exterior_struct_lit(&rhs) } - hir::ExprUnary(_, ref x) | - hir::ExprCast(ref x, _) | - hir::ExprType(ref x, _) | - hir::ExprField(ref x, _) | - hir::ExprIndex(ref x, _) => { + hir::ExprKind::Unary(_, ref x) | + hir::ExprKind::Cast(ref x, _) | + hir::ExprKind::Type(ref x, _) | + hir::ExprKind::Field(ref x, _) | + hir::ExprKind::Index(ref x, _) => { // &X { y: 1 }, X { y: 1 }.y contains_exterior_struct_lit(&x) } - hir::ExprMethodCall(.., ref exprs) => { + hir::ExprKind::MethodCall(.., ref exprs) => { // X { y: 1 }.bar(...) contains_exterior_struct_lit(&exprs[0]) } diff --git a/src/librustc/ich/impls_hir.rs b/src/librustc/ich/impls_hir.rs index b6add3e6f12..d1fb05ceafb 100644 --- a/src/librustc/ich/impls_hir.rs +++ b/src/librustc/ich/impls_hir.rs @@ -330,19 +330,19 @@ impl_stable_hash_for!(struct hir::ExistTy { bounds }); -impl_stable_hash_for!(enum hir::Ty_ { - TySlice(t), - TyArray(t, body_id), - TyPtr(t), - TyRptr(lifetime, t), - TyBareFn(t), - TyNever, - TyTup(ts), - TyPath(qpath), - TyTraitObject(trait_refs, lifetime), - TyTypeof(body_id), - TyErr, - TyInfer +impl_stable_hash_for!(enum hir::TyKind { + Slice(t), + Array(t, body_id), + Ptr(t), + Rptr(lifetime, t), + BareFn(t), + Never, + Tup(ts), + Path(qpath), + TraitObject(trait_refs, lifetime), + Typeof(body_id), + Err, + Infer }); impl_stable_hash_for!(struct hir::FnDecl { @@ -437,28 +437,28 @@ impl_stable_hash_for!(enum hir::PatKind { Slice(one, two, three) }); -impl_stable_hash_for!(enum hir::BinOp_ { - BiAdd, - BiSub, - BiMul, - BiDiv, - BiRem, - BiAnd, - BiOr, - BiBitXor, - BiBitAnd, - BiBitOr, - BiShl, - BiShr, - BiEq, - BiLt, - BiLe, - BiNe, - BiGe, - BiGt -}); - -impl_stable_hash_for_spanned!(hir::BinOp_); +impl_stable_hash_for!(enum hir::BinOpKind { + Add, + Sub, + Mul, + Div, + Rem, + And, + Or, + BitXor, + BitAnd, + BitOr, + Shl, + Shr, + Eq, + Lt, + Le, + Ne, + Ge, + Gt +}); + +impl_stable_hash_for_spanned!(hir::BinOpKind); impl_stable_hash_for!(enum hir::UnOp { UnDeref, @@ -466,7 +466,7 @@ impl_stable_hash_for!(enum hir::UnOp { UnNeg }); -impl_stable_hash_for_spanned!(hir::Stmt_); +impl_stable_hash_for_spanned!(hir::StmtKind); impl_stable_hash_for!(struct hir::Local { pat, @@ -479,10 +479,10 @@ impl_stable_hash_for!(struct hir::Local { source }); -impl_stable_hash_for_spanned!(hir::Decl_); -impl_stable_hash_for!(enum hir::Decl_ { - DeclLocal(local), - DeclItem(item_id) +impl_stable_hash_for_spanned!(hir::DeclKind); +impl_stable_hash_for!(enum hir::DeclKind { + Local(local), + Item(item_id) }); impl_stable_hash_for!(struct hir::Arm { @@ -541,36 +541,36 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::Expr { } } -impl_stable_hash_for!(enum hir::Expr_ { - ExprBox(sub), - ExprArray(subs), - ExprCall(callee, args), - ExprMethodCall(segment, span, args), - ExprTup(fields), - ExprBinary(op, lhs, rhs), - ExprUnary(op, operand), - ExprLit(value), - ExprCast(expr, t), - ExprType(expr, t), - ExprIf(cond, then, els), - ExprWhile(cond, body, label), - ExprLoop(body, label, loop_src), - ExprMatch(matchee, arms, match_src), - ExprClosure(capture_clause, decl, body_id, span, gen), - ExprBlock(blk, label), - ExprAssign(lhs, rhs), - ExprAssignOp(op, lhs, rhs), - ExprField(owner, ident), - ExprIndex(lhs, rhs), - ExprPath(path), - ExprAddrOf(mutability, sub), - ExprBreak(destination, sub), - ExprContinue(destination), - ExprRet(val), - ExprInlineAsm(asm, inputs, outputs), - ExprStruct(path, fields, base), - ExprRepeat(val, times), - ExprYield(val) +impl_stable_hash_for!(enum hir::ExprKind { + Box(sub), + Array(subs), + Call(callee, args), + MethodCall(segment, span, args), + Tup(fields), + Binary(op, lhs, rhs), + Unary(op, operand), + Lit(value), + Cast(expr, t), + Type(expr, t), + If(cond, then, els), + While(cond, body, label), + Loop(body, label, loop_src), + Match(matchee, arms, match_src), + Closure(capture_clause, decl, body_id, span, gen), + Block(blk, label), + Assign(lhs, rhs), + AssignOp(op, lhs, rhs), + Field(owner, ident), + Index(lhs, rhs), + Path(path), + AddrOf(mutability, sub), + Break(destination, sub), + Continue(destination), + Ret(val), + InlineAsm(asm, inputs, outputs), + Struct(path, fields, base), + Repeat(val, times), + Yield(val) }); impl_stable_hash_for!(enum hir::LocalSource { @@ -793,14 +793,14 @@ impl_stable_hash_for!(struct hir::EnumDef { variants }); -impl_stable_hash_for!(struct hir::Variant_ { +impl_stable_hash_for!(struct hir::VariantKind { name, attrs, data, disr_expr }); -impl_stable_hash_for_spanned!(hir::Variant_); +impl_stable_hash_for_spanned!(hir::VariantKind); impl_stable_hash_for!(enum hir::UseKind { Single, @@ -847,23 +847,23 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::Item { } } -impl_stable_hash_for!(enum hir::Item_ { - ItemExternCrate(orig_name), - ItemUse(path, use_kind), - ItemStatic(ty, mutability, body_id), - ItemConst(ty, body_id), - ItemFn(fn_decl, header, generics, body_id), - ItemMod(module), - ItemForeignMod(foreign_mod), - ItemGlobalAsm(global_asm), - ItemTy(ty, generics), - ItemExistential(exist), - ItemEnum(enum_def, generics), - ItemStruct(variant_data, generics), - ItemUnion(variant_data, generics), - ItemTrait(is_auto, unsafety, generics, bounds, item_refs), - ItemTraitAlias(generics, bounds), - ItemImpl(unsafety, impl_polarity, impl_defaultness, generics, trait_ref, ty, impl_item_refs) +impl_stable_hash_for!(enum hir::ItemKind { + ExternCrate(orig_name), + Use(path, use_kind), + Static(ty, mutability, body_id), + Const(ty, body_id), + Fn(fn_decl, header, generics, body_id), + Mod(module), + ForeignMod(foreign_mod), + GlobalAsm(global_asm), + Ty(ty, generics), + Existential(exist), + Enum(enum_def, generics), + Struct(variant_data, generics), + Union(variant_data, generics), + Trait(is_auto, unsafety, generics, bounds, item_refs), + TraitAlias(generics, bounds), + Impl(unsafety, impl_polarity, impl_defaultness, generics, trait_ref, ty, impl_item_refs) }); impl_stable_hash_for!(struct hir::TraitItemRef { @@ -909,16 +909,16 @@ impl_stable_hash_for!(struct hir::ForeignItem { vis }); -impl_stable_hash_for!(enum hir::ForeignItem_ { - ForeignItemFn(fn_decl, arg_names, generics), - ForeignItemStatic(ty, is_mutbl), - ForeignItemType +impl_stable_hash_for!(enum hir::ForeignItemKind { + Fn(fn_decl, arg_names, generics), + Static(ty, is_mutbl), + Type }); -impl_stable_hash_for!(enum hir::Stmt_ { - StmtDecl(decl, id), - StmtExpr(expr, id), - StmtSemi(expr, id) +impl_stable_hash_for!(enum hir::StmtKind { + Decl(decl, id), + Expr(expr, id), + Semi(expr, id) }); impl_stable_hash_for!(struct hir::Arg { diff --git a/src/librustc/infer/anon_types/mod.rs b/src/librustc/infer/anon_types/mod.rs index 5487da97d5b..2924016670b 100644 --- a/src/librustc/infer/anon_types/mod.rs +++ b/src/librustc/infer/anon_types/mod.rs @@ -691,7 +691,7 @@ impl<'a, 'gcx, 'tcx> Instantiator<'a, 'gcx, 'tcx> { // ``` if let Some(anon_node_id) = tcx.hir.as_local_node_id(def_id) { let anon_parent_def_id = match tcx.hir.expect_item(anon_node_id).node { - hir::ItemExistential(hir::ExistTy { + hir::ItemKind::Existential(hir::ExistTy { impl_trait_fn: Some(parent), .. }) => parent, diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs index 432826238db..8da0dc365b0 100644 --- a/src/librustc/infer/error_reporting/mod.rs +++ b/src/librustc/infer/error_reporting/mod.rs @@ -102,12 +102,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { let tag = match self.hir.find(scope.node_id(self, region_scope_tree)) { Some(hir_map::NodeBlock(_)) => "block", Some(hir_map::NodeExpr(expr)) => match expr.node { - hir::ExprCall(..) => "call", - hir::ExprMethodCall(..) => "method call", - hir::ExprMatch(.., hir::MatchSource::IfLetDesugar { .. }) => "if let", - hir::ExprMatch(.., hir::MatchSource::WhileLetDesugar) => "while let", - hir::ExprMatch(.., hir::MatchSource::ForLoopDesugar) => "for", - hir::ExprMatch(..) => "match", + hir::ExprKind::Call(..) => "call", + hir::ExprKind::MethodCall(..) => "method call", + hir::ExprKind::Match(.., hir::MatchSource::IfLetDesugar { .. }) => "if let", + hir::ExprKind::Match(.., hir::MatchSource::WhileLetDesugar) => "while let", + hir::ExprKind::Match(.., hir::MatchSource::ForLoopDesugar) => "for", + hir::ExprKind::Match(..) => "match", _ => "expression", }, Some(hir_map::NodeStmt(_)) => "statement", @@ -259,12 +259,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { fn item_scope_tag(item: &hir::Item) -> &'static str { match item.node { - hir::ItemImpl(..) => "impl", - hir::ItemStruct(..) => "struct", - hir::ItemUnion(..) => "union", - hir::ItemEnum(..) => "enum", - hir::ItemTrait(..) => "trait", - hir::ItemFn(..) => "function body", + hir::ItemKind::Impl(..) => "impl", + hir::ItemKind::Struct(..) => "struct", + hir::ItemKind::Union(..) => "union", + hir::ItemKind::Enum(..) => "enum", + hir::ItemKind::Trait(..) => "trait", + hir::ItemKind::Fn(..) => "function body", _ => "item", } } diff --git a/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs b/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs index b148a7401f8..21be09b0ba1 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs @@ -41,7 +41,7 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { if let Some(node_id) = self.tcx.hir.as_local_node_id(def_id) { let fndecl = match self.tcx.hir.get(node_id) { hir_map::NodeItem(&hir::Item { - node: hir::ItemFn(ref fndecl, ..), + node: hir::ItemKind::Fn(ref fndecl, ..), .. }) => &fndecl, hir_map::NodeTraitItem(&hir::TraitItem { @@ -109,20 +109,20 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> { fn visit_ty(&mut self, arg: &'gcx hir::Ty) { match arg.node { - hir::TyBareFn(_) => { + hir::TyKind::BareFn(_) => { self.current_index.shift_in(1); intravisit::walk_ty(self, arg); self.current_index.shift_out(1); return; } - hir::TyTraitObject(ref bounds, _) => for bound in bounds { + hir::TyKind::TraitObject(ref bounds, _) => for bound in bounds { self.current_index.shift_in(1); self.visit_poly_trait_ref(bound, hir::TraitBoundModifier::None); self.current_index.shift_out(1); }, - hir::TyRptr(ref lifetime, _) => { + hir::TyKind::Rptr(ref lifetime, _) => { // the lifetime of the TyRptr let hir_id = self.tcx.hir.node_to_hir_id(lifetime.id); match (self.tcx.named_region(hir_id), self.bound_region) { @@ -190,8 +190,8 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> { } } } - // Checks if it is of type `hir::TyPath` which corresponds to a struct. - hir::TyPath(_) => { + // Checks if it is of type `hir::TyKind::Path` which corresponds to a struct. + hir::TyKind::Path(_) => { let subvisitor = &mut TyPathVisitor { tcx: self.tcx, found_it: false, @@ -213,7 +213,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> { } // The visitor captures the corresponding `hir::Ty` of the anonymous region -// in the case of structs ie. `hir::TyPath`. +// in the case of structs ie. `hir::TyKind::Path`. // This visitor would be invoked for each lifetime corresponding to a struct, // and would walk the types like Vec<Ref> in the above example and Ref looking for the HIR // where that lifetime appears. This allows us to highlight the diff --git a/src/librustc/infer/error_reporting/nice_region_error/outlives_closure.rs b/src/librustc/infer/error_reporting/nice_region_error/outlives_closure.rs index 18b8c70c3ef..f4ef197e5b4 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/outlives_closure.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/outlives_closure.rs @@ -14,7 +14,7 @@ use infer::error_reporting::nice_region_error::NiceRegionError; use infer::SubregionOrigin; use ty::RegionKind; -use hir::{Expr, ExprClosure}; +use hir::{Expr, ExprKind::Closure}; use hir::map::NodeExpr; use util::common::ErrorReported; use infer::lexical_region_resolve::RegionResolutionError::SubSupConflict; @@ -60,7 +60,7 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { if let Some(node_id) = hir.as_local_node_id(free_region.scope) { match hir.get(node_id) { NodeExpr(Expr { - node: ExprClosure(_, _, _, closure_span, None), + node: Closure(_, _, _, closure_span, None), .. }) => { let sup_sp = sup_origin.span(); diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index 180469a5d84..da59bced760 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -153,21 +153,21 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> { match *node { hir_map::NodeItem(item) => { match item.node { - hir::ItemStruct(..) | hir::ItemUnion(..) => { + hir::ItemKind::Struct(..) | hir::ItemKind::Union(..) => { let def_id = self.tcx.hir.local_def_id(item.id); let def = self.tcx.adt_def(def_id); self.repr_has_repr_c = def.repr.c(); intravisit::walk_item(self, &item); } - hir::ItemEnum(..) => { + hir::ItemKind::Enum(..) => { self.inherited_pub_visibility = item.vis.node.is_pub(); intravisit::walk_item(self, &item); } - hir::ItemFn(..) - | hir::ItemTy(..) - | hir::ItemStatic(..) - | hir::ItemConst(..) => { + hir::ItemKind::Fn(..) + | hir::ItemKind::Ty(..) + | hir::ItemKind::Static(..) + | hir::ItemKind::Const(..) => { intravisit::walk_item(self, &item); } _ => () @@ -225,17 +225,17 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> { fn visit_expr(&mut self, expr: &'tcx hir::Expr) { match expr.node { - hir::ExprPath(ref qpath @ hir::QPath::TypeRelative(..)) => { + hir::ExprKind::Path(ref qpath @ hir::QPath::TypeRelative(..)) => { let def = self.tables.qpath_def(qpath, expr.hir_id); self.handle_definition(def); } - hir::ExprMethodCall(..) => { + hir::ExprKind::MethodCall(..) => { self.lookup_and_handle_method(expr.hir_id); } - hir::ExprField(ref lhs, ..) => { + hir::ExprKind::Field(ref lhs, ..) => { self.handle_field_access(&lhs, expr.id); } - hir::ExprStruct(_, ref fields, _) => { + hir::ExprKind::Struct(_, ref fields, _) => { if let ty::TypeVariants::TyAdt(ref adt, _) = self.tables.expr_ty(expr).sty { self.mark_as_used_if_union(adt, fields); } @@ -349,11 +349,11 @@ impl<'v, 'k, 'tcx> ItemLikeVisitor<'v> for LifeSeeder<'k, 'tcx> { self.worklist.push(item.id); } match item.node { - hir::ItemEnum(ref enum_def, _) if allow_dead_code => { + hir::ItemKind::Enum(ref enum_def, _) if allow_dead_code => { self.worklist.extend(enum_def.variants.iter() .map(|variant| variant.node.data.id())); } - hir::ItemTrait(.., ref trait_item_refs) => { + hir::ItemKind::Trait(.., ref trait_item_refs) => { for trait_item_ref in trait_item_refs { let trait_item = self.krate.trait_item(trait_item_ref.id); match trait_item.node { @@ -369,7 +369,7 @@ impl<'v, 'k, 'tcx> ItemLikeVisitor<'v> for LifeSeeder<'k, 'tcx> { } } } - hir::ItemImpl(.., ref opt_trait, _, ref impl_item_refs) => { + hir::ItemKind::Impl(.., ref opt_trait, _, ref impl_item_refs) => { for impl_item_ref in impl_item_refs { let impl_item = self.krate.impl_item(impl_item_ref.id); if opt_trait.is_some() || @@ -439,7 +439,7 @@ fn find_live<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn get_struct_ctor_id(item: &hir::Item) -> Option<ast::NodeId> { match item.node { - hir::ItemStruct(ref struct_def, _) if !struct_def.is_struct() => { + hir::ItemKind::Struct(ref struct_def, _) if !struct_def.is_struct() => { Some(struct_def.id()) } _ => None @@ -454,13 +454,13 @@ struct DeadVisitor<'a, 'tcx: 'a> { impl<'a, 'tcx> DeadVisitor<'a, 'tcx> { fn should_warn_about_item(&mut self, item: &hir::Item) -> bool { let should_warn = match item.node { - hir::ItemStatic(..) - | hir::ItemConst(..) - | hir::ItemFn(..) - | hir::ItemTy(..) - | hir::ItemEnum(..) - | hir::ItemStruct(..) - | hir::ItemUnion(..) => true, + hir::ItemKind::Static(..) + | hir::ItemKind::Const(..) + | hir::ItemKind::Fn(..) + | hir::ItemKind::Ty(..) + | hir::ItemKind::Enum(..) + | hir::ItemKind::Struct(..) + | hir::ItemKind::Union(..) => true, _ => false }; let ctor_id = get_struct_ctor_id(item); @@ -475,7 +475,7 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> { && !has_allow_dead_code_or_lang_attr(self.tcx, field.id, &field.attrs) } - fn should_warn_about_variant(&mut self, variant: &hir::Variant_) -> bool { + fn should_warn_about_variant(&mut self, variant: &hir::VariantKind) -> bool { !self.symbol_is_live(variant.data.id(), None) && !has_allow_dead_code_or_lang_attr(self.tcx, variant.data.id(), @@ -492,7 +492,7 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> { // `None` otherwise. // If the item is a struct_ctor, then either its `id` or // `ctor_id` (unwrapped) is in the live_symbols set. More specifically, - // DefMap maps the ExprPath of a struct_ctor to the node referred by + // DefMap maps the ExprKind::Path of a struct_ctor to the node referred by // `ctor_id`. On the other hand, in a statement like // `type <ident> <generics> = <ty>;` where <ty> refers to a struct_ctor, // DefMap maps <ty> to `id` instead. @@ -554,13 +554,13 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> { // For items that have a definition with a signature followed by a // block, point only at the signature. let span = match item.node { - hir::ItemFn(..) | - hir::ItemMod(..) | - hir::ItemEnum(..) | - hir::ItemStruct(..) | - hir::ItemUnion(..) | - hir::ItemTrait(..) | - hir::ItemImpl(..) => self.tcx.sess.codemap().def_span(item.span), + hir::ItemKind::Fn(..) | + hir::ItemKind::Mod(..) | + hir::ItemKind::Enum(..) | + hir::ItemKind::Struct(..) | + hir::ItemKind::Union(..) | + hir::ItemKind::Trait(..) | + hir::ItemKind::Impl(..) => self.tcx.sess.codemap().def_span(item.span), _ => item.span, }; self.warn_dead_code( diff --git a/src/librustc/middle/entry.rs b/src/librustc/middle/entry.rs index ebc79646662..feeb508d676 100644 --- a/src/librustc/middle/entry.rs +++ b/src/librustc/middle/entry.rs @@ -16,7 +16,7 @@ use syntax::ast::NodeId; use syntax::attr; use syntax::entry::EntryPointType; use syntax_pos::Span; -use hir::{Item, ItemFn, ImplItem, TraitItem}; +use hir::{Item, ItemKind, ImplItem, TraitItem}; use hir::itemlikevisit::ItemLikeVisitor; struct EntryContext<'a, 'tcx: 'a> { @@ -91,7 +91,7 @@ pub fn find_entry_point(session: &Session, // them in sync. fn entry_point_type(item: &Item, at_root: bool) -> EntryPointType { match item.node { - ItemFn(..) => { + ItemKind::Fn(..) => { if attr::contains_name(&item.attrs, "start") { EntryPointType::Start } else if attr::contains_name(&item.attrs, "main") { diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index a83aa47fd4f..5beafe2b601 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -392,43 +392,43 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> { self.walk_adjustment(expr); match expr.node { - hir::ExprPath(_) => { } + hir::ExprKind::Path(_) => { } - hir::ExprType(ref subexpr, _) => { + hir::ExprKind::Type(ref subexpr, _) => { self.walk_expr(&subexpr) } - hir::ExprUnary(hir::UnDeref, ref base) => { // *base + hir::ExprKind::Unary(hir::UnDeref, ref base) => { // *base self.select_from_expr(&base); } - hir::ExprField(ref base, _) => { // base.f + hir::ExprKind::Field(ref base, _) => { // base.f self.select_from_expr(&base); } - hir::ExprIndex(ref lhs, ref rhs) => { // lhs[rhs] + hir::ExprKind::Index(ref lhs, ref rhs) => { // lhs[rhs] self.select_from_expr(&lhs); self.consume_expr(&rhs); } - hir::ExprCall(ref callee, ref args) => { // callee(args) + hir::ExprKind::Call(ref callee, ref args) => { // callee(args) self.walk_callee(expr, &callee); self.consume_exprs(args); } - hir::ExprMethodCall(.., ref args) => { // callee.m(args) + hir::ExprKind::MethodCall(.., ref args) => { // callee.m(args) self.consume_exprs(args); } - hir::ExprStruct(_, ref fields, ref opt_with) => { + hir::ExprKind::Struct(_, ref fields, ref opt_with) => { self.walk_struct_expr(fields, opt_with); } - hir::ExprTup(ref exprs) => { + hir::ExprKind::Tup(ref exprs) => { self.consume_exprs(exprs); } - hir::ExprIf(ref cond_expr, ref then_expr, ref opt_else_expr) => { + hir::ExprKind::If(ref cond_expr, ref then_expr, ref opt_else_expr) => { self.consume_expr(&cond_expr); self.walk_expr(&then_expr); if let Some(ref else_expr) = *opt_else_expr { @@ -436,7 +436,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> { } } - hir::ExprMatch(ref discr, ref arms, _) => { + hir::ExprKind::Match(ref discr, ref arms, _) => { let discr_cmt = Rc::new(return_if_err!(self.mc.cat_expr(&discr))); let r = self.tcx().types.re_empty; self.borrow_expr(&discr, r, ty::ImmBorrow, MatchDiscriminant); @@ -449,11 +449,11 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> { } } - hir::ExprArray(ref exprs) => { + hir::ExprKind::Array(ref exprs) => { self.consume_exprs(exprs); } - hir::ExprAddrOf(m, ref base) => { // &base + hir::ExprKind::AddrOf(m, ref base) => { // &base // make sure that the thing we are pointing out stays valid // for the lifetime `scope_r` of the resulting ptr: let expr_ty = return_if_err!(self.mc.expr_ty(expr)); @@ -463,7 +463,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> { } } - hir::ExprInlineAsm(ref ia, ref outputs, ref inputs) => { + hir::ExprKind::InlineAsm(ref ia, ref outputs, ref inputs) => { for (o, output) in ia.outputs.iter().zip(outputs) { if o.is_indirect { self.consume_expr(output); @@ -479,47 +479,47 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> { self.consume_exprs(inputs); } - hir::ExprContinue(..) | - hir::ExprLit(..) => {} + hir::ExprKind::Continue(..) | + hir::ExprKind::Lit(..) => {} - hir::ExprLoop(ref blk, _, _) => { + hir::ExprKind::Loop(ref blk, _, _) => { self.walk_block(&blk); } - hir::ExprWhile(ref cond_expr, ref blk, _) => { + hir::ExprKind::While(ref cond_expr, ref blk, _) => { self.consume_expr(&cond_expr); self.walk_block(&blk); } - hir::ExprUnary(_, ref lhs) => { + hir::ExprKind::Unary(_, ref lhs) => { self.consume_expr(&lhs); } - hir::ExprBinary(_, ref lhs, ref rhs) => { + hir::ExprKind::Binary(_, ref lhs, ref rhs) => { self.consume_expr(&lhs); self.consume_expr(&rhs); } - hir::ExprBlock(ref blk, _) => { + hir::ExprKind::Block(ref blk, _) => { self.walk_block(&blk); } - hir::ExprBreak(_, ref opt_expr) | hir::ExprRet(ref opt_expr) => { + hir::ExprKind::Break(_, ref opt_expr) | hir::ExprKind::Ret(ref opt_expr) => { if let Some(ref expr) = *opt_expr { self.consume_expr(&expr); } } - hir::ExprAssign(ref lhs, ref rhs) => { + hir::ExprKind::Assign(ref lhs, ref rhs) => { self.mutate_expr(expr, &lhs, MutateMode::JustWrite); self.consume_expr(&rhs); } - hir::ExprCast(ref base, _) => { + hir::ExprKind::Cast(ref base, _) => { self.consume_expr(&base); } - hir::ExprAssignOp(_, ref lhs, ref rhs) => { + hir::ExprKind::AssignOp(_, ref lhs, ref rhs) => { if self.mc.tables.is_method_call(expr) { self.consume_expr(lhs); } else { @@ -528,19 +528,19 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> { self.consume_expr(&rhs); } - hir::ExprRepeat(ref base, _) => { + hir::ExprKind::Repeat(ref base, _) => { self.consume_expr(&base); } - hir::ExprClosure(.., fn_decl_span, _) => { + hir::ExprKind::Closure(.., fn_decl_span, _) => { self.walk_captures(expr, fn_decl_span) } - hir::ExprBox(ref base) => { + hir::ExprKind::Box(ref base) => { self.consume_expr(&base); } - hir::ExprYield(ref value) => { + hir::ExprKind::Yield(ref value) => { self.consume_expr(&value); } } @@ -586,21 +586,21 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> { fn walk_stmt(&mut self, stmt: &hir::Stmt) { match stmt.node { - hir::StmtDecl(ref decl, _) => { + hir::StmtKind::Decl(ref decl, _) => { match decl.node { - hir::DeclLocal(ref local) => { + hir::DeclKind::Local(ref local) => { self.walk_local(&local); } - hir::DeclItem(_) => { + hir::DeclKind::Item(_) => { // we don't visit nested items in this visitor, // only the fn body we were given. } } } - hir::StmtExpr(ref expr, _) | - hir::StmtSemi(ref expr, _) => { + hir::StmtKind::Expr(ref expr, _) | + hir::StmtKind::Semi(ref expr, _) => { self.consume_expr(&expr); } } diff --git a/src/librustc/middle/intrinsicck.rs b/src/librustc/middle/intrinsicck.rs index 27f7dbf508d..668bac1e479 100644 --- a/src/librustc/middle/intrinsicck.rs +++ b/src/librustc/middle/intrinsicck.rs @@ -145,7 +145,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ExprVisitor<'a, 'tcx> { } fn visit_expr(&mut self, expr: &'tcx hir::Expr) { - let def = if let hir::ExprPath(ref qpath) = expr.node { + let def = if let hir::ExprKind::Path(ref qpath) = expr.node { self.tables.qpath_def(qpath, expr.hir_id) } else { Def::Err diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 07a9dd75d4c..b828b1bd30a 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -454,14 +454,14 @@ fn visit_arm<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, arm: &'tcx hir::Arm) { fn visit_expr<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, expr: &'tcx Expr) { match expr.node { // live nodes required for uses or definitions of variables: - hir::ExprPath(hir::QPath::Resolved(_, ref path)) => { + hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => { debug!("expr {}: path that leads to {:?}", expr.id, path.def); if let Def::Local(..) = path.def { ir.add_live_node_for_node(expr.hir_id, ExprNode(expr.span)); } intravisit::walk_expr(ir, expr); } - hir::ExprClosure(..) => { + hir::ExprKind::Closure(..) => { // Interesting control flow (for loops can contain labeled // breaks or continues) ir.add_live_node_for_node(expr.hir_id, ExprNode(expr.span)); @@ -486,25 +486,43 @@ fn visit_expr<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, expr: &'tcx Expr) { } // live nodes required for interesting control flow: - hir::ExprIf(..) | hir::ExprMatch(..) | hir::ExprWhile(..) | hir::ExprLoop(..) => { + hir::ExprKind::If(..) | + hir::ExprKind::Match(..) | + hir::ExprKind::While(..) | + hir::ExprKind::Loop(..) => { ir.add_live_node_for_node(expr.hir_id, ExprNode(expr.span)); intravisit::walk_expr(ir, expr); } - hir::ExprBinary(op, ..) if op.node.is_lazy() => { + hir::ExprKind::Binary(op, ..) if op.node.is_lazy() => { ir.add_live_node_for_node(expr.hir_id, ExprNode(expr.span)); intravisit::walk_expr(ir, expr); } // otherwise, live nodes are not required: - hir::ExprIndex(..) | hir::ExprField(..) | - hir::ExprArray(..) | hir::ExprCall(..) | hir::ExprMethodCall(..) | - hir::ExprTup(..) | hir::ExprBinary(..) | hir::ExprAddrOf(..) | - hir::ExprCast(..) | hir::ExprUnary(..) | hir::ExprBreak(..) | - hir::ExprContinue(_) | hir::ExprLit(_) | hir::ExprRet(..) | - hir::ExprBlock(..) | hir::ExprAssign(..) | hir::ExprAssignOp(..) | - hir::ExprStruct(..) | hir::ExprRepeat(..) | - hir::ExprInlineAsm(..) | hir::ExprBox(..) | hir::ExprYield(..) | - hir::ExprType(..) | hir::ExprPath(hir::QPath::TypeRelative(..)) => { + hir::ExprKind::Index(..) | + hir::ExprKind::Field(..) | + hir::ExprKind::Array(..) | + hir::ExprKind::Call(..) | + hir::ExprKind::MethodCall(..) | + hir::ExprKind::Tup(..) | + hir::ExprKind::Binary(..) | + hir::ExprKind::AddrOf(..) | + hir::ExprKind::Cast(..) | + hir::ExprKind::Unary(..) | + hir::ExprKind::Break(..) | + hir::ExprKind::Continue(_) | + hir::ExprKind::Lit(_) | + hir::ExprKind::Ret(..) | + hir::ExprKind::Block(..) | + hir::ExprKind::Assign(..) | + hir::ExprKind::AssignOp(..) | + hir::ExprKind::Struct(..) | + hir::ExprKind::Repeat(..) | + hir::ExprKind::InlineAsm(..) | + hir::ExprKind::Box(..) | + hir::ExprKind::Yield(..) | + hir::ExprKind::Type(..) | + hir::ExprKind::Path(hir::QPath::TypeRelative(..)) => { intravisit::walk_expr(ir, expr); } } @@ -860,11 +878,11 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { fn propagate_through_stmt(&mut self, stmt: &hir::Stmt, succ: LiveNode) -> LiveNode { match stmt.node { - hir::StmtDecl(ref decl, _) => { + hir::StmtKind::Decl(ref decl, _) => { self.propagate_through_decl(&decl, succ) } - hir::StmtExpr(ref expr, _) | hir::StmtSemi(ref expr, _) => { + hir::StmtKind::Expr(ref expr, _) | hir::StmtKind::Semi(ref expr, _) => { self.propagate_through_expr(&expr, succ) } } @@ -873,10 +891,10 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { fn propagate_through_decl(&mut self, decl: &hir::Decl, succ: LiveNode) -> LiveNode { match decl.node { - hir::DeclLocal(ref local) => { + hir::DeclKind::Local(ref local) => { self.propagate_through_local(&local, succ) } - hir::DeclItem(_) => succ, + hir::DeclKind::Item(_) => succ, } } @@ -920,16 +938,16 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { match expr.node { // Interesting cases with control flow or which gen/kill - hir::ExprPath(hir::QPath::Resolved(_, ref path)) => { + hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => { self.access_path(expr.hir_id, path, succ, ACC_READ | ACC_USE) } - hir::ExprField(ref e, _) => { + hir::ExprKind::Field(ref e, _) => { self.propagate_through_expr(&e, succ) } - hir::ExprClosure(.., blk_id, _, _) => { - debug!("{} is an ExprClosure", self.ir.tcx.hir.node_to_pretty_string(expr.id)); + hir::ExprKind::Closure(.., blk_id, _, _) => { + debug!("{} is an ExprKind::Closure", self.ir.tcx.hir.node_to_pretty_string(expr.id)); // The next-node for a break is the successor of the entire // loop. The next-node for a continue is the top of this loop. @@ -956,7 +974,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { }) } - hir::ExprIf(ref cond, ref then, ref els) => { + hir::ExprKind::If(ref cond, ref then, ref els) => { // // (cond) // | @@ -978,17 +996,17 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { self.propagate_through_expr(&cond, ln) } - hir::ExprWhile(ref cond, ref blk, _) => { + hir::ExprKind::While(ref cond, ref blk, _) => { self.propagate_through_loop(expr, WhileLoop(&cond), &blk, succ) } // Note that labels have been resolved, so we don't need to look // at the label ident - hir::ExprLoop(ref blk, _, _) => { + hir::ExprKind::Loop(ref blk, _, _) => { self.propagate_through_loop(expr, LoopLoop, &blk, succ) } - hir::ExprMatch(ref e, ref arms, _) => { + hir::ExprKind::Match(ref e, ref arms, _) => { // // (e) // | @@ -1023,13 +1041,13 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { self.propagate_through_expr(&e, ln) } - hir::ExprRet(ref o_e) => { + hir::ExprKind::Ret(ref o_e) => { // ignore succ and subst exit_ln: let exit_ln = self.s.exit_ln; self.propagate_through_opt_expr(o_e.as_ref().map(|e| &**e), exit_ln) } - hir::ExprBreak(label, ref opt_expr) => { + hir::ExprKind::Break(label, ref opt_expr) => { // Find which label this break jumps to let target = match label.target_id { Ok(node_id) => self.break_ln.get(&node_id), @@ -1045,7 +1063,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { } } - hir::ExprContinue(label) => { + hir::ExprKind::Continue(label) => { // Find which label this expr continues to let sc = match label.target_id { Ok(node_id) => node_id, @@ -1061,7 +1079,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { } } - hir::ExprAssign(ref l, ref r) => { + hir::ExprKind::Assign(ref l, ref r) => { // see comment on places in // propagate_through_place_components() let succ = self.write_place(&l, succ, ACC_WRITE); @@ -1069,7 +1087,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { self.propagate_through_expr(&r, succ) } - hir::ExprAssignOp(_, ref l, ref r) => { + hir::ExprKind::AssignOp(_, ref l, ref r) => { // an overloaded assign op is like a method call if self.tables.is_method_call(expr) { let succ = self.propagate_through_expr(&l, succ); @@ -1085,18 +1103,18 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { // Uninteresting cases: just propagate in rev exec order - hir::ExprArray(ref exprs) => { + hir::ExprKind::Array(ref exprs) => { self.propagate_through_exprs(exprs, succ) } - hir::ExprStruct(_, ref fields, ref with_expr) => { + hir::ExprKind::Struct(_, ref fields, ref with_expr) => { let succ = self.propagate_through_opt_expr(with_expr.as_ref().map(|e| &**e), succ); fields.iter().rev().fold(succ, |succ, field| { self.propagate_through_expr(&field.expr, succ) }) } - hir::ExprCall(ref f, ref args) => { + hir::ExprKind::Call(ref f, ref args) => { // FIXME(canndrew): This is_never should really be an is_uninhabited let succ = if self.tables.expr_ty(expr).is_never() { self.s.exit_ln @@ -1107,7 +1125,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { self.propagate_through_expr(&f, succ) } - hir::ExprMethodCall(.., ref args) => { + hir::ExprKind::MethodCall(.., ref args) => { // FIXME(canndrew): This is_never should really be an is_uninhabited let succ = if self.tables.expr_ty(expr).is_never() { self.s.exit_ln @@ -1117,11 +1135,11 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { self.propagate_through_exprs(args, succ) } - hir::ExprTup(ref exprs) => { + hir::ExprKind::Tup(ref exprs) => { self.propagate_through_exprs(exprs, succ) } - hir::ExprBinary(op, ref l, ref r) if op.node.is_lazy() => { + hir::ExprKind::Binary(op, ref l, ref r) if op.node.is_lazy() => { let r_succ = self.propagate_through_expr(&r, succ); let ln = self.live_node(expr.hir_id, expr.span); @@ -1131,23 +1149,23 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { self.propagate_through_expr(&l, ln) } - hir::ExprIndex(ref l, ref r) | - hir::ExprBinary(_, ref l, ref r) => { + hir::ExprKind::Index(ref l, ref r) | + hir::ExprKind::Binary(_, ref l, ref r) => { let r_succ = self.propagate_through_expr(&r, succ); self.propagate_through_expr(&l, r_succ) } - hir::ExprBox(ref e) | - hir::ExprAddrOf(_, ref e) | - hir::ExprCast(ref e, _) | - hir::ExprType(ref e, _) | - hir::ExprUnary(_, ref e) | - hir::ExprYield(ref e) | - hir::ExprRepeat(ref e, _) => { + hir::ExprKind::Box(ref e) | + hir::ExprKind::AddrOf(_, ref e) | + hir::ExprKind::Cast(ref e, _) | + hir::ExprKind::Type(ref e, _) | + hir::ExprKind::Unary(_, ref e) | + hir::ExprKind::Yield(ref e) | + hir::ExprKind::Repeat(ref e, _) => { self.propagate_through_expr(&e, succ) } - hir::ExprInlineAsm(ref ia, ref outputs, ref inputs) => { + hir::ExprKind::InlineAsm(ref ia, ref outputs, ref inputs) => { let succ = ia.outputs.iter().zip(outputs).rev().fold(succ, |succ, (o, output)| { // see comment on places // in propagate_through_place_components() @@ -1164,13 +1182,13 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { self.propagate_through_exprs(inputs, succ) } - hir::ExprLit(..) | hir::ExprPath(hir::QPath::TypeRelative(..)) => { + hir::ExprKind::Lit(..) | hir::ExprKind::Path(hir::QPath::TypeRelative(..)) => { succ } // Note that labels have been resolved, so we don't need to look // at the label ident - hir::ExprBlock(ref blk, _) => { + hir::ExprKind::Block(ref blk, _) => { self.propagate_through_block(&blk, succ) } } @@ -1230,8 +1248,8 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { // just ignore such cases and treat them as reads. match expr.node { - hir::ExprPath(_) => succ, - hir::ExprField(ref e, _) => self.propagate_through_expr(&e, succ), + hir::ExprKind::Path(_) => succ, + hir::ExprKind::Field(ref e, _) => self.propagate_through_expr(&e, succ), _ => self.propagate_through_expr(expr, succ) } } @@ -1240,7 +1258,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { fn write_place(&mut self, expr: &Expr, succ: LiveNode, acc: u32) -> LiveNode { match expr.node { - hir::ExprPath(hir::QPath::Resolved(_, ref path)) => { + hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => { self.access_path(expr.hir_id, path, succ, acc) } @@ -1393,13 +1411,13 @@ fn check_arm<'a, 'tcx>(this: &mut Liveness<'a, 'tcx>, arm: &'tcx hir::Arm) { fn check_expr<'a, 'tcx>(this: &mut Liveness<'a, 'tcx>, expr: &'tcx Expr) { match expr.node { - hir::ExprAssign(ref l, _) => { + hir::ExprKind::Assign(ref l, _) => { this.check_place(&l); intravisit::walk_expr(this, expr); } - hir::ExprAssignOp(_, ref l, _) => { + hir::ExprKind::AssignOp(_, ref l, _) => { if !this.tables.is_method_call(expr) { this.check_place(&l); } @@ -1407,7 +1425,7 @@ fn check_expr<'a, 'tcx>(this: &mut Liveness<'a, 'tcx>, expr: &'tcx Expr) { intravisit::walk_expr(this, expr); } - hir::ExprInlineAsm(ref ia, ref outputs, ref inputs) => { + hir::ExprKind::InlineAsm(ref ia, ref outputs, ref inputs) => { for input in inputs { this.visit_expr(input); } @@ -1424,16 +1442,16 @@ fn check_expr<'a, 'tcx>(this: &mut Liveness<'a, 'tcx>, expr: &'tcx Expr) { } // no correctness conditions related to liveness - hir::ExprCall(..) | hir::ExprMethodCall(..) | hir::ExprIf(..) | - hir::ExprMatch(..) | hir::ExprWhile(..) | hir::ExprLoop(..) | - hir::ExprIndex(..) | hir::ExprField(..) | - hir::ExprArray(..) | hir::ExprTup(..) | hir::ExprBinary(..) | - hir::ExprCast(..) | hir::ExprUnary(..) | hir::ExprRet(..) | - hir::ExprBreak(..) | hir::ExprContinue(..) | hir::ExprLit(_) | - hir::ExprBlock(..) | hir::ExprAddrOf(..) | - hir::ExprStruct(..) | hir::ExprRepeat(..) | - hir::ExprClosure(..) | hir::ExprPath(_) | hir::ExprYield(..) | - hir::ExprBox(..) | hir::ExprType(..) => { + hir::ExprKind::Call(..) | hir::ExprKind::MethodCall(..) | hir::ExprKind::If(..) | + hir::ExprKind::Match(..) | hir::ExprKind::While(..) | hir::ExprKind::Loop(..) | + hir::ExprKind::Index(..) | hir::ExprKind::Field(..) | + hir::ExprKind::Array(..) | hir::ExprKind::Tup(..) | hir::ExprKind::Binary(..) | + hir::ExprKind::Cast(..) | hir::ExprKind::Unary(..) | hir::ExprKind::Ret(..) | + hir::ExprKind::Break(..) | hir::ExprKind::Continue(..) | hir::ExprKind::Lit(_) | + hir::ExprKind::Block(..) | hir::ExprKind::AddrOf(..) | + hir::ExprKind::Struct(..) | hir::ExprKind::Repeat(..) | + hir::ExprKind::Closure(..) | hir::ExprKind::Path(_) | hir::ExprKind::Yield(..) | + hir::ExprKind::Box(..) | hir::ExprKind::Type(..) => { intravisit::walk_expr(this, expr); } } @@ -1442,7 +1460,7 @@ fn check_expr<'a, 'tcx>(this: &mut Liveness<'a, 'tcx>, expr: &'tcx Expr) { impl<'a, 'tcx> Liveness<'a, 'tcx> { fn check_place(&mut self, expr: &'tcx Expr) { match expr.node { - hir::ExprPath(hir::QPath::Resolved(_, ref path)) => { + hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => { if let Def::Local(nid) = path.def { // Assignment to an immutable variable or argument: only legal // if there is no later assignment. If this local is actually diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 3b89a9d2de5..0602dc55c43 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -639,7 +639,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { let expr_ty = self.expr_ty(expr)?; match expr.node { - hir::ExprUnary(hir::UnDeref, ref e_base) => { + hir::ExprKind::Unary(hir::UnDeref, ref e_base) => { if self.tables.is_method_call(expr) { self.cat_overloaded_place(expr, e_base, NoteNone) } else { @@ -648,7 +648,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { } } - hir::ExprField(ref base, f_ident) => { + hir::ExprKind::Field(ref base, f_ident) => { let base_cmt = Rc::new(self.cat_expr(&base)?); debug!("cat_expr(cat_field): id={} expr={:?} base={:?}", expr.id, @@ -658,7 +658,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { Ok(self.cat_field(expr, base_cmt, f_index, f_ident, expr_ty)) } - hir::ExprIndex(ref base, _) => { + hir::ExprKind::Index(ref base, _) => { if self.tables.is_method_call(expr) { // If this is an index implemented by a method call, then it // will include an implicit deref of the result. @@ -672,26 +672,26 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { } } - hir::ExprPath(ref qpath) => { + hir::ExprKind::Path(ref qpath) => { let def = self.tables.qpath_def(qpath, expr.hir_id); self.cat_def(expr.hir_id, expr.span, expr_ty, def) } - hir::ExprType(ref e, _) => { + hir::ExprKind::Type(ref e, _) => { self.cat_expr(&e) } - hir::ExprAddrOf(..) | hir::ExprCall(..) | - hir::ExprAssign(..) | hir::ExprAssignOp(..) | - hir::ExprClosure(..) | hir::ExprRet(..) | - hir::ExprUnary(..) | hir::ExprYield(..) | - hir::ExprMethodCall(..) | hir::ExprCast(..) | - hir::ExprArray(..) | hir::ExprTup(..) | hir::ExprIf(..) | - hir::ExprBinary(..) | hir::ExprWhile(..) | - hir::ExprBlock(..) | hir::ExprLoop(..) | hir::ExprMatch(..) | - hir::ExprLit(..) | hir::ExprBreak(..) | - hir::ExprContinue(..) | hir::ExprStruct(..) | hir::ExprRepeat(..) | - hir::ExprInlineAsm(..) | hir::ExprBox(..) => { + hir::ExprKind::AddrOf(..) | hir::ExprKind::Call(..) | + hir::ExprKind::Assign(..) | hir::ExprKind::AssignOp(..) | + hir::ExprKind::Closure(..) | hir::ExprKind::Ret(..) | + hir::ExprKind::Unary(..) | hir::ExprKind::Yield(..) | + hir::ExprKind::MethodCall(..) | hir::ExprKind::Cast(..) | + hir::ExprKind::Array(..) | hir::ExprKind::Tup(..) | hir::ExprKind::If(..) | + hir::ExprKind::Binary(..) | hir::ExprKind::While(..) | + hir::ExprKind::Block(..) | hir::ExprKind::Loop(..) | hir::ExprKind::Match(..) | + hir::ExprKind::Lit(..) | hir::ExprKind::Break(..) | + hir::ExprKind::Continue(..) | hir::ExprKind::Struct(..) | hir::ExprKind::Repeat(..) | + hir::ExprKind::InlineAsm(..) | hir::ExprKind::Box(..) => { Ok(self.cat_rvalue_node(expr.hir_id, expr.span, expr_ty)) } } diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs index 476f3f5799d..a504697008e 100644 --- a/src/librustc/middle/reachable.rs +++ b/src/librustc/middle/reachable.rs @@ -58,8 +58,8 @@ fn item_might_be_inlined(tcx: TyCtxt<'a, 'tcx, 'tcx>, } match item.node { - hir::ItemImpl(..) | - hir::ItemFn(..) => { + hir::ItemKind::Impl(..) | + hir::ItemKind::Fn(..) => { let generics = tcx.generics_of(tcx.hir.local_def_id(item.id)); generics_require_inlining(generics) } @@ -116,10 +116,10 @@ impl<'a, 'tcx> Visitor<'tcx> for ReachableContext<'a, 'tcx> { fn visit_expr(&mut self, expr: &'tcx hir::Expr) { let def = match expr.node { - hir::ExprPath(ref qpath) => { + hir::ExprKind::Path(ref qpath) => { Some(self.tables.qpath_def(qpath, expr.hir_id)) } - hir::ExprMethodCall(..) => { + hir::ExprKind::MethodCall(..) => { self.tables.type_dependent_defs().get(expr.hir_id).cloned() } _ => None @@ -171,7 +171,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { match self.tcx.hir.find(node_id) { Some(hir_map::NodeItem(item)) => { match item.node { - hir::ItemFn(..) => + hir::ItemKind::Fn(..) => item_might_be_inlined(self.tcx, &item, self.tcx.codegen_fn_attrs(def_id)), _ => false, } @@ -202,7 +202,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { // does too. let impl_node_id = self.tcx.hir.as_local_node_id(impl_did).unwrap(); match self.tcx.hir.expect_item(impl_node_id).node { - hir::ItemImpl(..) => { + hir::ItemKind::Impl(..) => { let generics = self.tcx.generics_of(impl_did); generics_require_inlining(&generics) } @@ -238,7 +238,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { // If we are building an executable, only explicitly extern // types need to be exported. if let hir_map::NodeItem(item) = *node { - let reachable = if let hir::ItemFn(_, header, ..) = item.node { + let reachable = if let hir::ItemKind::Fn(_, header, ..) = item.node { header.abi != Abi::Rust } else { false @@ -260,7 +260,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { match *node { hir_map::NodeItem(item) => { match item.node { - hir::ItemFn(.., body) => { + hir::ItemKind::Fn(.., body) => { let def_id = self.tcx.hir.local_def_id(item.id); if item_might_be_inlined(self.tcx, &item, @@ -272,20 +272,27 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { // Reachable constants will be inlined into other crates // unconditionally, so we need to make sure that their // contents are also reachable. - hir::ItemConst(_, init) => { + hir::ItemKind::Const(_, init) => { self.visit_nested_body(init); } // These are normal, nothing reachable about these // inherently and their children are already in the // worklist, as determined by the privacy pass - hir::ItemExternCrate(_) | hir::ItemUse(..) | - hir::ItemExistential(..) | - hir::ItemTy(..) | hir::ItemStatic(..) | - hir::ItemMod(..) | hir::ItemForeignMod(..) | - hir::ItemImpl(..) | hir::ItemTrait(..) | hir::ItemTraitAlias(..) | - hir::ItemStruct(..) | hir::ItemEnum(..) | - hir::ItemUnion(..) | hir::ItemGlobalAsm(..) => {} + hir::ItemKind::ExternCrate(_) | + hir::ItemKind::Use(..) | + hir::ItemKind::Existential(..) | + hir::ItemKind::Ty(..) | + hir::ItemKind::Static(..) | + hir::ItemKind::Mod(..) | + hir::ItemKind::ForeignMod(..) | + hir::ItemKind::Impl(..) | + hir::ItemKind::Trait(..) | + hir::ItemKind::TraitAlias(..) | + hir::ItemKind::Struct(..) | + hir::ItemKind::Enum(..) | + hir::ItemKind::Union(..) | + hir::ItemKind::GlobalAsm(..) => {} } } hir_map::NodeTraitItem(trait_method) => { @@ -315,7 +322,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { hir::ImplItemKind::Type(_) => {} } } - hir_map::NodeExpr(&hir::Expr { node: hir::ExprClosure(.., body, _, _), .. }) => { + hir_map::NodeExpr(&hir::Expr { node: hir::ExprKind::Closure(.., body, _, _), .. }) => { self.visit_nested_body(body); } // Nothing to recurse on for these @@ -356,7 +363,7 @@ impl<'a, 'tcx: 'a> ItemLikeVisitor<'tcx> for CollectPrivateImplItemsVisitor<'a, } // We need only trait impls here, not inherent impls, and only non-exported ones - if let hir::ItemImpl(.., Some(ref trait_ref), _, ref impl_item_refs) = item.node { + if let hir::ItemKind::Impl(.., Some(ref trait_ref), _, ref impl_item_refs) = item.node { if !self.access_levels.is_reachable(item.id) { for impl_item_ref in impl_item_refs { self.worklist.push(impl_item_ref.id.node_id); diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index a11c8f5dc04..ebdc9c922b1 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -858,8 +858,8 @@ fn resolve_block<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, blk: // index information.) for (i, statement) in blk.stmts.iter().enumerate() { - if let hir::StmtDecl(..) = statement.node { - // Each StmtDecl introduces a subscope for bindings + if let hir::StmtKind::Decl(..) = statement.node { + // Each StmtKind::Decl introduces a subscope for bindings // introduced by the declaration; this subscope covers // a suffix of the block . Each subscope in a block // has the previous subscope in the block as a parent, @@ -943,39 +943,39 @@ fn resolve_expr<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, expr: // scopes, meaning that temporaries cannot outlive them. // This ensures fixed size stacks. - hir::ExprBinary(codemap::Spanned { node: hir::BiAnd, .. }, _, ref r) | - hir::ExprBinary(codemap::Spanned { node: hir::BiOr, .. }, _, ref r) => { + hir::ExprKind::Binary(codemap::Spanned { node: hir::BinOpKind::And, .. }, _, ref r) | + hir::ExprKind::Binary(codemap::Spanned { node: hir::BinOpKind::Or, .. }, _, ref r) => { // For shortcircuiting operators, mark the RHS as a terminating // scope since it only executes conditionally. terminating(r.hir_id.local_id); } - hir::ExprIf(ref expr, ref then, Some(ref otherwise)) => { + hir::ExprKind::If(ref expr, ref then, Some(ref otherwise)) => { terminating(expr.hir_id.local_id); terminating(then.hir_id.local_id); terminating(otherwise.hir_id.local_id); } - hir::ExprIf(ref expr, ref then, None) => { + hir::ExprKind::If(ref expr, ref then, None) => { terminating(expr.hir_id.local_id); terminating(then.hir_id.local_id); } - hir::ExprLoop(ref body, _, _) => { + hir::ExprKind::Loop(ref body, _, _) => { terminating(body.hir_id.local_id); } - hir::ExprWhile(ref expr, ref body, _) => { + hir::ExprKind::While(ref expr, ref body, _) => { terminating(expr.hir_id.local_id); terminating(body.hir_id.local_id); } - hir::ExprMatch(..) => { + hir::ExprKind::Match(..) => { visitor.cx.var_parent = visitor.cx.parent; } - hir::ExprAssignOp(..) | hir::ExprIndex(..) | - hir::ExprUnary(..) | hir::ExprCall(..) | hir::ExprMethodCall(..) => { + hir::ExprKind::AssignOp(..) | hir::ExprKind::Index(..) | + hir::ExprKind::Unary(..) | hir::ExprKind::Call(..) | hir::ExprKind::MethodCall(..) => { // FIXME(https://github.com/rust-lang/rfcs/issues/811) Nested method calls // // The lifetimes for a call or method call look as follows: @@ -1003,7 +1003,7 @@ fn resolve_expr<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, expr: match expr.node { // Manually recurse over closures, because they are the only // case of nested bodies that share the parent environment. - hir::ExprClosure(.., body, _, _) => { + hir::ExprKind::Closure(.., body, _, _) => { let body = visitor.tcx.hir.body(body); visitor.visit_body(body); } @@ -1015,7 +1015,7 @@ fn resolve_expr<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, expr: debug!("resolve_expr post-increment {}, expr = {:?}", visitor.expr_and_pat_count, expr); - if let hir::ExprYield(..) = expr.node { + if let hir::ExprKind::Yield(..) = expr.node { // Mark this expr's scope and all parent scopes as containing `yield`. let mut scope = Scope::Node(expr.hir_id.local_id); loop { @@ -1193,27 +1193,27 @@ fn resolve_local<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, blk_id: Option<Scope>) { match expr.node { - hir::ExprAddrOf(_, ref subexpr) => { + hir::ExprKind::AddrOf(_, ref subexpr) => { record_rvalue_scope_if_borrow_expr(visitor, &subexpr, blk_id); record_rvalue_scope(visitor, &subexpr, blk_id); } - hir::ExprStruct(_, ref fields, _) => { + hir::ExprKind::Struct(_, ref fields, _) => { for field in fields { record_rvalue_scope_if_borrow_expr( visitor, &field.expr, blk_id); } } - hir::ExprArray(ref subexprs) | - hir::ExprTup(ref subexprs) => { + hir::ExprKind::Array(ref subexprs) | + hir::ExprKind::Tup(ref subexprs) => { for subexpr in subexprs { record_rvalue_scope_if_borrow_expr( visitor, &subexpr, blk_id); } } - hir::ExprCast(ref subexpr, _) => { + hir::ExprKind::Cast(ref subexpr, _) => { record_rvalue_scope_if_borrow_expr(visitor, &subexpr, blk_id) } - hir::ExprBlock(ref block, _) => { + hir::ExprKind::Block(ref block, _) => { if let Some(ref subexpr) = block.expr { record_rvalue_scope_if_borrow_expr( visitor, &subexpr, blk_id); @@ -1251,10 +1251,10 @@ fn resolve_local<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, visitor.scope_tree.record_rvalue_scope(expr.hir_id.local_id, blk_scope); match expr.node { - hir::ExprAddrOf(_, ref subexpr) | - hir::ExprUnary(hir::UnDeref, ref subexpr) | - hir::ExprField(ref subexpr, _) | - hir::ExprIndex(ref subexpr, _) => { + hir::ExprKind::AddrOf(_, ref subexpr) | + hir::ExprKind::Unary(hir::UnDeref, ref subexpr) | + hir::ExprKind::Field(ref subexpr, _) | + hir::ExprKind::Index(ref subexpr, _) => { expr = &subexpr; } _ => { diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index 369f65c214a..05a6cd9c243 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -476,21 +476,21 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { fn visit_item(&mut self, item: &'tcx hir::Item) { match item.node { - hir::ItemFn(ref decl, _, ref generics, _) => { + hir::ItemKind::Fn(ref decl, _, ref generics, _) => { self.visit_early_late(None, decl, generics, |this| { intravisit::walk_item(this, item); }); } - hir::ItemExternCrate(_) - | hir::ItemUse(..) - | hir::ItemMod(..) - | hir::ItemForeignMod(..) - | hir::ItemGlobalAsm(..) => { + hir::ItemKind::ExternCrate(_) + | hir::ItemKind::Use(..) + | hir::ItemKind::Mod(..) + | hir::ItemKind::ForeignMod(..) + | hir::ItemKind::GlobalAsm(..) => { // These sorts of items have no lifetime parameters at all. intravisit::walk_item(self, item); } - hir::ItemStatic(..) | hir::ItemConst(..) => { + hir::ItemKind::Static(..) | hir::ItemKind::Const(..) => { // No lifetime parameters, but implied 'static. let scope = Scope::Elision { elide: Elide::Exact(Region::Static), @@ -498,27 +498,27 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { }; self.with(scope, |_, this| intravisit::walk_item(this, item)); } - hir::ItemExistential(hir::ExistTy { impl_trait_fn: Some(_), .. }) => { + hir::ItemKind::Existential(hir::ExistTy { impl_trait_fn: Some(_), .. }) => { // currently existential type declarations are just generated from impl Trait // items. doing anything on this node is irrelevant, as we currently don't need // it. } - hir::ItemTy(_, ref generics) - | hir::ItemExistential(hir::ExistTy { impl_trait_fn: None, ref generics, .. }) - | hir::ItemEnum(_, ref generics) - | hir::ItemStruct(_, ref generics) - | hir::ItemUnion(_, ref generics) - | hir::ItemTrait(_, _, ref generics, ..) - | hir::ItemTraitAlias(ref generics, ..) - | hir::ItemImpl(_, _, _, ref generics, ..) => { + hir::ItemKind::Ty(_, ref generics) + | hir::ItemKind::Existential(hir::ExistTy { impl_trait_fn: None, ref generics, .. }) + | hir::ItemKind::Enum(_, ref generics) + | hir::ItemKind::Struct(_, ref generics) + | hir::ItemKind::Union(_, ref generics) + | hir::ItemKind::Trait(_, _, ref generics, ..) + | hir::ItemKind::TraitAlias(ref generics, ..) + | hir::ItemKind::Impl(_, _, _, ref generics, ..) => { // Impls permit `'_` to be used and it is equivalent to "some fresh lifetime name". // This is not true for other kinds of items.x let track_lifetime_uses = match item.node { - hir::ItemImpl(..) => true, + hir::ItemKind::Impl(..) => true, _ => false, }; // These kinds of items have only early bound lifetime parameters. - let mut index = if let hir::ItemTrait(..) = item.node { + let mut index = if let hir::ItemKind::Trait(..) = item.node { 1 // Self comes before lifetimes } else { 0 @@ -550,15 +550,15 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { fn visit_foreign_item(&mut self, item: &'tcx hir::ForeignItem) { match item.node { - hir::ForeignItemFn(ref decl, _, ref generics) => { + hir::ForeignItemKind::Fn(ref decl, _, ref generics) => { self.visit_early_late(None, decl, generics, |this| { intravisit::walk_foreign_item(this, item); }) } - hir::ForeignItemStatic(..) => { + hir::ForeignItemKind::Static(..) => { intravisit::walk_foreign_item(self, item); } - hir::ForeignItemType => { + hir::ForeignItemKind::Type => { intravisit::walk_foreign_item(self, item); } } @@ -567,7 +567,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { fn visit_ty(&mut self, ty: &'tcx hir::Ty) { debug!("visit_ty: id={:?} ty={:?}", ty.id, ty); match ty.node { - hir::TyBareFn(ref c) => { + hir::TyKind::BareFn(ref c) => { let next_early_index = self.next_early_index(); let was_in_fn_syntax = self.is_in_fn_syntax; self.is_in_fn_syntax = true; @@ -591,7 +591,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { }); self.is_in_fn_syntax = was_in_fn_syntax; } - hir::TyTraitObject(ref bounds, ref lifetime) => { + hir::TyKind::TraitObject(ref bounds, ref lifetime) => { for bound in bounds { self.visit_poly_trait_ref(bound, hir::TraitBoundModifier::None); } @@ -617,7 +617,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { } } } - hir::TyRptr(ref lifetime_ref, ref mt) => { + hir::TyKind::Rptr(ref lifetime_ref, ref mt) => { self.visit_lifetime(lifetime_ref); let scope = Scope::ObjectLifetimeDefault { lifetime: self.map.defs.get(&lifetime_ref.id).cloned(), @@ -625,7 +625,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { }; self.with(scope, |_, this| this.visit_ty(&mt.ty)); } - hir::TyPath(hir::QPath::Resolved(None, ref path)) => { + hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) => { if let Def::Existential(exist_ty_did) = path.def { assert!(exist_ty_did.is_local()); // Resolve the lifetimes that are applied to the existential type. @@ -675,7 +675,9 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { // ^ ^ this gets resolved in the scope of // the exist_ty generics let (generics, bounds) = match self.tcx.hir.expect_item(id).node { - hir::ItemExistential(hir::ExistTy{ ref generics, ref bounds, .. }) => ( + hir::ItemKind::Existential( + hir::ExistTy { ref generics, ref bounds, .. } + ) => ( generics, bounds, ), @@ -1157,8 +1159,8 @@ fn extract_labels(ctxt: &mut LifetimeContext<'_, '_>, body: &hir::Body) { fn expression_label(ex: &hir::Expr) -> Option<ast::Ident> { match ex.node { - hir::ExprWhile(.., Some(label)) | - hir::ExprLoop(_, Some(label), _) => Some(label.ident), + hir::ExprKind::While(.., Some(label)) | + hir::ExprKind::Loop(_, Some(label), _) => Some(label.ident), _ => None, } } @@ -1208,11 +1210,11 @@ fn compute_object_lifetime_defaults( let mut map = NodeMap(); for item in tcx.hir.krate().items.values() { match item.node { - hir::ItemStruct(_, ref generics) - | hir::ItemUnion(_, ref generics) - | hir::ItemEnum(_, ref generics) - | hir::ItemTy(_, ref generics) - | hir::ItemTrait(_, _, ref generics, ..) => { + hir::ItemKind::Struct(_, ref generics) + | hir::ItemKind::Union(_, ref generics) + | hir::ItemKind::Enum(_, ref generics) + | hir::ItemKind::Ty(_, ref generics) + | hir::ItemKind::Trait(_, _, ref generics, ..) => { let result = object_lifetime_defaults_for_item(tcx, generics); // Debugging aid. @@ -1287,7 +1289,7 @@ fn object_lifetime_defaults_for_item( } let def = match data.bounded_ty.node { - hir::TyPath(hir::QPath::Resolved(None, ref path)) => path.def, + hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) => path.def, _ => continue, }; @@ -1485,12 +1487,12 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { let mut index = 0; if let Some(parent_id) = parent_id { let parent = self.tcx.hir.expect_item(parent_id); - if let hir::ItemTrait(..) = parent.node { + if let hir::ItemKind::Trait(..) = parent.node { index += 1; // Self comes first. } match parent.node { - hir::ItemTrait(_, _, ref generics, ..) - | hir::ItemImpl(_, _, _, ref generics, ..) => { + hir::ItemKind::Trait(_, _, ref generics, ..) + | hir::ItemKind::Impl(_, _, _, ref generics, ..) => { index += generics.params.len() as u32; } _ => {} @@ -1609,7 +1611,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { let fn_id = self.tcx.hir.body_owner(body_id); match self.tcx.hir.get(fn_id) { hir::map::NodeItem(&hir::Item { - node: hir::ItemFn(..), + node: hir::ItemKind::Fn(..), .. }) | hir::map::NodeTraitItem(&hir::TraitItem { @@ -1834,7 +1836,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { let body = match self.tcx.hir.get(parent) { // `fn` definitions and methods. hir::map::NodeItem(&hir::Item { - node: hir::ItemFn(.., body), + node: hir::ItemKind::Fn(.., body), .. }) => Some(body), @@ -1847,7 +1849,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { .expect_item(self.tcx.hir.get_parent(parent)) .node { - hir::ItemTrait(.., ref trait_items) => { + hir::ItemKind::Trait(.., ref trait_items) => { assoc_item_kind = trait_items .iter() .find(|ti| ti.id.node_id == parent) @@ -1870,7 +1872,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { .expect_item(self.tcx.hir.get_parent(parent)) .node { - hir::ItemImpl(.., ref self_ty, ref impl_items) => { + hir::ItemKind::Impl(.., ref self_ty, ref impl_items) => { impl_self = Some(self_ty); assoc_item_kind = impl_items .iter() @@ -1912,7 +1914,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { // Can't always rely on literal (or implied) `Self` due // to the way elision rules were originally specified. let impl_self = impl_self.map(|ty| &ty.node); - if let Some(&hir::TyPath(hir::QPath::Resolved(None, ref path))) = impl_self { + if let Some(&hir::TyKind::Path(hir::QPath::Resolved(None, ref path))) = impl_self { match path.def { // Whitelist the types that unambiguously always // result in the same type constructor being used @@ -1927,8 +1929,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { false }; - if let hir::TyRptr(lifetime_ref, ref mt) = inputs[0].node { - if let hir::TyPath(hir::QPath::Resolved(None, ref path)) = mt.ty.node { + if let hir::TyKind::Rptr(lifetime_ref, ref mt) = inputs[0].node { + if let hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) = mt.ty.node { if is_self_ty(path.def) { if let Some(&lifetime) = self.map.defs.get(&lifetime_ref.id) { let scope = Scope::Elision { @@ -2007,10 +2009,10 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { } fn visit_ty(&mut self, ty: &hir::Ty) { - if let hir::TyBareFn(_) = ty.node { + if let hir::TyKind::BareFn(_) = ty.node { self.outer_index.shift_in(1); } - if let hir::TyTraitObject(ref bounds, ref lifetime) = ty.node { + if let hir::TyKind::TraitObject(ref bounds, ref lifetime) = ty.node { for bound in bounds { self.visit_poly_trait_ref(bound, hir::TraitBoundModifier::None); } @@ -2023,7 +2025,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { } else { intravisit::walk_ty(self, ty); } - if let hir::TyBareFn(_) = ty.node { + if let hir::TyKind::BareFn(_) = ty.node { self.outer_index.shift_out(1); } } @@ -2578,14 +2580,14 @@ fn insert_late_bound_lifetimes( fn visit_ty(&mut self, ty: &'v hir::Ty) { match ty.node { - hir::TyPath(hir::QPath::Resolved(Some(_), _)) - | hir::TyPath(hir::QPath::TypeRelative(..)) => { + hir::TyKind::Path(hir::QPath::Resolved(Some(_), _)) + | hir::TyKind::Path(hir::QPath::TypeRelative(..)) => { // ignore lifetimes appearing in associated type // projections, as they are not *constrained* // (defined above) } - hir::TyPath(hir::QPath::Resolved(None, ref path)) => { + hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) => { // consider only the lifetimes on the final // segment; I am not sure it's even currently // valid to have them elsewhere, but even if it diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index 9bf5c4d72b7..fdcae38fc6a 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -263,14 +263,14 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> { // they don't have their own stability. They still can be annotated as unstable // and propagate this unstability to children, but this annotation is completely // optional. They inherit stability from their parents when unannotated. - hir::ItemImpl(.., None, _, _) | hir::ItemForeignMod(..) => { + hir::ItemKind::Impl(.., None, _, _) | hir::ItemKind::ForeignMod(..) => { self.in_trait_impl = false; kind = AnnotationKind::Container; } - hir::ItemImpl(.., Some(_), _, _) => { + hir::ItemKind::Impl(.., Some(_), _, _) => { self.in_trait_impl = true; } - hir::ItemStruct(ref sd, _) => { + hir::ItemKind::Struct(ref sd, _) => { if !sd.is_struct() { self.annotate(sd.id(), &i.attrs, i.span, AnnotationKind::Required, |_| {}) } @@ -353,7 +353,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'a, 'tcx> { // they don't have their own stability. They still can be annotated as unstable // and propagate this unstability to children, but this annotation is completely // optional. They inherit stability from their parents when unannotated. - hir::ItemImpl(.., None, _, _) | hir::ItemForeignMod(..) => {} + hir::ItemKind::Impl(.., None, _, _) | hir::ItemKind::ForeignMod(..) => {} _ => self.check_missing_stability(i.id, i.span) } @@ -723,7 +723,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> { fn visit_item(&mut self, item: &'tcx hir::Item) { match item.node { - hir::ItemExternCrate(_) => { + hir::ItemKind::ExternCrate(_) => { // compiler-generated `extern crate` items have a dummy span. if item.span.is_dummy() { return } @@ -739,7 +739,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> { // For implementations of traits, check the stability of each item // individually as it's possible to have a stable trait with unstable // items. - hir::ItemImpl(.., Some(ref t), _, ref impl_item_refs) => { + hir::ItemKind::Impl(.., Some(ref t), _, ref impl_item_refs) => { if let Def::Trait(trait_did) = t.path.def { for impl_item_ref in impl_item_refs { let impl_item = self.tcx.hir.impl_item(impl_item_ref.id); @@ -756,7 +756,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> { // There's no good place to insert stability check for non-Copy unions, // so semi-randomly perform it here in stability.rs - hir::ItemUnion(..) if !self.tcx.features().untagged_unions => { + hir::ItemKind::Union(..) if !self.tcx.features().untagged_unions => { let def_id = self.tcx.hir.local_def_id(item.id); let adt_def = self.tcx.adt_def(def_id); let ty = self.tcx.type_of(def_id); diff --git a/src/librustc/mir/tcx.rs b/src/librustc/mir/tcx.rs index 67dfad50f44..6876b1490f3 100644 --- a/src/librustc/mir/tcx.rs +++ b/src/librustc/mir/tcx.rs @@ -256,24 +256,24 @@ impl BorrowKind { } impl BinOp { - pub fn to_hir_binop(self) -> hir::BinOp_ { + pub fn to_hir_binop(self) -> hir::BinOpKind { match self { - BinOp::Add => hir::BinOp_::BiAdd, - BinOp::Sub => hir::BinOp_::BiSub, - BinOp::Mul => hir::BinOp_::BiMul, - BinOp::Div => hir::BinOp_::BiDiv, - BinOp::Rem => hir::BinOp_::BiRem, - BinOp::BitXor => hir::BinOp_::BiBitXor, - BinOp::BitAnd => hir::BinOp_::BiBitAnd, - BinOp::BitOr => hir::BinOp_::BiBitOr, - BinOp::Shl => hir::BinOp_::BiShl, - BinOp::Shr => hir::BinOp_::BiShr, - BinOp::Eq => hir::BinOp_::BiEq, - BinOp::Ne => hir::BinOp_::BiNe, - BinOp::Lt => hir::BinOp_::BiLt, - BinOp::Gt => hir::BinOp_::BiGt, - BinOp::Le => hir::BinOp_::BiLe, - BinOp::Ge => hir::BinOp_::BiGe, + BinOp::Add => hir::BinOpKind::Add, + BinOp::Sub => hir::BinOpKind::Sub, + BinOp::Mul => hir::BinOpKind::Mul, + BinOp::Div => hir::BinOpKind::Div, + BinOp::Rem => hir::BinOpKind::Rem, + BinOp::BitXor => hir::BinOpKind::BitXor, + BinOp::BitAnd => hir::BinOpKind::BitAnd, + BinOp::BitOr => hir::BinOpKind::BitOr, + BinOp::Shl => hir::BinOpKind::Shl, + BinOp::Shr => hir::BinOpKind::Shr, + BinOp::Eq => hir::BinOpKind::Eq, + BinOp::Ne => hir::BinOpKind::Ne, + BinOp::Lt => hir::BinOpKind::Lt, + BinOp::Gt => hir::BinOpKind::Gt, + BinOp::Le => hir::BinOpKind::Le, + BinOp::Ge => hir::BinOpKind::Ge, BinOp::Offset => unreachable!() } } diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index a5caacea986..df26ac67060 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -858,7 +858,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { let parent_node = self.tcx.hir.get_parent_node(node_id); if let Some(hir::map::NodeLocal(ref local)) = self.tcx.hir.find(parent_node) { if let Some(ref expr) = local.init { - if let hir::ExprIndex(_, _) = expr.node { + if let hir::ExprKind::Index(_, _) = expr.node { if let Ok(snippet) = self.tcx.sess.codemap().span_to_snippet(expr.span) { err.span_suggestion_with_applicability( expr.span, @@ -927,7 +927,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { pub fn get_fn_like_arguments(&self, node: hir::map::Node) -> (Span, Vec<ArgKind>) { match node { hir::map::NodeExpr(&hir::Expr { - node: hir::ExprClosure(_, ref _decl, id, span, _), + node: hir::ExprKind::Closure(_, ref _decl, id, span, _), .. }) => { (self.tcx.sess.codemap().def_span(span), self.tcx.hir.body(id).arguments.iter() @@ -955,7 +955,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } hir::map::NodeItem(&hir::Item { span, - node: hir::ItemFn(ref decl, ..), + node: hir::ItemKind::Fn(ref decl, ..), .. }) | hir::map::NodeImplItem(&hir::ImplItem { @@ -970,7 +970,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { }) => { (self.tcx.sess.codemap().def_span(span), decl.inputs.iter() .map(|arg| match arg.clone().node { - hir::TyTup(ref tys) => ArgKind::Tuple( + hir::TyKind::Tup(ref tys) => ArgKind::Tuple( Some(arg.span), tys.iter() .map(|_| ("_".to_owned(), "_".to_owned())) @@ -981,7 +981,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } hir::map::NodeVariant(&hir::Variant { span, - node: hir::Variant_ { + node: hir::VariantKind { data: hir::VariantData::Tuple(ref fields, _), .. }, diff --git a/src/librustc/traits/util.rs b/src/librustc/traits/util.rs index 684022f8e8a..875c7199f6d 100644 --- a/src/librustc/traits/util.rs +++ b/src/librustc/traits/util.rs @@ -534,7 +534,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { match self.hir.as_local_node_id(node_item_def_id) { Some(node_id) => { let item = self.hir.expect_item(node_id); - if let hir::ItemImpl(_, _, defaultness, ..) = item.node { + if let hir::ItemKind::Impl(_, _, defaultness, ..) = item.node { defaultness.is_default() } else { false diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 8f7f9d09423..c7bb90bfcb0 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -627,7 +627,7 @@ impl<'tcx> TypeckTables<'tcx> { pub fn is_method_call(&self, expr: &hir::Expr) -> bool { // Only paths and method calls/overloaded operators have // entries in type_dependent_defs, ignore the former here. - if let hir::ExprPath(_) = expr.node { + if let hir::ExprKind::Path(_) = expr.node { return false; } diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index bbfcfb79890..5aa6542a027 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -2757,7 +2757,7 @@ fn associated_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) let parent_def_id = tcx.hir.local_def_id(parent_id); let parent_item = tcx.hir.expect_item(parent_id); match parent_item.node { - hir::ItemImpl(.., ref impl_item_refs) => { + hir::ItemKind::Impl(.., ref impl_item_refs) => { if let Some(impl_item_ref) = impl_item_refs.iter().find(|i| i.id.node_id == id) { let assoc_item = tcx.associated_item_from_impl_item_ref(parent_def_id, impl_item_ref); @@ -2766,7 +2766,7 @@ fn associated_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) } } - hir::ItemTrait(.., ref trait_item_refs) => { + hir::ItemKind::Trait(.., ref trait_item_refs) => { if let Some(trait_item_ref) = trait_item_refs.iter().find(|i| i.id.node_id == id) { let assoc_item = tcx.associated_item_from_trait_item_ref(parent_def_id, &parent_item.vis, @@ -2815,19 +2815,19 @@ fn associated_item_def_ids<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let id = tcx.hir.as_local_node_id(def_id).unwrap(); let item = tcx.hir.expect_item(id); let vec: Vec<_> = match item.node { - hir::ItemTrait(.., ref trait_item_refs) => { + hir::ItemKind::Trait(.., ref trait_item_refs) => { trait_item_refs.iter() .map(|trait_item_ref| trait_item_ref.id) .map(|id| tcx.hir.local_def_id(id.node_id)) .collect() } - hir::ItemImpl(.., ref impl_item_refs) => { + hir::ItemKind::Impl(.., ref impl_item_refs) => { impl_item_refs.iter() .map(|impl_item_ref| impl_item_ref.id) .map(|id| tcx.hir.local_def_id(id.node_id)) .collect() } - hir::ItemTraitAlias(..) => vec![], + hir::ItemKind::TraitAlias(..) => vec![], _ => span_bug!(item.span, "associated_item_def_ids: not impl or trait") }; Lrc::new(vec) diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs index f118d22c54d..d5425aff6ba 100644 --- a/src/librustc/ty/util.rs +++ b/src/librustc/ty/util.rs @@ -605,10 +605,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { if let Some(node) = self.hir.get_if_local(def_id) { match node { Node::NodeItem(&hir::Item { - node: hir::ItemStatic(_, mutbl, _), .. + node: hir::ItemKind::Static(_, mutbl, _), .. }) => Some(mutbl), Node::NodeForeignItem(&hir::ForeignItem { - node: hir::ForeignItemStatic(_, is_mutbl), .. + node: hir::ForeignItemKind::Static(_, is_mutbl), .. }) => Some(if is_mutbl { hir::Mutability::MutMutable diff --git a/src/librustc_borrowck/borrowck/check_loans.rs b/src/librustc_borrowck/borrowck/check_loans.rs index 046318b3619..002e8697588 100644 --- a/src/librustc_borrowck/borrowck/check_loans.rs +++ b/src/librustc_borrowck/borrowck/check_loans.rs @@ -203,7 +203,7 @@ pub fn check_loans<'a, 'b, 'c, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, let node_id = bccx.tcx.hir.as_local_node_id(def_id).unwrap(); let movable_generator = !match bccx.tcx.hir.get(node_id) { hir::map::Node::NodeExpr(&hir::Expr { - node: hir::ExprClosure(.., Some(hir::GeneratorMovability::Static)), + node: hir::ExprKind::Closure(.., Some(hir::GeneratorMovability::Static)), .. }) => true, _ => false, diff --git a/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs b/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs index 241950fb6bf..7ce6863a7c9 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs @@ -63,7 +63,7 @@ fn get_pattern_source<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, pat: &Pat) -> Patte NodeExpr(ref e) => { // the enclosing expression must be a `match` or something else assert!(match e.node { - ExprMatch(..) => true, + ExprKind::Match(..) => true, _ => return PatternSource::Other, }); PatternSource::MatchExpr(e) diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index 79b43823692..3ae1e5aac50 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -409,7 +409,7 @@ fn closure_to_block(closure_id: LocalDefId, let closure_id = tcx.hir.local_def_id_to_node_id(closure_id); match tcx.hir.get(closure_id) { hir_map::NodeExpr(expr) => match expr.node { - hir::ExprClosure(.., body_id, _, _) => { + hir::ExprKind::Closure(.., body_id, _, _) => { body_id.node_id } _ => { @@ -722,7 +722,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { move_data::Captured => (match self.tcx.hir.expect_expr(node_id).node { - hir::ExprClosure(.., fn_decl_span, _) => fn_decl_span, + hir::ExprKind::Closure(.., fn_decl_span, _) => fn_decl_span, ref r => bug!("Captured({:?}) maps to non-closure: {:?}", the_move.id, r), }, " (into closure)"), @@ -1131,7 +1131,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { fn suggest_mut_for_immutable(&self, pty: &hir::Ty, is_implicit_self: bool) -> Option<String> { // Check whether the argument is an immutable reference debug!("suggest_mut_for_immutable({:?}, {:?})", pty, is_implicit_self); - if let hir::TyRptr(lifetime, hir::MutTy { + if let hir::TyKind::Rptr(lifetime, hir::MutTy { mutbl: hir::Mutability::MutImmutable, ref ty }) = pty.node { @@ -1259,7 +1259,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { // avoid suggesting `mut &self`. return } - if let Some(&hir::TyRptr( + if let Some(&hir::TyKind::Rptr( _, hir::MutTy { mutbl: hir::MutMutable, diff --git a/src/librustc_codegen_llvm/back/symbol_export.rs b/src/librustc_codegen_llvm/back/symbol_export.rs index 28e76a80513..94357f34849 100644 --- a/src/librustc_codegen_llvm/back/symbol_export.rs +++ b/src/librustc_codegen_llvm/back/symbol_export.rs @@ -105,11 +105,11 @@ fn reachable_non_generics_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, // Only consider nodes that actually have exported symbols. hir::map::NodeItem(&hir::Item { - node: hir::ItemStatic(..), + node: hir::ItemKind::Static(..), .. }) | hir::map::NodeItem(&hir::Item { - node: hir::ItemFn(..), .. + node: hir::ItemKind::Fn(..), .. }) | hir::map::NodeImplItem(&hir::ImplItem { node: hir::ImplItemKind::Method(..), diff --git a/src/librustc_codegen_llvm/base.rs b/src/librustc_codegen_llvm/base.rs index ea26e271c9b..d4d0b67523e 100644 --- a/src/librustc_codegen_llvm/base.rs +++ b/src/librustc_codegen_llvm/base.rs @@ -124,16 +124,16 @@ impl<'a, 'tcx> Drop for StatRecorder<'a, 'tcx> { } } -pub fn bin_op_to_icmp_predicate(op: hir::BinOp_, +pub fn bin_op_to_icmp_predicate(op: hir::BinOpKind, signed: bool) -> llvm::IntPredicate { match op { - hir::BiEq => llvm::IntEQ, - hir::BiNe => llvm::IntNE, - hir::BiLt => if signed { llvm::IntSLT } else { llvm::IntULT }, - hir::BiLe => if signed { llvm::IntSLE } else { llvm::IntULE }, - hir::BiGt => if signed { llvm::IntSGT } else { llvm::IntUGT }, - hir::BiGe => if signed { llvm::IntSGE } else { llvm::IntUGE }, + hir::BinOpKind::Eq => llvm::IntEQ, + hir::BinOpKind::Ne => llvm::IntNE, + hir::BinOpKind::Lt => if signed { llvm::IntSLT } else { llvm::IntULT }, + hir::BinOpKind::Le => if signed { llvm::IntSLE } else { llvm::IntULE }, + hir::BinOpKind::Gt => if signed { llvm::IntSGT } else { llvm::IntUGT }, + hir::BinOpKind::Ge => if signed { llvm::IntSGE } else { llvm::IntUGE }, op => { bug!("comparison_op_to_icmp_predicate: expected comparison operator, \ found {:?}", @@ -142,14 +142,14 @@ pub fn bin_op_to_icmp_predicate(op: hir::BinOp_, } } -pub fn bin_op_to_fcmp_predicate(op: hir::BinOp_) -> llvm::RealPredicate { +pub fn bin_op_to_fcmp_predicate(op: hir::BinOpKind) -> llvm::RealPredicate { match op { - hir::BiEq => llvm::RealOEQ, - hir::BiNe => llvm::RealUNE, - hir::BiLt => llvm::RealOLT, - hir::BiLe => llvm::RealOLE, - hir::BiGt => llvm::RealOGT, - hir::BiGe => llvm::RealOGE, + hir::BinOpKind::Eq => llvm::RealOEQ, + hir::BinOpKind::Ne => llvm::RealUNE, + hir::BinOpKind::Lt => llvm::RealOLT, + hir::BinOpKind::Le => llvm::RealOLE, + hir::BinOpKind::Gt => llvm::RealOGT, + hir::BinOpKind::Ge => llvm::RealOGE, op => { bug!("comparison_op_to_fcmp_predicate: expected comparison operator, \ found {:?}", @@ -164,7 +164,7 @@ pub fn compare_simd_types<'a, 'tcx>( rhs: ValueRef, t: Ty<'tcx>, ret_ty: Type, - op: hir::BinOp_ + op: hir::BinOpKind ) -> ValueRef { let signed = match t.sty { ty::TyFloat(_) => { @@ -332,12 +332,12 @@ pub fn coerce_unsized_into<'a, 'tcx>(bx: &Builder<'a, 'tcx>, } pub fn cast_shift_expr_rhs( - cx: &Builder, op: hir::BinOp_, lhs: ValueRef, rhs: ValueRef + cx: &Builder, op: hir::BinOpKind, lhs: ValueRef, rhs: ValueRef ) -> ValueRef { cast_shift_rhs(op, lhs, rhs, |a, b| cx.trunc(a, b), |a, b| cx.zext(a, b)) } -fn cast_shift_rhs<F, G>(op: hir::BinOp_, +fn cast_shift_rhs<F, G>(op: hir::BinOpKind, lhs: ValueRef, rhs: ValueRef, trunc: F, diff --git a/src/librustc_codegen_llvm/common.rs b/src/librustc_codegen_llvm/common.rs index 7e55642814b..60bba635a78 100644 --- a/src/librustc_codegen_llvm/common.rs +++ b/src/librustc_codegen_llvm/common.rs @@ -350,7 +350,7 @@ pub fn build_unchecked_lshift<'a, 'tcx>( lhs: ValueRef, rhs: ValueRef ) -> ValueRef { - let rhs = base::cast_shift_expr_rhs(bx, hir::BinOp_::BiShl, lhs, rhs); + let rhs = base::cast_shift_expr_rhs(bx, hir::BinOpKind::Shl, lhs, rhs); // #1877, #10183: Ensure that input is always valid let rhs = shift_mask_rhs(bx, rhs); bx.shl(lhs, rhs) @@ -359,7 +359,7 @@ pub fn build_unchecked_lshift<'a, 'tcx>( pub fn build_unchecked_rshift<'a, 'tcx>( bx: &Builder<'a, 'tcx>, lhs_t: Ty<'tcx>, lhs: ValueRef, rhs: ValueRef ) -> ValueRef { - let rhs = base::cast_shift_expr_rhs(bx, hir::BinOp_::BiShr, lhs, rhs); + let rhs = base::cast_shift_expr_rhs(bx, hir::BinOpKind::Shr, lhs, rhs); // #1877, #10183: Ensure that input is always valid let rhs = shift_mask_rhs(bx, rhs); let is_signed = lhs_t.is_signed(); diff --git a/src/librustc_codegen_llvm/consts.rs b/src/librustc_codegen_llvm/consts.rs index 199c40bb704..6e3096d4cd5 100644 --- a/src/librustc_codegen_llvm/consts.rs +++ b/src/librustc_codegen_llvm/consts.rs @@ -125,7 +125,7 @@ pub fn get_static(cx: &CodegenCx, def_id: DefId) -> ValueRef { let llty = cx.layout_of(ty).llvm_type(cx); let (g, attrs) = match cx.tcx.hir.get(id) { hir_map::NodeItem(&hir::Item { - ref attrs, span, node: hir::ItemStatic(..), .. + ref attrs, span, node: hir::ItemKind::Static(..), .. }) => { if declare::get_declared_value(cx, &sym[..]).is_some() { span_bug!(span, "Conflicting symbol names for static?"); @@ -143,7 +143,7 @@ pub fn get_static(cx: &CodegenCx, def_id: DefId) -> ValueRef { } hir_map::NodeForeignItem(&hir::ForeignItem { - ref attrs, span, node: hir::ForeignItemStatic(..), .. + ref attrs, span, node: hir::ForeignItemKind::Static(..), .. }) => { let g = if let Some(linkage) = cx.tcx.codegen_fn_attrs(def_id).linkage { // If this is a static with a linkage specified, then we need to handle diff --git a/src/librustc_codegen_llvm/intrinsic.rs b/src/librustc_codegen_llvm/intrinsic.rs index 7625e4c7e0f..58a32ad9774 100644 --- a/src/librustc_codegen_llvm/intrinsic.rs +++ b/src/librustc_codegen_llvm/intrinsic.rs @@ -1022,12 +1022,12 @@ fn generic_simd_intrinsic<'a, 'tcx>( let in_len = arg_tys[0].simd_size(tcx); let comparison = match name { - "simd_eq" => Some(hir::BiEq), - "simd_ne" => Some(hir::BiNe), - "simd_lt" => Some(hir::BiLt), - "simd_le" => Some(hir::BiLe), - "simd_gt" => Some(hir::BiGt), - "simd_ge" => Some(hir::BiGe), + "simd_eq" => Some(hir::BinOpKind::Eq), + "simd_ne" => Some(hir::BinOpKind::Ne), + "simd_lt" => Some(hir::BinOpKind::Lt), + "simd_le" => Some(hir::BinOpKind::Le), + "simd_gt" => Some(hir::BinOpKind::Gt), + "simd_ge" => Some(hir::BinOpKind::Ge), _ => None }; diff --git a/src/librustc_codegen_llvm/mono_item.rs b/src/librustc_codegen_llvm/mono_item.rs index e142a7d9c1c..b512a6f1bb4 100644 --- a/src/librustc_codegen_llvm/mono_item.rs +++ b/src/librustc_codegen_llvm/mono_item.rs @@ -60,7 +60,7 @@ pub trait MonoItemExt<'a, 'tcx>: fmt::Debug + BaseMonoItemExt<'a, 'tcx> { } MonoItem::GlobalAsm(node_id) => { let item = cx.tcx.hir.expect_item(node_id); - if let hir::ItemGlobalAsm(ref ga) = item.node { + if let hir::ItemKind::GlobalAsm(ref ga) = item.node { asm::codegen_global_asm(cx, ga); } else { span_bug!(item.span, "Mismatch between hir::Item type and MonoItem type") diff --git a/src/librustc_driver/test.rs b/src/librustc_driver/test.rs index 9808e289f3b..f082d03234a 100644 --- a/src/librustc_driver/test.rs +++ b/src/librustc_driver/test.rs @@ -249,24 +249,24 @@ impl<'a, 'gcx, 'tcx> Env<'a, 'gcx, 'tcx> { } return match it.node { - hir::ItemUse(..) | - hir::ItemExternCrate(..) | - hir::ItemConst(..) | - hir::ItemStatic(..) | - hir::ItemFn(..) | - hir::ItemForeignMod(..) | - hir::ItemGlobalAsm(..) | - hir::ItemExistential(..) | - hir::ItemTy(..) => None, - - hir::ItemEnum(..) | - hir::ItemStruct(..) | - hir::ItemUnion(..) | - hir::ItemTrait(..) | - hir::ItemTraitAlias(..) | - hir::ItemImpl(..) => None, - - hir::ItemMod(ref m) => search_mod(this, m, idx, names), + hir::ItemKind::Use(..) | + hir::ItemKind::ExternCrate(..) | + hir::ItemKind::Const(..) | + hir::ItemKind::Static(..) | + hir::ItemKind::Fn(..) | + hir::ItemKind::ForeignMod(..) | + hir::ItemKind::GlobalAsm(..) | + hir::ItemKind::Existential(..) | + hir::ItemKind::Ty(..) => None, + + hir::ItemKind::Enum(..) | + hir::ItemKind::Struct(..) | + hir::ItemKind::Union(..) | + hir::ItemKind::Trait(..) | + hir::ItemKind::TraitAlias(..) | + hir::ItemKind::Impl(..) => None, + + hir::ItemKind::Mod(ref m) => search_mod(this, m, idx, names), }; } } diff --git a/src/librustc_incremental/persist/dirty_clean.rs b/src/librustc_incremental/persist/dirty_clean.rs index eeb87e41757..39e674a6095 100644 --- a/src/librustc_incremental/persist/dirty_clean.rs +++ b/src/librustc_incremental/persist/dirty_clean.rs @@ -29,7 +29,7 @@ use std::iter::FromIterator; use std::vec::Vec; use rustc::dep_graph::{DepNode, label_strs}; use rustc::hir; -use rustc::hir::{Item_ as HirItem, ImplItemKind, TraitItemKind}; +use rustc::hir::{ItemKind as HirItem, ImplItemKind, TraitItemKind}; use rustc::hir::map::Node as HirNode; use rustc::hir::def_id::DefId; use rustc::hir::itemlikevisit::ItemLikeVisitor; @@ -342,40 +342,40 @@ impl<'a, 'tcx> DirtyCleanVisitor<'a, 'tcx> { // FIXME(michaelwoerister): do commented out ones // // An `extern crate` item, with optional original crate name, - // HirItem::ItemExternCrate(..), // intentionally no assertions + // HirItem::ExternCrate(..), // intentionally no assertions // // `use foo::bar::*;` or `use foo::bar::baz as quux;` - // HirItem::ItemUse(..), // intentionally no assertions + // HirItem::Use(..), // intentionally no assertions // A `static` item - HirItem::ItemStatic(..) => ("ItemStatic", LABELS_CONST), + HirItem::Static(..) => ("ItemStatic", LABELS_CONST), // A `const` item - HirItem::ItemConst(..) => ("ItemConst", LABELS_CONST), + HirItem::Const(..) => ("ItemConst", LABELS_CONST), // A function declaration - HirItem::ItemFn(..) => ("ItemFn", LABELS_FN), + HirItem::Fn(..) => ("ItemFn", LABELS_FN), // // A module - HirItem::ItemMod(..) =>("ItemMod", LABELS_HIR_ONLY), + HirItem::Mod(..) =>("ItemMod", LABELS_HIR_ONLY), // // An external module - HirItem::ItemForeignMod(..) => ("ItemForeignMod", LABELS_HIR_ONLY), + HirItem::ForeignMod(..) => ("ItemForeignMod", LABELS_HIR_ONLY), // Module-level inline assembly (from global_asm!) - HirItem::ItemGlobalAsm(..) => ("ItemGlobalAsm", LABELS_HIR_ONLY), + HirItem::GlobalAsm(..) => ("ItemGlobalAsm", LABELS_HIR_ONLY), // A type alias, e.g. `type Foo = Bar<u8>` - HirItem::ItemTy(..) => ("ItemTy", LABELS_HIR_ONLY), + HirItem::Ty(..) => ("ItemTy", LABELS_HIR_ONLY), // An enum definition, e.g. `enum Foo<A, B> {C<A>, D<B>}` - HirItem::ItemEnum(..) => ("ItemEnum", LABELS_ADT), + HirItem::Enum(..) => ("ItemEnum", LABELS_ADT), // A struct definition, e.g. `struct Foo<A> {x: A}` - HirItem::ItemStruct(..) => ("ItemStruct", LABELS_ADT), + HirItem::Struct(..) => ("ItemStruct", LABELS_ADT), // A union definition, e.g. `union Foo<A, B> {x: A, y: B}` - HirItem::ItemUnion(..) => ("ItemUnion", LABELS_ADT), + HirItem::Union(..) => ("ItemUnion", LABELS_ADT), // Represents a Trait Declaration // FIXME(michaelwoerister): trait declaration is buggy because sometimes some of @@ -391,10 +391,10 @@ impl<'a, 'tcx> DirtyCleanVisitor<'a, 'tcx> { // However, this did not seem to work effectively and more bugs were hit. // Nebie @vitiral gave up :) // - //HirItem::ItemTrait(..) => ("ItemTrait", LABELS_TRAIT), + //HirItem::Trait(..) => ("ItemTrait", LABELS_TRAIT), // An implementation, eg `impl<A> Trait for Foo { .. }` - HirItem::ItemImpl(..) => ("ItemImpl", LABELS_IMPL), + HirItem::Impl(..) => ("ItemKind::Impl", LABELS_IMPL), _ => self.tcx.sess.span_fatal( attr.span, diff --git a/src/librustc_lint/bad_style.rs b/src/librustc_lint/bad_style.rs index 6bc364b7261..fd5a152311d 100644 --- a/src/librustc_lint/bad_style.rs +++ b/src/librustc_lint/bad_style.rs @@ -133,11 +133,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonCamelCaseTypes { } match it.node { - hir::ItemTy(..) | - hir::ItemEnum(..) | - hir::ItemStruct(..) | - hir::ItemUnion(..) => self.check_case(cx, "type", it.name, it.span), - hir::ItemTrait(..) => self.check_case(cx, "trait", it.name, it.span), + hir::ItemKind::Ty(..) | + hir::ItemKind::Enum(..) | + hir::ItemKind::Struct(..) | + hir::ItemKind::Union(..) => self.check_case(cx, "type", it.name, it.span), + hir::ItemKind::Trait(..) => self.check_case(cx, "trait", it.name, it.span), _ => (), } } @@ -296,7 +296,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSnakeCase { } fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { - if let hir::ItemMod(_) = it.node { + if let hir::ItemKind::Mod(_) = it.node { self.check_snake_case(cx, "module", &it.name.as_str(), Some(it.span)); } } @@ -369,13 +369,13 @@ impl LintPass for NonUpperCaseGlobals { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonUpperCaseGlobals { fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { match it.node { - hir::ItemStatic(..) => { + hir::ItemKind::Static(..) => { if attr::find_by_name(&it.attrs, "no_mangle").is_some() { return; } NonUpperCaseGlobals::check_upper_case(cx, "static variable", it.name, it.span); } - hir::ItemConst(..) => { + hir::ItemKind::Const(..) => { NonUpperCaseGlobals::check_upper_case(cx, "constant", it.name, it.span); } _ => {} diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 0b33e397d18..8a674449880 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -75,8 +75,8 @@ impl LintPass for WhileTrue { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for WhileTrue { fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) { - if let hir::ExprWhile(ref cond, ..) = e.node { - if let hir::ExprLit(ref lit) = cond.node { + if let hir::ExprKind::While(ref cond, ..) = e.node { + if let hir::ExprKind::Lit(ref lit) = cond.node { if let ast::LitKind::Bool(true) = lit.node { if lit.span.ctxt() == SyntaxContext::empty() { let msg = "denote infinite loops with `loop { ... }`"; @@ -120,11 +120,11 @@ impl LintPass for BoxPointers { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxPointers { fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { match it.node { - hir::ItemFn(..) | - hir::ItemTy(..) | - hir::ItemEnum(..) | - hir::ItemStruct(..) | - hir::ItemUnion(..) => { + hir::ItemKind::Fn(..) | + hir::ItemKind::Ty(..) | + hir::ItemKind::Enum(..) | + hir::ItemKind::Struct(..) | + hir::ItemKind::Union(..) => { let def_id = cx.tcx.hir.local_def_id(it.id); self.check_heap_type(cx, it.span, cx.tcx.type_of(def_id)) } @@ -133,8 +133,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxPointers { // If it's a struct, we also have to check the fields' types match it.node { - hir::ItemStruct(ref struct_def, _) | - hir::ItemUnion(ref struct_def, _) => { + hir::ItemKind::Struct(ref struct_def, _) | + hir::ItemKind::Union(ref struct_def, _) => { for struct_field in struct_def.fields() { let def_id = cx.tcx.hir.local_def_id(struct_field.id); self.check_heap_type(cx, struct_field.span, @@ -226,7 +226,7 @@ impl UnsafeCode { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnsafeCode { fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) { - if let hir::ExprBlock(ref blk, _) = e.node { + if let hir::ExprKind::Block(ref blk, _) = e.node { // Don't warn about generated blocks, that'll just pollute the output. if blk.rules == hir::UnsafeBlock(hir::UserProvided) { self.report_unsafe(cx, blk.span, "usage of an `unsafe` block"); @@ -236,11 +236,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnsafeCode { fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { match it.node { - hir::ItemTrait(_, hir::Unsafety::Unsafe, ..) => { + hir::ItemKind::Trait(_, hir::Unsafety::Unsafe, ..) => { self.report_unsafe(cx, it.span, "declaration of an `unsafe` trait") } - hir::ItemImpl(hir::Unsafety::Unsafe, ..) => { + hir::ItemKind::Impl(hir::Unsafety::Unsafe, ..) => { self.report_unsafe(cx, it.span, "implementation of an `unsafe` trait") } @@ -390,12 +390,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc { fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { let desc = match it.node { - hir::ItemFn(..) => "a function", - hir::ItemMod(..) => "a module", - hir::ItemEnum(..) => "an enum", - hir::ItemStruct(..) => "a struct", - hir::ItemUnion(..) => "a union", - hir::ItemTrait(.., ref trait_item_refs) => { + hir::ItemKind::Fn(..) => "a function", + hir::ItemKind::Mod(..) => "a module", + hir::ItemKind::Enum(..) => "an enum", + hir::ItemKind::Struct(..) => "a struct", + hir::ItemKind::Union(..) => "a union", + hir::ItemKind::Trait(.., ref trait_item_refs) => { // Issue #11592, traits are always considered exported, even when private. if let hir::VisibilityKind::Inherited = it.vis.node { self.private_traits.insert(it.id); @@ -406,8 +406,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc { } "a trait" } - hir::ItemTy(..) => "a type alias", - hir::ItemImpl(.., Some(ref trait_ref), _, ref impl_item_refs) => { + hir::ItemKind::Ty(..) => "a type alias", + hir::ItemKind::Impl(.., Some(ref trait_ref), _, ref impl_item_refs) => { // If the trait is private, add the impl items to private_traits so they don't get // reported for missing docs. let real_trait = trait_ref.path.def.def_id(); @@ -425,8 +425,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc { } return; } - hir::ItemConst(..) => "a constant", - hir::ItemStatic(..) => "a static", + hir::ItemKind::Const(..) => "a constant", + hir::ItemKind::Static(..) => "a static", _ => return, }; @@ -509,21 +509,21 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingCopyImplementations { return; } let (def, ty) = match item.node { - hir::ItemStruct(_, ref ast_generics) => { + hir::ItemKind::Struct(_, ref ast_generics) => { if !ast_generics.params.is_empty() { return; } let def = cx.tcx.adt_def(cx.tcx.hir.local_def_id(item.id)); (def, cx.tcx.mk_adt(def, cx.tcx.intern_substs(&[]))) } - hir::ItemUnion(_, ref ast_generics) => { + hir::ItemKind::Union(_, ref ast_generics) => { if !ast_generics.params.is_empty() { return; } let def = cx.tcx.adt_def(cx.tcx.hir.local_def_id(item.id)); (def, cx.tcx.mk_adt(def, cx.tcx.intern_substs(&[]))) } - hir::ItemEnum(_, ref ast_generics) => { + hir::ItemKind::Enum(_, ref ast_generics) => { if !ast_generics.params.is_empty() { return; } @@ -577,9 +577,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDebugImplementations { } match item.node { - hir::ItemStruct(..) | - hir::ItemUnion(..) | - hir::ItemEnum(..) => {} + hir::ItemKind::Struct(..) | + hir::ItemKind::Union(..) | + hir::ItemKind::Enum(..) => {} _ => return, } @@ -960,8 +960,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnconditionalRecursion { fn expr_refers_to_this_fn(cx: &LateContext, fn_id: ast::NodeId, id: ast::NodeId) -> bool { match cx.tcx.hir.get(id) { - hir_map::NodeExpr(&hir::Expr { node: hir::ExprCall(ref callee, _), .. }) => { - let def = if let hir::ExprPath(ref qpath) = callee.node { + hir_map::NodeExpr(&hir::Expr { node: hir::ExprKind::Call(ref callee, _), .. }) => { + let def = if let hir::ExprKind::Path(ref qpath) = callee.node { cx.tables.qpath_def(qpath, callee.hir_id) } else { return false; @@ -1018,8 +1018,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnconditionalRecursion { // Check for calls to methods via explicit paths (e.g. `T::method()`). match expr.node { - hir::ExprCall(ref callee, _) => { - let def = if let hir::ExprPath(ref qpath) = callee.node { + hir::ExprKind::Call(ref callee, _) => { + let def = if let hir::ExprKind::Path(ref qpath) = callee.node { cx.tables.qpath_def(qpath, callee.hir_id) } else { return false; @@ -1121,7 +1121,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PluginAsLibrary { } match it.node { - hir::ItemExternCrate(..) => (), + hir::ItemKind::ExternCrate(..) => (), _ => return, }; @@ -1203,7 +1203,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidNoMangleItems { }; match it.node { - hir::ItemFn(.., ref generics, _) => { + hir::ItemKind::Fn(.., ref generics, _) => { if let Some(no_mangle_attr) = attr::find_by_name(&it.attrs, "no_mangle") { if attr::contains_name(&it.attrs, "linkage") { return; @@ -1232,7 +1232,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidNoMangleItems { } } } - hir::ItemStatic(..) => { + hir::ItemKind::Static(..) => { if attr::contains_name(&it.attrs, "no_mangle") && !cx.access_levels.is_reachable(it.id) { let msg = "static is marked #[no_mangle], but not exported"; @@ -1241,7 +1241,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidNoMangleItems { err.emit(); } } - hir::ItemConst(..) => { + hir::ItemKind::Const(..) => { if attr::contains_name(&it.attrs, "no_mangle") { // Const items do not refer to a particular location in memory, and therefore // don't have anything to attach a symbol to @@ -1300,7 +1300,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutableTransmutes { (cx: &LateContext<'a, 'tcx>, expr: &hir::Expr) -> Option<(&'tcx ty::TypeVariants<'tcx>, &'tcx ty::TypeVariants<'tcx>)> { - let def = if let hir::ExprPath(ref qpath) = expr.node { + let def = if let hir::ExprKind::Path(ref qpath) = expr.node { cx.tables.qpath_def(qpath, expr.hir_id) } else { return None; @@ -1369,7 +1369,7 @@ impl LintPass for UnionsWithDropFields { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnionsWithDropFields { fn check_item(&mut self, ctx: &LateContext, item: &hir::Item) { - if let hir::ItemUnion(ref vdata, _) = item.node { + if let hir::ItemKind::Union(ref vdata, _) = item.node { for field in vdata.fields() { let field_ty = ctx.tcx.type_of(ctx.tcx.hir.local_def_id(field.id)); if field_ty.needs_drop(ctx.tcx, ctx.param_env) { @@ -1475,7 +1475,7 @@ impl TypeAliasBounds { hir::QPath::TypeRelative(ref ty, _) => { // If this is a type variable, we found a `T::Assoc`. match ty.node { - hir::TyPath(hir::QPath::Resolved(None, ref path)) => { + hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) => { match path.def { Def::TyParam(_) => true, _ => false @@ -1523,7 +1523,7 @@ impl TypeAliasBounds { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeAliasBounds { fn check_item(&mut self, cx: &LateContext, item: &hir::Item) { let (ty, type_alias_generics) = match item.node { - hir::ItemTy(ref ty, ref generics) => (&*ty, generics), + hir::ItemKind::Ty(ref ty, ref generics) => (&*ty, generics), _ => return, }; let mut suggested_changing_assoc_types = false; @@ -1605,10 +1605,10 @@ impl<'a, 'tcx, 'v> hir::intravisit::Visitor<'v> for UnusedBrokenConstVisitor<'a, impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedBrokenConst { fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { match it.node { - hir::ItemConst(_, body_id) => { + hir::ItemKind::Const(_, body_id) => { check_const(cx, body_id, "constant"); }, - hir::ItemTy(ref ty, _) => hir::intravisit::walk_ty( + hir::ItemKind::Ty(ref ty, _) => hir::intravisit::walk_ty( &mut UnusedBrokenConstVisitor(cx), ty ), @@ -1761,12 +1761,12 @@ impl LintPass for UnnameableTestFunctions { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnnameableTestFunctions { fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { match it.node { - hir::ItemFn(..) => { + hir::ItemKind::Fn(..) => { for attr in &it.attrs { if attr.name() == "test" { let parent = cx.tcx.hir.get_parent(it.id); match cx.tcx.hir.find(parent) { - Some(hir_map::NodeItem(hir::Item {node: hir::ItemMod(_), ..})) | + Some(hir_map::NodeItem(hir::Item {node: hir::ItemKind::Mod(_), ..})) | None => {} _ => { cx.struct_span_lint( diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index e5bd6a7f610..ad4a4fbff64 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -68,20 +68,20 @@ impl LintPass for TypeLimits { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr) { match e.node { - hir::ExprUnary(hir::UnNeg, ref expr) => { + hir::ExprKind::Unary(hir::UnNeg, ref expr) => { // propagate negation, if the negation itself isn't negated if self.negated_expr_id != e.id { self.negated_expr_id = expr.id; } } - hir::ExprBinary(binop, ref l, ref r) => { + hir::ExprKind::Binary(binop, ref l, ref r) => { if is_comparison(binop) && !check_limits(cx, binop, &l, &r) { cx.span_lint(UNUSED_COMPARISONS, e.span, "comparison is useless due to type limits"); } } - hir::ExprLit(ref lit) => { + hir::ExprKind::Lit(ref lit) => { match cx.tables.node_id_to_type(e.hir_id).sty { ty::TyInt(t) => { match lit.node { @@ -137,7 +137,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { if lit_val < min || lit_val > max { let parent_id = cx.tcx.hir.get_parent_node(e.id); if let hir_map::NodeExpr(parent_expr) = cx.tcx.hir.get(parent_id) { - if let hir::ExprCast(..) = parent_expr.node { + if let hir::ExprKind::Cast(..) = parent_expr.node { if let ty::TyChar = cx.tables.expr_ty(parent_expr).sty { let mut err = cx.struct_span_lint( OVERFLOWING_LITERALS, @@ -194,11 +194,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { fn is_valid<T: cmp::PartialOrd>(binop: hir::BinOp, v: T, min: T, max: T) -> bool { match binop.node { - hir::BiLt => v > min && v <= max, - hir::BiLe => v >= min && v < max, - hir::BiGt => v >= min && v < max, - hir::BiGe => v > min && v <= max, - hir::BiEq | hir::BiNe => v >= min && v <= max, + hir::BinOpKind::Lt => v > min && v <= max, + hir::BinOpKind::Le => v >= min && v < max, + hir::BinOpKind::Gt => v >= min && v < max, + hir::BinOpKind::Ge => v > min && v <= max, + hir::BinOpKind::Eq | hir::BinOpKind::Ne => v >= min && v <= max, _ => bug!(), } } @@ -206,10 +206,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { fn rev_binop(binop: hir::BinOp) -> hir::BinOp { codemap::respan(binop.span, match binop.node { - hir::BiLt => hir::BiGt, - hir::BiLe => hir::BiGe, - hir::BiGt => hir::BiLt, - hir::BiGe => hir::BiLe, + hir::BinOpKind::Lt => hir::BinOpKind::Gt, + hir::BinOpKind::Le => hir::BinOpKind::Ge, + hir::BinOpKind::Gt => hir::BinOpKind::Lt, + hir::BinOpKind::Ge => hir::BinOpKind::Le, _ => return binop, }) } @@ -244,8 +244,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { r: &hir::Expr) -> bool { let (lit, expr, swap) = match (&l.node, &r.node) { - (&hir::ExprLit(_), _) => (l, r, true), - (_, &hir::ExprLit(_)) => (r, l, false), + (&hir::ExprKind::Lit(_), _) => (l, r, true), + (_, &hir::ExprKind::Lit(_)) => (r, l, false), _ => return true, }; // Normalize the binop so that the literal is always on the RHS in @@ -255,7 +255,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { ty::TyInt(int_ty) => { let (min, max) = int_ty_range(int_ty); let lit_val: i128 = match lit.node { - hir::ExprLit(ref li) => { + hir::ExprKind::Lit(ref li) => { match li.node { ast::LitKind::Int(v, ast::LitIntType::Signed(_)) | ast::LitKind::Int(v, ast::LitIntType::Unsuffixed) => v as i128, @@ -269,7 +269,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { ty::TyUint(uint_ty) => { let (min, max) :(u128, u128) = uint_ty_range(uint_ty); let lit_val: u128 = match lit.node { - hir::ExprLit(ref li) => { + hir::ExprKind::Lit(ref li) => { match li.node { ast::LitKind::Int(v, _) => v, _ => return true @@ -285,7 +285,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { fn is_comparison(binop: hir::BinOp) -> bool { match binop.node { - hir::BiEq | hir::BiLt | hir::BiLe | hir::BiNe | hir::BiGe | hir::BiGt => true, + hir::BinOpKind::Eq | + hir::BinOpKind::Lt | + hir::BinOpKind::Le | + hir::BinOpKind::Ne | + hir::BinOpKind::Ge | + hir::BinOpKind::Gt => true, _ => false, } } @@ -782,17 +787,17 @@ impl LintPass for ImproperCTypes { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImproperCTypes { fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { let mut vis = ImproperCTypesVisitor { cx: cx }; - if let hir::ItemForeignMod(ref nmod) = it.node { + if let hir::ItemKind::ForeignMod(ref nmod) = it.node { if nmod.abi != Abi::RustIntrinsic && nmod.abi != Abi::PlatformIntrinsic { for ni in &nmod.items { match ni.node { - hir::ForeignItemFn(ref decl, _, _) => { + hir::ForeignItemKind::Fn(ref decl, _, _) => { vis.check_foreign_fn(ni.id, decl); } - hir::ForeignItemStatic(ref ty, _) => { + hir::ForeignItemKind::Static(ref ty, _) => { vis.check_foreign_static(ni.id, ty.span); } - hir::ForeignItemType => () + hir::ForeignItemKind::Type => () } } } @@ -810,7 +815,7 @@ impl LintPass for VariantSizeDifferences { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for VariantSizeDifferences { fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { - if let hir::ItemEnum(ref enum_definition, _) = it.node { + if let hir::ItemKind::Enum(ref enum_definition, _) = it.node { let item_def_id = cx.tcx.hir.local_def_id(it.id); let generics = cx.tcx.generics_of(item_def_id); for param in &generics.params { diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index 81b4ae3f6e8..3d64fa572d1 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -49,11 +49,11 @@ impl LintPass for UnusedResults { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults { fn check_stmt(&mut self, cx: &LateContext, s: &hir::Stmt) { let expr = match s.node { - hir::StmtSemi(ref expr, _) => &**expr, + hir::StmtKind::Semi(ref expr, _) => &**expr, _ => return, }; - if let hir::ExprRet(..) = expr.node { + if let hir::ExprKind::Ret(..) = expr.node { return; } @@ -74,9 +74,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults { let mut fn_warned = false; let mut op_warned = false; let maybe_def = match expr.node { - hir::ExprCall(ref callee, _) => { + hir::ExprKind::Call(ref callee, _) => { match callee.node { - hir::ExprPath(ref qpath) => { + hir::ExprKind::Path(ref qpath) => { let def = cx.tables.qpath_def(qpath, callee.hir_id); if let Def::Fn(_) = def { Some(def) @@ -87,7 +87,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults { _ => None } }, - hir::ExprMethodCall(..) => { + hir::ExprKind::MethodCall(..) => { cx.tables.type_dependent_defs().get(expr.hir_id).cloned() }, _ => None @@ -100,23 +100,36 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults { // Hardcoding operators here seemed more expedient than the // refactoring that would be needed to look up the `#[must_use]` // attribute which does exist on the comparison trait methods - hir::ExprBinary(bin_op, ..) => { + hir::ExprKind::Binary(bin_op, ..) => { match bin_op.node { - hir::BiEq | hir::BiLt | hir::BiLe | hir::BiNe | hir::BiGe | hir::BiGt => { + hir::BinOpKind::Eq | + hir::BinOpKind::Lt | + hir::BinOpKind::Le | + hir::BinOpKind::Ne | + hir::BinOpKind::Ge | + hir::BinOpKind::Gt => { Some("comparison") }, - hir::BiAdd | hir::BiSub | hir::BiDiv | hir::BiMul | hir::BiRem => { + hir::BinOpKind::Add | + hir::BinOpKind::Sub | + hir::BinOpKind::Div | + hir::BinOpKind::Mul | + hir::BinOpKind::Rem => { Some("arithmetic operation") }, - hir::BiAnd | hir::BiOr => { + hir::BinOpKind::And | hir::BinOpKind::Or => { Some("logical operation") }, - hir::BiBitXor | hir::BiBitAnd | hir::BiBitOr | hir::BiShl | hir::BiShr => { + hir::BinOpKind::BitXor | + hir::BinOpKind::BitAnd | + hir::BinOpKind::BitOr | + hir::BinOpKind::Shl | + hir::BinOpKind::Shr => { Some("bitwise operation") }, } }, - hir::ExprUnary(..) => Some("unary operation"), + hir::ExprKind::Unary(..) => Some("unary operation"), _ => None }; @@ -166,8 +179,8 @@ impl LintPass for PathStatements { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PathStatements { fn check_stmt(&mut self, cx: &LateContext, s: &hir::Stmt) { - if let hir::StmtSemi(ref expr, _) = s.node { - if let hir::ExprPath(_) = expr.node { + if let hir::StmtKind::Semi(ref expr, _) = s.node { + if let hir::ExprKind::Path(_) = expr.node { cx.span_lint(PATH_STATEMENTS, s.span, "path statement with no effect"); } } @@ -447,7 +460,7 @@ impl LintPass for UnusedAllocation { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedAllocation { fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) { match e.node { - hir::ExprBox(_) => {} + hir::ExprKind::Box(_) => {} _ => return, } diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index 72f91dcea60..b9cb97ed7d0 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -1039,16 +1039,16 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { debug!("IsolatedEncoder::encode_info_for_item({:?})", def_id); let kind = match item.node { - hir::ItemStatic(_, hir::MutMutable, _) => EntryKind::MutStatic, - hir::ItemStatic(_, hir::MutImmutable, _) => EntryKind::ImmStatic, - hir::ItemConst(_, body_id) => { + hir::ItemKind::Static(_, hir::MutMutable, _) => EntryKind::MutStatic, + hir::ItemKind::Static(_, hir::MutImmutable, _) => EntryKind::ImmStatic, + hir::ItemKind::Const(_, body_id) => { let mir = tcx.at(item.span).mir_const_qualif(def_id).0; EntryKind::Const( self.const_qualif(mir, body_id), self.encode_rendered_const_for_body(body_id) ) } - hir::ItemFn(_, header, .., body) => { + hir::ItemKind::Fn(_, header, .., body) => { let data = FnData { constness: header.constness, arg_names: self.encode_fn_arg_names_for_body(body), @@ -1057,15 +1057,15 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { EntryKind::Fn(self.lazy(&data)) } - hir::ItemMod(ref m) => { + hir::ItemKind::Mod(ref m) => { return self.encode_info_for_mod(FromId(item.id, (m, &item.attrs, &item.vis))); } - hir::ItemForeignMod(_) => EntryKind::ForeignMod, - hir::ItemGlobalAsm(..) => EntryKind::GlobalAsm, - hir::ItemTy(..) => EntryKind::Type, - hir::ItemExistential(..) => EntryKind::Existential, - hir::ItemEnum(..) => EntryKind::Enum(get_repr_options(&tcx, def_id)), - hir::ItemStruct(ref struct_def, _) => { + hir::ItemKind::ForeignMod(_) => EntryKind::ForeignMod, + hir::ItemKind::GlobalAsm(..) => EntryKind::GlobalAsm, + hir::ItemKind::Ty(..) => EntryKind::Type, + hir::ItemKind::Existential(..) => EntryKind::Existential, + hir::ItemKind::Enum(..) => EntryKind::Enum(get_repr_options(&tcx, def_id)), + hir::ItemKind::Struct(ref struct_def, _) => { let variant = tcx.adt_def(def_id).non_enum_variant(); // Encode def_ids for each field and method @@ -1086,7 +1086,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { ctor_sig: None, }), repr_options) } - hir::ItemUnion(..) => { + hir::ItemKind::Union(..) => { let variant = tcx.adt_def(def_id).non_enum_variant(); let repr_options = get_repr_options(&tcx, def_id); @@ -1097,7 +1097,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { ctor_sig: None, }), repr_options) } - hir::ItemImpl(_, polarity, defaultness, ..) => { + hir::ItemKind::Impl(_, polarity, defaultness, ..) => { let trait_ref = tcx.impl_trait_ref(def_id); let parent = if let Some(trait_ref) = trait_ref { let trait_def = tcx.trait_def(trait_ref.def_id); @@ -1132,7 +1132,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { EntryKind::Impl(self.lazy(&data)) } - hir::ItemTrait(..) => { + hir::ItemKind::Trait(..) => { let trait_def = tcx.trait_def(def_id); let data = TraitData { unsafety: trait_def.unsafety, @@ -1143,9 +1143,9 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { EntryKind::Trait(self.lazy(&data)) } - hir::ItemExternCrate(_) | - hir::ItemTraitAlias(..) | - hir::ItemUse(..) => bug!("cannot encode info for item {:?}", item), + hir::ItemKind::ExternCrate(_) | + hir::ItemKind::TraitAlias(..) | + hir::ItemKind::Use(..) => bug!("cannot encode info for item {:?}", item), }; Entry { @@ -1154,28 +1154,28 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { span: self.lazy(&item.span), attributes: self.encode_attributes(&item.attrs), children: match item.node { - hir::ItemForeignMod(ref fm) => { + hir::ItemKind::ForeignMod(ref fm) => { self.lazy_seq(fm.items .iter() .map(|foreign_item| tcx.hir.local_def_id(foreign_item.id).index)) } - hir::ItemEnum(..) => { + hir::ItemKind::Enum(..) => { let def = self.tcx.adt_def(def_id); self.lazy_seq(def.variants.iter().map(|v| { assert!(v.did.is_local()); v.did.index })) } - hir::ItemStruct(..) | - hir::ItemUnion(..) => { + hir::ItemKind::Struct(..) | + hir::ItemKind::Union(..) => { let def = self.tcx.adt_def(def_id); self.lazy_seq(def.non_enum_variant().fields.iter().map(|f| { assert!(f.did.is_local()); f.did.index })) } - hir::ItemImpl(..) | - hir::ItemTrait(..) => { + hir::ItemKind::Impl(..) | + hir::ItemKind::Trait(..) => { self.lazy_seq(tcx.associated_item_def_ids(def_id).iter().map(|&def_id| { assert!(def_id.is_local()); def_id.index @@ -1187,49 +1187,49 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { deprecation: self.encode_deprecation(def_id), ty: match item.node { - hir::ItemStatic(..) | - hir::ItemConst(..) | - hir::ItemFn(..) | - hir::ItemTy(..) | - hir::ItemExistential(..) | - hir::ItemEnum(..) | - hir::ItemStruct(..) | - hir::ItemUnion(..) | - hir::ItemImpl(..) => Some(self.encode_item_type(def_id)), + hir::ItemKind::Static(..) | + hir::ItemKind::Const(..) | + hir::ItemKind::Fn(..) | + hir::ItemKind::Ty(..) | + hir::ItemKind::Existential(..) | + hir::ItemKind::Enum(..) | + hir::ItemKind::Struct(..) | + hir::ItemKind::Union(..) | + hir::ItemKind::Impl(..) => Some(self.encode_item_type(def_id)), _ => None, }, inherent_impls: self.encode_inherent_implementations(def_id), variances: match item.node { - hir::ItemEnum(..) | - hir::ItemStruct(..) | - hir::ItemUnion(..) | - hir::ItemFn(..) => self.encode_variances_of(def_id), + hir::ItemKind::Enum(..) | + hir::ItemKind::Struct(..) | + hir::ItemKind::Union(..) | + hir::ItemKind::Fn(..) => self.encode_variances_of(def_id), _ => LazySeq::empty(), }, generics: match item.node { - hir::ItemStatic(..) | - hir::ItemConst(..) | - hir::ItemFn(..) | - hir::ItemTy(..) | - hir::ItemEnum(..) | - hir::ItemStruct(..) | - hir::ItemUnion(..) | - hir::ItemImpl(..) | - hir::ItemExistential(..) | - hir::ItemTrait(..) => Some(self.encode_generics(def_id)), + hir::ItemKind::Static(..) | + hir::ItemKind::Const(..) | + hir::ItemKind::Fn(..) | + hir::ItemKind::Ty(..) | + hir::ItemKind::Enum(..) | + hir::ItemKind::Struct(..) | + hir::ItemKind::Union(..) | + hir::ItemKind::Impl(..) | + hir::ItemKind::Existential(..) | + hir::ItemKind::Trait(..) => Some(self.encode_generics(def_id)), _ => None, }, predicates: match item.node { - hir::ItemStatic(..) | - hir::ItemConst(..) | - hir::ItemFn(..) | - hir::ItemTy(..) | - hir::ItemEnum(..) | - hir::ItemStruct(..) | - hir::ItemUnion(..) | - hir::ItemImpl(..) | - hir::ItemExistential(..) | - hir::ItemTrait(..) => Some(self.encode_predicates(def_id)), + hir::ItemKind::Static(..) | + hir::ItemKind::Const(..) | + hir::ItemKind::Fn(..) | + hir::ItemKind::Ty(..) | + hir::ItemKind::Enum(..) | + hir::ItemKind::Struct(..) | + hir::ItemKind::Union(..) | + hir::ItemKind::Impl(..) | + hir::ItemKind::Existential(..) | + hir::ItemKind::Trait(..) => Some(self.encode_predicates(def_id)), _ => None, }, @@ -1239,16 +1239,16 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { // hack. (No reason not to expand it in the future if // necessary.) predicates_defined_on: match item.node { - hir::ItemTrait(..) => Some(self.encode_predicates_defined_on(def_id)), + hir::ItemKind::Trait(..) => Some(self.encode_predicates_defined_on(def_id)), _ => None, // not *wrong* for other kinds of items, but not needed }, mir: match item.node { - hir::ItemStatic(..) => { + hir::ItemKind::Static(..) => { self.encode_optimized_mir(def_id) } - hir::ItemConst(..) => self.encode_optimized_mir(def_id), - hir::ItemFn(_, header, ..) => { + hir::ItemKind::Const(..) => self.encode_optimized_mir(def_id), + hir::ItemKind::Fn(_, header, ..) => { let generics = tcx.generics_of(def_id); let has_types = generics.params.iter().any(|param| match param.kind { ty::GenericParamDefKind::Type { .. } => true, @@ -1561,7 +1561,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { debug!("IsolatedEncoder::encode_info_for_foreign_item({:?})", def_id); let kind = match nitem.node { - hir::ForeignItemFn(_, ref names, _) => { + hir::ForeignItemKind::Fn(_, ref names, _) => { let data = FnData { constness: hir::Constness::NotConst, arg_names: self.encode_fn_arg_names(names), @@ -1569,9 +1569,9 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { }; EntryKind::ForeignFn(self.lazy(&data)) } - hir::ForeignItemStatic(_, true) => EntryKind::ForeignMutStatic, - hir::ForeignItemStatic(_, false) => EntryKind::ForeignImmStatic, - hir::ForeignItemType => EntryKind::ForeignType, + hir::ForeignItemKind::Static(_, true) => EntryKind::ForeignMutStatic, + hir::ForeignItemKind::Static(_, false) => EntryKind::ForeignImmStatic, + hir::ForeignItemKind::Type => EntryKind::ForeignType, }; Entry { @@ -1586,7 +1586,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { ty: Some(self.encode_item_type(def_id)), inherent_impls: LazySeq::empty(), variances: match nitem.node { - hir::ForeignItemFn(..) => self.encode_variances_of(def_id), + hir::ForeignItemKind::Fn(..) => self.encode_variances_of(def_id), _ => LazySeq::empty(), }, generics: Some(self.encode_generics(def_id)), @@ -1614,8 +1614,8 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for EncodeVisitor<'a, 'b, 'tcx> { intravisit::walk_item(self, item); let def_id = self.index.tcx.hir.local_def_id(item.id); match item.node { - hir::ItemExternCrate(_) | - hir::ItemUse(..) => (), // ignore these + hir::ItemKind::ExternCrate(_) | + hir::ItemKind::Use(..) => (), // ignore these _ => self.index.record(def_id, IsolatedEncoder::encode_info_for_item, (def_id, item)), } self.index.encode_addl_info_for_item(item); @@ -1678,7 +1678,7 @@ impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> { fn encode_info_for_ty(&mut self, ty: &hir::Ty) { match ty.node { - hir::TyArray(_, ref length) => { + hir::TyKind::Array(_, ref length) => { let def_id = self.tcx.hir.local_def_id(length.id); self.record(def_id, IsolatedEncoder::encode_info_for_anon_const, def_id); } @@ -1688,7 +1688,7 @@ impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> { fn encode_info_for_expr(&mut self, expr: &hir::Expr) { match expr.node { - hir::ExprClosure(..) => { + hir::ExprKind::Closure(..) => { let def_id = self.tcx.hir.local_def_id(expr.id); self.record(def_id, IsolatedEncoder::encode_info_for_closure, def_id); } @@ -1703,20 +1703,20 @@ impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> { fn encode_addl_info_for_item(&mut self, item: &hir::Item) { let def_id = self.tcx.hir.local_def_id(item.id); match item.node { - hir::ItemStatic(..) | - hir::ItemConst(..) | - hir::ItemFn(..) | - hir::ItemMod(..) | - hir::ItemForeignMod(..) | - hir::ItemGlobalAsm(..) | - hir::ItemExternCrate(..) | - hir::ItemUse(..) | - hir::ItemTy(..) | - hir::ItemExistential(..) | - hir::ItemTraitAlias(..) => { + hir::ItemKind::Static(..) | + hir::ItemKind::Const(..) | + hir::ItemKind::Fn(..) | + hir::ItemKind::Mod(..) | + hir::ItemKind::ForeignMod(..) | + hir::ItemKind::GlobalAsm(..) | + hir::ItemKind::ExternCrate(..) | + hir::ItemKind::Use(..) | + hir::ItemKind::Ty(..) | + hir::ItemKind::Existential(..) | + hir::ItemKind::TraitAlias(..) => { // no sub-item recording needed in these cases } - hir::ItemEnum(..) => { + hir::ItemKind::Enum(..) => { self.encode_fields(def_id); let def = self.tcx.adt_def(def_id); @@ -1726,7 +1726,7 @@ impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> { (def_id, Untracked(i))); } } - hir::ItemStruct(ref struct_def, _) => { + hir::ItemKind::Struct(ref struct_def, _) => { self.encode_fields(def_id); // If the struct has a constructor, encode it. @@ -1737,17 +1737,17 @@ impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> { (def_id, ctor_def_id)); } } - hir::ItemUnion(..) => { + hir::ItemKind::Union(..) => { self.encode_fields(def_id); } - hir::ItemImpl(..) => { + hir::ItemKind::Impl(..) => { for &trait_item_def_id in self.tcx.associated_item_def_ids(def_id).iter() { self.record(trait_item_def_id, IsolatedEncoder::encode_info_for_impl_item, trait_item_def_id); } } - hir::ItemTrait(..) => { + hir::ItemKind::Trait(..) => { for &item_def_id in self.tcx.associated_item_def_ids(def_id).iter() { self.record(item_def_id, IsolatedEncoder::encode_info_for_trait_item, @@ -1765,7 +1765,7 @@ struct ImplVisitor<'a, 'tcx: 'a> { impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for ImplVisitor<'a, 'tcx> { fn visit_item(&mut self, item: &hir::Item) { - if let hir::ItemImpl(..) = item.node { + if let hir::ItemKind::Impl(..) = item.node { let impl_id = self.tcx.hir.local_def_id(item.id); if let Some(trait_ref) = self.tcx.impl_trait_ref(impl_id) { self.impls diff --git a/src/librustc_metadata/foreign_modules.rs b/src/librustc_metadata/foreign_modules.rs index c44d891b7f3..e96d56fb388 100644 --- a/src/librustc_metadata/foreign_modules.rs +++ b/src/librustc_metadata/foreign_modules.rs @@ -30,7 +30,7 @@ struct Collector<'a, 'tcx: 'a> { impl<'a, 'tcx> ItemLikeVisitor<'tcx> for Collector<'a, 'tcx> { fn visit_item(&mut self, it: &'tcx hir::Item) { let fm = match it.node { - hir::ItemForeignMod(ref fm) => fm, + hir::ItemKind::ForeignMod(ref fm) => fm, _ => return, }; diff --git a/src/librustc_metadata/link_args.rs b/src/librustc_metadata/link_args.rs index b699885b0eb..008e1e363ff 100644 --- a/src/librustc_metadata/link_args.rs +++ b/src/librustc_metadata/link_args.rs @@ -37,7 +37,7 @@ struct Collector { impl<'tcx> ItemLikeVisitor<'tcx> for Collector { fn visit_item(&mut self, it: &'tcx hir::Item) { let fm = match it.node { - hir::ItemForeignMod(ref fm) => fm, + hir::ItemKind::ForeignMod(ref fm) => fm, _ => return, }; if fm.abi == Abi::Rust || diff --git a/src/librustc_metadata/native_libs.rs b/src/librustc_metadata/native_libs.rs index 70b8c7b11fd..327b2abc4d3 100644 --- a/src/librustc_metadata/native_libs.rs +++ b/src/librustc_metadata/native_libs.rs @@ -45,7 +45,7 @@ struct Collector<'a, 'tcx: 'a> { impl<'a, 'tcx> ItemLikeVisitor<'tcx> for Collector<'a, 'tcx> { fn visit_item(&mut self, it: &'tcx hir::Item) { let fm = match it.node { - hir::ItemForeignMod(ref fm) => fm, + hir::ItemKind::ForeignMod(ref fm) => fm, _ => return, }; diff --git a/src/librustc_mir/borrow_check/error_reporting.rs b/src/librustc_mir/borrow_check/error_reporting.rs index f903dbd97a8..c481d1d325b 100644 --- a/src/librustc_mir/borrow_check/error_reporting.rs +++ b/src/librustc_mir/borrow_check/error_reporting.rs @@ -207,7 +207,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { maybe_closure_span: Span, location: Location, ) -> Option<(Span, Span)> { - use rustc::hir::ExprClosure; + use rustc::hir::ExprKind::Closure; use rustc::mir::AggregateKind; let local = match self.mir[location.block] @@ -231,7 +231,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { debug!("find_closure_span: found closure {:?}", places); return if let Some(node_id) = self.tcx.hir.as_local_node_id(def_id) { - let args_span = if let ExprClosure(_, _, _, span, _) = + let args_span = if let Closure(_, _, _, span, _) = self.tcx.hir.expect_expr(node_id).node { span diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 03eaee362c7..e7f00b577b3 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -232,7 +232,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>( let movable_generator = match tcx.hir.get(id) { hir::map::Node::NodeExpr(&hir::Expr { - node: hir::ExprClosure(.., Some(hir::GeneratorMovability::Static)), + node: hir::ExprKind::Closure(.., Some(hir::GeneratorMovability::Static)), .. }) => false, _ => true, diff --git a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs index 16dec2725ff..fc0e64d0a8a 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs @@ -201,7 +201,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { // This indicates a variable with no type annotation, like // `|x|`... in that case, we can't highlight the type but // must highlight the variable. - hir::TyInfer => None, + hir::TyKind::Infer => None, _ => self.give_name_if_we_can_match_hir_ty( tcx, @@ -263,7 +263,10 @@ impl<'tcx> RegionInferenceContext<'tcx> { // // & // - let's call the lifetime of this reference `'1` - (ty::TyRef(region, referent_ty, _), hir::TyRptr(_lifetime, referent_hir_ty)) => { + ( + ty::TyRef(region, referent_ty, _), + hir::TyKind::Rptr(_lifetime, referent_hir_ty), + ) => { if region.to_region_vid() == needle_fr { let region_name = self.synthesize_region_name(counter); @@ -287,7 +290,10 @@ impl<'tcx> RegionInferenceContext<'tcx> { } // Match up something like `Foo<'1>` - (ty::TyAdt(_adt_def, substs), hir::TyPath(hir::QPath::Resolved(None, path))) => { + ( + ty::TyAdt(_adt_def, substs), + hir::TyKind::Path(hir::QPath::Resolved(None, path)), + ) => { if let Some(last_segment) = path.segments.last() { if let Some(name) = self.match_adt_and_segment( substs, @@ -305,16 +311,16 @@ impl<'tcx> RegionInferenceContext<'tcx> { // The following cases don't have lifetimes, so we // just worry about trying to match up the rustc type // with the HIR types: - (ty::TyTuple(elem_tys), hir::TyTup(elem_hir_tys)) => { + (ty::TyTuple(elem_tys), hir::TyKind::Tup(elem_hir_tys)) => { search_stack.extend(elem_tys.iter().cloned().zip(elem_hir_tys)); } - (ty::TySlice(elem_ty), hir::TySlice(elem_hir_ty)) - | (ty::TyArray(elem_ty, _), hir::TyArray(elem_hir_ty, _)) => { + (ty::TySlice(elem_ty), hir::TyKind::Slice(elem_hir_ty)) + | (ty::TyArray(elem_ty, _), hir::TyKind::Array(elem_hir_ty, _)) => { search_stack.push((elem_ty, elem_hir_ty)); } - (ty::TyRawPtr(mut_ty), hir::TyPtr(mut_hir_ty)) => { + (ty::TyRawPtr(mut_ty), hir::TyKind::Ptr(mut_hir_ty)) => { search_stack.push((mut_ty.ty, &mut_hir_ty.ty)); } diff --git a/src/librustc_mir/hair/cx/block.rs b/src/librustc_mir/hair/cx/block.rs index 5ef1eef133d..6c8b5d97b6f 100644 --- a/src/librustc_mir/hair/cx/block.rs +++ b/src/librustc_mir/hair/cx/block.rs @@ -55,8 +55,8 @@ fn mirror_stmts<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, let hir_id = cx.tcx.hir.node_to_hir_id(stmt.node.id()); let opt_dxn_ext = cx.region_scope_tree.opt_destruction_scope(hir_id.local_id); match stmt.node { - hir::StmtExpr(ref expr, _) | - hir::StmtSemi(ref expr, _) => { + hir::StmtKind::Expr(ref expr, _) | + hir::StmtKind::Semi(ref expr, _) => { result.push(StmtRef::Mirror(Box::new(Stmt { kind: StmtKind::Expr { scope: region::Scope::Node(hir_id.local_id), @@ -65,12 +65,12 @@ fn mirror_stmts<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, opt_destruction_scope: opt_dxn_ext, }))) } - hir::StmtDecl(ref decl, _) => { + hir::StmtKind::Decl(ref decl, _) => { match decl.node { - hir::DeclItem(..) => { + hir::DeclKind::Item(..) => { // ignore for purposes of the MIR } - hir::DeclLocal(ref local) => { + hir::DeclKind::Local(ref local) => { let remainder_scope = region::Scope::Remainder(BlockRemainder { block: block_id, first_statement_index: region::FirstStatementIndex::new(index), diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs index 8c73771e57b..13b2a0ab874 100644 --- a/src/librustc_mir/hair/cx/expr.rs +++ b/src/librustc_mir/hair/cx/expr.rs @@ -200,7 +200,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, let kind = match expr.node { // Here comes the interesting stuff: - hir::ExprMethodCall(.., ref args) => { + hir::ExprKind::MethodCall(.., ref args) => { // Rewrite a.b(c) into UFCS form like Trait::b(a, c) let expr = method_callee(cx, expr, None); let args = args.iter() @@ -213,7 +213,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, } } - hir::ExprCall(ref fun, ref args) => { + hir::ExprKind::Call(ref fun, ref args) => { if cx.tables().is_method_call(expr) { // The callee is something implementing Fn, FnMut, or FnOnce. // Find the actual method implementation being called and @@ -238,8 +238,10 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, args: vec![fun.to_ref(), tupled_args.to_ref()], } } else { - let adt_data = if let hir::ExprPath(hir::QPath::Resolved(_, ref path)) = fun.node { - // Tuple-like ADTs are represented as ExprCall. We convert them here. + let adt_data = if let hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) = + fun.node + { + // Tuple-like ADTs are represented as ExprKind::Call. We convert them here. expr_ty.ty_adt_def().and_then(|adt_def| { match path.def { Def::VariantCtor(variant_id, CtorKind::Fn) => { @@ -280,7 +282,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, } } - hir::ExprAddrOf(mutbl, ref expr) => { + hir::ExprKind::AddrOf(mutbl, ref expr) => { let region = match expr_ty.sty { ty::TyRef(r, _, _) => r, _ => span_bug!(expr.span, "type of & not region"), @@ -292,16 +294,16 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, } } - hir::ExprBlock(ref blk, _) => ExprKind::Block { body: &blk }, + hir::ExprKind::Block(ref blk, _) => ExprKind::Block { body: &blk }, - hir::ExprAssign(ref lhs, ref rhs) => { + hir::ExprKind::Assign(ref lhs, ref rhs) => { ExprKind::Assign { lhs: lhs.to_ref(), rhs: rhs.to_ref(), } } - hir::ExprAssignOp(op, ref lhs, ref rhs) => { + hir::ExprKind::AssignOp(op, ref lhs, ref rhs) => { if cx.tables().is_method_call(expr) { overloaded_operator(cx, expr, vec![lhs.to_ref(), rhs.to_ref()]) } else { @@ -313,11 +315,11 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, } } - hir::ExprLit(ref lit) => ExprKind::Literal { + hir::ExprKind::Lit(ref lit) => ExprKind::Literal { literal: cx.const_eval_literal(&lit.node, expr_ty, lit.span, false), }, - hir::ExprBinary(op, ref lhs, ref rhs) => { + hir::ExprKind::Binary(op, ref lhs, ref rhs) => { if cx.tables().is_method_call(expr) { overloaded_operator(cx, expr, vec![lhs.to_ref(), rhs.to_ref()]) } else { @@ -325,14 +327,14 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, match (op.node, cx.constness) { // FIXME(eddyb) use logical ops in constants when // they can handle that kind of control-flow. - (hir::BinOp_::BiAnd, hir::Constness::Const) => { + (hir::BinOpKind::And, hir::Constness::Const) => { ExprKind::Binary { op: BinOp::BitAnd, lhs: lhs.to_ref(), rhs: rhs.to_ref(), } } - (hir::BinOp_::BiOr, hir::Constness::Const) => { + (hir::BinOpKind::Or, hir::Constness::Const) => { ExprKind::Binary { op: BinOp::BitOr, lhs: lhs.to_ref(), @@ -340,14 +342,14 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, } } - (hir::BinOp_::BiAnd, hir::Constness::NotConst) => { + (hir::BinOpKind::And, hir::Constness::NotConst) => { ExprKind::LogicalOp { op: LogicalOp::And, lhs: lhs.to_ref(), rhs: rhs.to_ref(), } } - (hir::BinOp_::BiOr, hir::Constness::NotConst) => { + (hir::BinOpKind::Or, hir::Constness::NotConst) => { ExprKind::LogicalOp { op: LogicalOp::Or, lhs: lhs.to_ref(), @@ -367,7 +369,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, } } - hir::ExprIndex(ref lhs, ref index) => { + hir::ExprKind::Index(ref lhs, ref index) => { if cx.tables().is_method_call(expr) { overloaded_place(cx, expr, expr_ty, None, vec![lhs.to_ref(), index.to_ref()]) } else { @@ -378,7 +380,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, } } - hir::ExprUnary(hir::UnOp::UnDeref, ref arg) => { + hir::ExprKind::Unary(hir::UnOp::UnDeref, ref arg) => { if cx.tables().is_method_call(expr) { overloaded_place(cx, expr, expr_ty, None, vec![arg.to_ref()]) } else { @@ -386,7 +388,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, } } - hir::ExprUnary(hir::UnOp::UnNot, ref arg) => { + hir::ExprKind::Unary(hir::UnOp::UnNot, ref arg) => { if cx.tables().is_method_call(expr) { overloaded_operator(cx, expr, vec![arg.to_ref()]) } else { @@ -397,11 +399,11 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, } } - hir::ExprUnary(hir::UnOp::UnNeg, ref arg) => { + hir::ExprKind::Unary(hir::UnOp::UnNeg, ref arg) => { if cx.tables().is_method_call(expr) { overloaded_operator(cx, expr, vec![arg.to_ref()]) } else { - if let hir::ExprLit(ref lit) = arg.node { + if let hir::ExprKind::Lit(ref lit) = arg.node { ExprKind::Literal { literal: cx.const_eval_literal(&lit.node, expr_ty, lit.span, true), } @@ -414,7 +416,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, } } - hir::ExprStruct(ref qpath, ref fields, ref base) => { + hir::ExprKind::Struct(ref qpath, ref fields, ref base) => { match expr_ty.sty { ty::TyAdt(adt, substs) => { match adt.adt_kind() { @@ -467,7 +469,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, } } - hir::ExprClosure(..) => { + hir::ExprKind::Closure(..) => { let closure_ty = cx.tables().expr_ty(expr); let (def_id, substs, movability) = match closure_ty.sty { ty::TyClosure(def_id, substs) => (def_id, UpvarSubsts::Closure(substs), None), @@ -492,12 +494,12 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, } } - hir::ExprPath(ref qpath) => { + hir::ExprKind::Path(ref qpath) => { let def = cx.tables().qpath_def(qpath, expr.hir_id); convert_path_expr(cx, expr, def) } - hir::ExprInlineAsm(ref asm, ref outputs, ref inputs) => { + hir::ExprKind::InlineAsm(ref asm, ref outputs, ref inputs) => { ExprKind::InlineAsm { asm, outputs: outputs.to_ref(), @@ -506,7 +508,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, } // Now comes the rote stuff: - hir::ExprRepeat(ref v, ref count) => { + hir::ExprKind::Repeat(ref v, ref count) => { let def_id = cx.tcx.hir.local_def_id(count.id); let substs = Substs::identity_for_item(cx.tcx.global_tcx(), def_id); let instance = ty::Instance::resolve( @@ -533,8 +535,8 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, count, } } - hir::ExprRet(ref v) => ExprKind::Return { value: v.to_ref() }, - hir::ExprBreak(dest, ref value) => { + hir::ExprKind::Ret(ref v) => ExprKind::Return { value: v.to_ref() }, + hir::ExprKind::Break(dest, ref value) => { match dest.target_id { Ok(target_id) => ExprKind::Break { label: region::Scope::Node(cx.tcx.hir.node_to_hir_id(target_id).local_id), @@ -543,7 +545,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, Err(err) => bug!("invalid loop id for break: {}", err) } } - hir::ExprContinue(dest) => { + hir::ExprKind::Continue(dest) => { match dest.target_id { Ok(loop_id) => ExprKind::Continue { label: region::Scope::Node(cx.tcx.hir.node_to_hir_id(loop_id).local_id), @@ -551,38 +553,38 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, Err(err) => bug!("invalid loop id for continue: {}", err) } } - hir::ExprMatch(ref discr, ref arms, _) => { + hir::ExprKind::Match(ref discr, ref arms, _) => { ExprKind::Match { discriminant: discr.to_ref(), arms: arms.iter().map(|a| convert_arm(cx, a)).collect(), } } - hir::ExprIf(ref cond, ref then, ref otherwise) => { + hir::ExprKind::If(ref cond, ref then, ref otherwise) => { ExprKind::If { condition: cond.to_ref(), then: then.to_ref(), otherwise: otherwise.to_ref(), } } - hir::ExprWhile(ref cond, ref body, _) => { + hir::ExprKind::While(ref cond, ref body, _) => { ExprKind::Loop { condition: Some(cond.to_ref()), body: block::to_expr_ref(cx, body), } } - hir::ExprLoop(ref body, _, _) => { + hir::ExprKind::Loop(ref body, _, _) => { ExprKind::Loop { condition: None, body: block::to_expr_ref(cx, body), } } - hir::ExprField(ref source, ..) => { + hir::ExprKind::Field(ref source, ..) => { ExprKind::Field { lhs: source.to_ref(), name: Field::new(cx.tcx.field_index(expr.id, cx.tables)), } } - hir::ExprCast(ref source, _) => { + hir::ExprKind::Cast(ref source, _) => { // Check to see if this cast is a "coercion cast", where the cast is actually done // using a coercion (or is a no-op). if let Some(&TyCastKind::CoercionCast) = cx.tables() @@ -602,7 +604,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, // } // The correct solution would be to add symbolic computations to miri, // so we wouldn't have to compute and store the actual value - let var = if let hir::ExprPath(ref qpath) = source.node { + let var = if let hir::ExprKind::Path(ref qpath) = source.node { let def = cx.tables().qpath_def(qpath, source.hir_id); cx .tables() @@ -666,16 +668,16 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, ExprKind::Cast { source } } } - hir::ExprType(ref source, _) => return source.make_mirror(cx), - hir::ExprBox(ref value) => { + hir::ExprKind::Type(ref source, _) => return source.make_mirror(cx), + hir::ExprKind::Box(ref value) => { ExprKind::Box { value: value.to_ref(), } } - hir::ExprArray(ref fields) => ExprKind::Array { fields: fields.to_ref() }, - hir::ExprTup(ref fields) => ExprKind::Tuple { fields: fields.to_ref() }, + hir::ExprKind::Array(ref fields) => ExprKind::Array { fields: fields.to_ref() }, + hir::ExprKind::Tup(ref fields) => ExprKind::Tuple { fields: fields.to_ref() }, - hir::ExprYield(ref v) => ExprKind::Yield { value: v.to_ref() }, + hir::ExprKind::Yield(ref v) => ExprKind::Yield { value: v.to_ref() }, }; Expr { @@ -930,24 +932,24 @@ fn convert_var<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, } -fn bin_op(op: hir::BinOp_) -> BinOp { +fn bin_op(op: hir::BinOpKind) -> BinOp { match op { - hir::BinOp_::BiAdd => BinOp::Add, - hir::BinOp_::BiSub => BinOp::Sub, - hir::BinOp_::BiMul => BinOp::Mul, - hir::BinOp_::BiDiv => BinOp::Div, - hir::BinOp_::BiRem => BinOp::Rem, - hir::BinOp_::BiBitXor => BinOp::BitXor, - hir::BinOp_::BiBitAnd => BinOp::BitAnd, - hir::BinOp_::BiBitOr => BinOp::BitOr, - hir::BinOp_::BiShl => BinOp::Shl, - hir::BinOp_::BiShr => BinOp::Shr, - hir::BinOp_::BiEq => BinOp::Eq, - hir::BinOp_::BiLt => BinOp::Lt, - hir::BinOp_::BiLe => BinOp::Le, - hir::BinOp_::BiNe => BinOp::Ne, - hir::BinOp_::BiGe => BinOp::Ge, - hir::BinOp_::BiGt => BinOp::Gt, + hir::BinOpKind::Add => BinOp::Add, + hir::BinOpKind::Sub => BinOp::Sub, + hir::BinOpKind::Mul => BinOp::Mul, + hir::BinOpKind::Div => BinOp::Div, + hir::BinOpKind::Rem => BinOp::Rem, + hir::BinOpKind::BitXor => BinOp::BitXor, + hir::BinOpKind::BitAnd => BinOp::BitAnd, + hir::BinOpKind::BitOr => BinOp::BitOr, + hir::BinOpKind::Shl => BinOp::Shl, + hir::BinOpKind::Shr => BinOp::Shr, + hir::BinOpKind::Eq => BinOp::Eq, + hir::BinOpKind::Lt => BinOp::Lt, + hir::BinOpKind::Le => BinOp::Le, + hir::BinOpKind::Ne => BinOp::Ne, + hir::BinOpKind::Ge => BinOp::Ge, + hir::BinOpKind::Gt => BinOp::Gt, _ => bug!("no equivalent for ast binop {:?}", op), } } diff --git a/src/librustc_mir/hair/pattern/check_match.rs b/src/librustc_mir/hair/pattern/check_match.rs index 18ae7c77459..35f9dcee99f 100644 --- a/src/librustc_mir/hair/pattern/check_match.rs +++ b/src/librustc_mir/hair/pattern/check_match.rs @@ -98,7 +98,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MatchVisitor<'a, 'tcx> { intravisit::walk_expr(self, ex); match ex.node { - hir::ExprMatch(ref scrut, ref arms, source) => { + hir::ExprKind::Match(ref scrut, ref arms, source) => { self.check_match(scrut, arms, source); } _ => {} diff --git a/src/librustc_mir/hair/pattern/mod.rs b/src/librustc_mir/hair/pattern/mod.rs index 636969e2632..53511c1c127 100644 --- a/src/librustc_mir/hair/pattern/mod.rs +++ b/src/librustc_mir/hair/pattern/mod.rs @@ -733,7 +733,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { /// afterwards. fn lower_lit(&mut self, expr: &'tcx hir::Expr) -> PatternKind<'tcx> { match expr.node { - hir::ExprLit(ref lit) => { + hir::ExprKind::Lit(ref lit) => { let ty = self.tables.expr_ty(expr); match lit_to_const(&lit.node, self.tcx, ty, false) { Ok(val) => { @@ -751,11 +751,11 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { }, } }, - hir::ExprPath(ref qpath) => *self.lower_path(qpath, expr.hir_id, expr.span).kind, - hir::ExprUnary(hir::UnNeg, ref expr) => { + hir::ExprKind::Path(ref qpath) => *self.lower_path(qpath, expr.hir_id, expr.span).kind, + hir::ExprKind::Unary(hir::UnNeg, ref expr) => { let ty = self.tables.expr_ty(expr); let lit = match expr.node { - hir::ExprLit(ref lit) => lit, + hir::ExprKind::Lit(ref lit) => lit, _ => span_bug!(expr.span, "not a literal: {:?}", expr), }; match lit_to_const(&lit.node, self.tcx, ty, true) { diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index ce917b8ca55..a2d620db924 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -945,18 +945,18 @@ struct RootCollector<'b, 'a: 'b, 'tcx: 'a + 'b> { impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> { fn visit_item(&mut self, item: &'v hir::Item) { match item.node { - hir::ItemExternCrate(..) | - hir::ItemUse(..) | - hir::ItemForeignMod(..) | - hir::ItemTy(..) | - hir::ItemTrait(..) | - hir::ItemTraitAlias(..) | - hir::ItemExistential(..) | - hir::ItemMod(..) => { + hir::ItemKind::ExternCrate(..) | + hir::ItemKind::Use(..) | + hir::ItemKind::ForeignMod(..) | + hir::ItemKind::Ty(..) | + hir::ItemKind::Trait(..) | + hir::ItemKind::TraitAlias(..) | + hir::ItemKind::Existential(..) | + hir::ItemKind::Mod(..) => { // Nothing to do, just keep recursing... } - hir::ItemImpl(..) => { + hir::ItemKind::Impl(..) => { if self.mode == MonoItemCollectionMode::Eager { create_mono_items_for_default_impls(self.tcx, item, @@ -964,9 +964,9 @@ impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> { } } - hir::ItemEnum(_, ref generics) | - hir::ItemStruct(_, ref generics) | - hir::ItemUnion(_, ref generics) => { + hir::ItemKind::Enum(_, ref generics) | + hir::ItemKind::Struct(_, ref generics) | + hir::ItemKind::Union(_, ref generics) => { if generics.params.is_empty() { if self.mode == MonoItemCollectionMode::Eager { let def_id = self.tcx.hir.local_def_id(item.id); @@ -978,19 +978,19 @@ impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> { } } } - hir::ItemGlobalAsm(..) => { - debug!("RootCollector: ItemGlobalAsm({})", + hir::ItemKind::GlobalAsm(..) => { + debug!("RootCollector: ItemKind::GlobalAsm({})", def_id_to_string(self.tcx, self.tcx.hir.local_def_id(item.id))); self.output.push(MonoItem::GlobalAsm(item.id)); } - hir::ItemStatic(..) => { + hir::ItemKind::Static(..) => { let def_id = self.tcx.hir.local_def_id(item.id); - debug!("RootCollector: ItemStatic({})", + debug!("RootCollector: ItemKind::Static({})", def_id_to_string(self.tcx, def_id)); self.output.push(MonoItem::Static(def_id)); } - hir::ItemConst(..) => { + hir::ItemKind::Const(..) => { // const items only generate mono items if they are // actually used somewhere. Just declaring them is insufficient. @@ -1001,7 +1001,7 @@ impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> { self.output.push(MonoItem::CustomSection(def_id)); } } - hir::ItemFn(..) => { + hir::ItemKind::Fn(..) => { let def_id = self.tcx.hir.local_def_id(item.id); self.push_if_root(def_id); } @@ -1102,7 +1102,7 @@ fn create_mono_items_for_default_impls<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item: &'tcx hir::Item, output: &mut Vec<MonoItem<'tcx>>) { match item.node { - hir::ItemImpl(_, _, _, ref generics, .., ref impl_item_refs) => { + hir::ItemKind::Impl(_, _, _, ref generics, .., ref impl_item_refs) => { for param in &generics.params { match param.kind { hir::GenericParamKind::Lifetime { .. } => {} diff --git a/src/librustc_mir/transform/add_validation.rs b/src/librustc_mir/transform/add_validation.rs index 44f9477c2ec..9c341b38e34 100644 --- a/src/librustc_mir/transform/add_validation.rs +++ b/src/librustc_mir/transform/add_validation.rs @@ -141,7 +141,7 @@ fn fn_contains_unsafe<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, src: MirSource) -> } // Check if this is an unsafe block, or an item match node { - Node::NodeExpr(&hir::Expr { node: hir::ExprBlock(ref block, _), ..}) => { + Node::NodeExpr(&hir::Expr { node: hir::ExprKind::Block(ref block, _), ..}) => { if block_is_unsafe(&*block) { // Found an unsafe block, we can bail out here. return true; diff --git a/src/librustc_mir/transform/check_unsafety.rs b/src/librustc_mir/transform/check_unsafety.rs index 7768e96d036..b4f0a7cd6c4 100644 --- a/src/librustc_mir/transform/check_unsafety.rs +++ b/src/librustc_mir/transform/check_unsafety.rs @@ -405,7 +405,7 @@ fn is_enclosed(tcx: TyCtxt, if used_unsafe.contains(&parent_id) { Some(("block".to_string(), parent_id)) } else if let Some(hir::map::NodeItem(&hir::Item { - node: hir::ItemFn(_, header, _, _), + node: hir::ItemKind::Fn(_, header, _, _), .. })) = tcx.hir.find(parent_id) { match header.unsafety { diff --git a/src/librustc_passes/loops.rs b/src/librustc_passes/loops.rs index eff0dbe1235..8ef20126e03 100644 --- a/src/librustc_passes/loops.rs +++ b/src/librustc_passes/loops.rs @@ -78,23 +78,23 @@ impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> { fn visit_expr(&mut self, e: &'hir hir::Expr) { match e.node { - hir::ExprWhile(ref e, ref b, _) => { + hir::ExprKind::While(ref e, ref b, _) => { self.with_context(Loop(LoopKind::WhileLoop), |v| { v.visit_expr(&e); v.visit_block(&b); }); } - hir::ExprLoop(ref b, _, source) => { + hir::ExprKind::Loop(ref b, _, source) => { self.with_context(Loop(LoopKind::Loop(source)), |v| v.visit_block(&b)); } - hir::ExprClosure(_, ref function_decl, b, _, _) => { + hir::ExprKind::Closure(_, ref function_decl, b, _, _) => { self.visit_fn_decl(&function_decl); self.with_context(Closure, |v| v.visit_nested_body(b)); } - hir::ExprBlock(ref b, Some(_label)) => { + hir::ExprKind::Block(ref b, Some(_label)) => { self.with_context(LabeledBlock, |v| v.visit_block(&b)); } - hir::ExprBreak(label, ref opt_expr) => { + hir::ExprKind::Break(label, ref opt_expr) => { opt_expr.as_ref().map(|e| self.visit_expr(e)); if self.require_label_in_labeled_block(e.span, &label, "break") { @@ -125,8 +125,8 @@ impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> { None } else { Some(match self.hir_map.expect_expr(loop_id).node { - hir::ExprWhile(..) => LoopKind::WhileLoop, - hir::ExprLoop(_, _, source) => LoopKind::Loop(source), + hir::ExprKind::While(..) => LoopKind::WhileLoop, + hir::ExprKind::Loop(_, _, source) => LoopKind::Loop(source), ref r => span_bug!(e.span, "break label resolved to a non-loop: {:?}", r), }) @@ -153,7 +153,7 @@ impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> { self.require_break_cx("break", e.span); } - hir::ExprContinue(label) => { + hir::ExprKind::Continue(label) => { self.require_label_in_labeled_block(e.span, &label, "continue"); match label.target_id { diff --git a/src/librustc_passes/rvalue_promotion.rs b/src/librustc_passes/rvalue_promotion.rs index 6fbe4e0f240..d223dc2a353 100644 --- a/src/librustc_passes/rvalue_promotion.rs +++ b/src/librustc_passes/rvalue_promotion.rs @@ -261,9 +261,9 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> { fn check_stmt(&mut self, stmt: &'tcx hir::Stmt) -> Promotability { match stmt.node { - hir::StmtDecl(ref decl, _node_id) => { + hir::StmtKind::Decl(ref decl, _node_id) => { match &decl.node { - hir::DeclLocal(local) => { + hir::DeclKind::Local(local) => { if self.remove_mut_rvalue_borrow(&local.pat) { if let Some(init) = &local.init { self.mut_rvalue_borrows.insert(init.id); @@ -277,11 +277,11 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> { NotPromotable } // Item statements are allowed - hir::DeclItem(_) => Promotable + hir::DeclKind::Item(_) => Promotable } } - hir::StmtExpr(ref box_expr, _node_id) | - hir::StmtSemi(ref box_expr, _node_id) => { + hir::StmtKind::Expr(ref box_expr, _node_id) | + hir::StmtKind::Semi(ref box_expr, _node_id) => { let _ = self.check_expr(box_expr); NotPromotable } @@ -334,11 +334,11 @@ fn check_expr_kind<'a, 'tcx>( }; let node_result = match e.node { - hir::ExprBox(ref expr) => { + hir::ExprKind::Box(ref expr) => { let _ = v.check_expr(&expr); NotPromotable } - hir::ExprUnary(op, ref expr) => { + hir::ExprKind::Unary(op, ref expr) => { let expr_promotability = v.check_expr(expr); if v.tables.is_method_call(e) { return NotPromotable; @@ -348,7 +348,7 @@ fn check_expr_kind<'a, 'tcx>( } expr_promotability } - hir::ExprBinary(op, ref lhs, ref rhs) => { + hir::ExprKind::Binary(op, ref lhs, ref rhs) => { let lefty = v.check_expr(lhs); let righty = v.check_expr(rhs); if v.tables.is_method_call(e) { @@ -356,16 +356,16 @@ fn check_expr_kind<'a, 'tcx>( } match v.tables.node_id_to_type(lhs.hir_id).sty { ty::TyRawPtr(_) => { - assert!(op.node == hir::BiEq || op.node == hir::BiNe || - op.node == hir::BiLe || op.node == hir::BiLt || - op.node == hir::BiGe || op.node == hir::BiGt); + assert!(op.node == hir::BinOpKind::Eq || op.node == hir::BinOpKind::Ne || + op.node == hir::BinOpKind::Le || op.node == hir::BinOpKind::Lt || + op.node == hir::BinOpKind::Ge || op.node == hir::BinOpKind::Gt); NotPromotable } _ => lefty & righty } } - hir::ExprCast(ref from, _) => { + hir::ExprKind::Cast(ref from, _) => { let expr_promotability = v.check_expr(from); debug!("Checking const cast(id={})", from.id); match v.tables.cast_kinds().get(from.hir_id) { @@ -379,7 +379,7 @@ fn check_expr_kind<'a, 'tcx>( _ => expr_promotability } } - hir::ExprPath(ref qpath) => { + hir::ExprKind::Path(ref qpath) => { let def = v.tables.qpath_def(qpath, e.hir_id); match def { Def::VariantCtor(..) | Def::StructCtor(..) | @@ -426,7 +426,7 @@ fn check_expr_kind<'a, 'tcx>( _ => NotPromotable } } - hir::ExprCall(ref callee, ref hirvec) => { + hir::ExprKind::Call(ref callee, ref hirvec) => { let mut call_result = v.check_expr(callee); for index in hirvec.iter() { call_result = call_result & v.check_expr(index); @@ -434,7 +434,7 @@ fn check_expr_kind<'a, 'tcx>( let mut callee = &**callee; loop { callee = match callee.node { - hir::ExprBlock(ref block, _) => match block.expr { + hir::ExprKind::Block(ref block, _) => match block.expr { Some(ref tail) => &tail, None => break }, @@ -442,7 +442,7 @@ fn check_expr_kind<'a, 'tcx>( }; } // The callee is an arbitrary expression, it doesn't necessarily have a definition. - let def = if let hir::ExprPath(ref qpath) = callee.node { + let def = if let hir::ExprKind::Path(ref qpath) = callee.node { v.tables.qpath_def(qpath, callee.hir_id) } else { Def::Err @@ -465,7 +465,7 @@ fn check_expr_kind<'a, 'tcx>( }; def_result & call_result } - hir::ExprMethodCall(ref _pathsegment, ref _span, ref hirvec) => { + hir::ExprKind::MethodCall(ref _pathsegment, ref _span, ref hirvec) => { let mut method_call_result = Promotable; for index in hirvec.iter() { method_call_result = method_call_result & v.check_expr(index); @@ -484,7 +484,7 @@ fn check_expr_kind<'a, 'tcx>( } method_call_result } - hir::ExprStruct(ref _qpath, ref hirvec, ref option_expr) => { + hir::ExprKind::Struct(ref _qpath, ref hirvec, ref option_expr) => { let mut struct_result = Promotable; for index in hirvec.iter() { struct_result = struct_result & v.check_expr(&index.expr); @@ -502,14 +502,14 @@ fn check_expr_kind<'a, 'tcx>( struct_result } - hir::ExprLit(_) => Promotable, + hir::ExprKind::Lit(_) => Promotable, - hir::ExprAddrOf(_, ref expr) | - hir::ExprRepeat(ref expr, _) => { + hir::ExprKind::AddrOf(_, ref expr) | + hir::ExprKind::Repeat(ref expr, _) => { v.check_expr(&expr) } - hir::ExprClosure(_capture_clause, ref _box_fn_decl, + hir::ExprKind::Closure(_capture_clause, ref _box_fn_decl, body_id, _span, _option_generator_movability) => { let nested_body_promotable = v.check_nested_body(body_id); // Paths in constant contexts cannot refer to local variables, @@ -521,7 +521,7 @@ fn check_expr_kind<'a, 'tcx>( } } - hir::ExprField(ref expr, _ident) => { + hir::ExprKind::Field(ref expr, _ident) => { let expr_promotability = v.check_expr(&expr); if let Some(def) = v.tables.expr_ty(expr).ty_adt_def() { if def.is_union() { @@ -531,11 +531,11 @@ fn check_expr_kind<'a, 'tcx>( expr_promotability } - hir::ExprBlock(ref box_block, ref _option_label) => { + hir::ExprKind::Block(ref box_block, ref _option_label) => { v.check_block(box_block) } - hir::ExprIndex(ref lhs, ref rhs) => { + hir::ExprKind::Index(ref lhs, ref rhs) => { let lefty = v.check_expr(lhs); let righty = v.check_expr(rhs); if v.tables.is_method_call(e) { @@ -544,7 +544,7 @@ fn check_expr_kind<'a, 'tcx>( lefty & righty } - hir::ExprArray(ref hirvec) => { + hir::ExprKind::Array(ref hirvec) => { let mut array_result = Promotable; for index in hirvec.iter() { array_result = array_result & v.check_expr(index); @@ -552,11 +552,11 @@ fn check_expr_kind<'a, 'tcx>( array_result } - hir::ExprType(ref expr, ref _ty) => { + hir::ExprKind::Type(ref expr, ref _ty) => { v.check_expr(&expr) } - hir::ExprTup(ref hirvec) => { + hir::ExprKind::Tup(ref hirvec) => { let mut tup_result = Promotable; for index in hirvec.iter() { tup_result = tup_result & v.check_expr(index); @@ -566,7 +566,7 @@ fn check_expr_kind<'a, 'tcx>( // Conditional control flow (possible to implement). - hir::ExprMatch(ref expr, ref hirvec_arm, ref _match_source) => { + hir::ExprKind::Match(ref expr, ref hirvec_arm, ref _match_source) => { // Compute the most demanding borrow from all the arms' // patterns and set that on the discriminator. let mut mut_borrow = false; @@ -590,7 +590,7 @@ fn check_expr_kind<'a, 'tcx>( NotPromotable } - hir::ExprIf(ref lhs, ref rhs, ref option_expr) => { + hir::ExprKind::If(ref lhs, ref rhs, ref option_expr) => { let _ = v.check_expr(lhs); let _ = v.check_expr(rhs); match option_expr { @@ -601,19 +601,19 @@ fn check_expr_kind<'a, 'tcx>( } // Loops (not very meaningful in constants). - hir::ExprWhile(ref expr, ref box_block, ref _option_label) => { + hir::ExprKind::While(ref expr, ref box_block, ref _option_label) => { let _ = v.check_expr(expr); let _ = v.check_block(box_block); NotPromotable } - hir::ExprLoop(ref box_block, ref _option_label, ref _loop_source) => { + hir::ExprKind::Loop(ref box_block, ref _option_label, ref _loop_source) => { let _ = v.check_block(box_block); NotPromotable } // More control flow (also not very meaningful). - hir::ExprBreak(_, ref option_expr) | hir::ExprRet(ref option_expr) => { + hir::ExprKind::Break(_, ref option_expr) | hir::ExprKind::Ret(ref option_expr) => { match *option_expr { Some(ref expr) => { let _ = v.check_expr(&expr); }, None => {}, @@ -621,24 +621,24 @@ fn check_expr_kind<'a, 'tcx>( NotPromotable } - hir::ExprContinue(_) => { + hir::ExprKind::Continue(_) => { NotPromotable } // Generator expressions - hir::ExprYield(ref expr) => { + hir::ExprKind::Yield(ref expr) => { let _ = v.check_expr(&expr); NotPromotable } // Expressions with side-effects. - hir::ExprAssignOp(_, ref lhs, ref rhs) | hir::ExprAssign(ref lhs, ref rhs) => { + hir::ExprKind::AssignOp(_, ref lhs, ref rhs) | hir::ExprKind::Assign(ref lhs, ref rhs) => { let _ = v.check_expr(lhs); let _ = v.check_expr(rhs); NotPromotable } - hir::ExprInlineAsm(ref _inline_asm, ref hirvec_lhs, ref hirvec_rhs) => { + hir::ExprKind::InlineAsm(ref _inline_asm, ref hirvec_lhs, ref hirvec_rhs) => { for index in hirvec_lhs.iter() { let _ = v.check_expr(index); } diff --git a/src/librustc_plugin/build.rs b/src/librustc_plugin/build.rs index 88af8b49b9e..f2728593db4 100644 --- a/src/librustc_plugin/build.rs +++ b/src/librustc_plugin/build.rs @@ -24,7 +24,7 @@ struct RegistrarFinder { impl<'v> ItemLikeVisitor<'v> for RegistrarFinder { fn visit_item(&mut self, item: &hir::Item) { - if let hir::ItemFn(..) = item.node { + if let hir::ItemKind::Fn(..) = item.node { if attr::contains_name(&item.attrs, "plugin_registrar") { self.registrars.push((item.id, item.span)); diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 16e2e4b0393..ab383287773 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -149,21 +149,21 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> { fn visit_item(&mut self, item: &'tcx hir::Item) { let inherited_item_level = match item.node { // Impls inherit level from their types and traits - hir::ItemImpl(..) => { + hir::ItemKind::Impl(..) => { let def_id = self.tcx.hir.local_def_id(item.id); cmp::min(self.item_ty_level(def_id), self.impl_trait_level(def_id)) } // Foreign mods inherit level from parents - hir::ItemForeignMod(..) => { + hir::ItemKind::ForeignMod(..) => { self.prev_level } // Other `pub` items inherit levels from parents - hir::ItemConst(..) | hir::ItemEnum(..) | hir::ItemExternCrate(..) | - hir::ItemGlobalAsm(..) | hir::ItemFn(..) | hir::ItemMod(..) | - hir::ItemStatic(..) | hir::ItemStruct(..) | - hir::ItemTrait(..) | hir::ItemTraitAlias(..) | - hir::ItemExistential(..) | - hir::ItemTy(..) | hir::ItemUnion(..) | hir::ItemUse(..) => { + hir::ItemKind::Const(..) | hir::ItemKind::Enum(..) | hir::ItemKind::ExternCrate(..) | + hir::ItemKind::GlobalAsm(..) | hir::ItemKind::Fn(..) | hir::ItemKind::Mod(..) | + hir::ItemKind::Static(..) | hir::ItemKind::Struct(..) | + hir::ItemKind::Trait(..) | hir::ItemKind::TraitAlias(..) | + hir::ItemKind::Existential(..) | + hir::ItemKind::Ty(..) | hir::ItemKind::Union(..) | hir::ItemKind::Use(..) => { if item.vis.node.is_pub() { self.prev_level } else { None } } }; @@ -173,7 +173,7 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> { // Update levels of nested things match item.node { - hir::ItemEnum(ref def, _) => { + hir::ItemKind::Enum(ref def, _) => { for variant in &def.variants { let variant_level = self.update(variant.node.data.id(), item_level); for field in variant.node.data.fields() { @@ -181,24 +181,24 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> { } } } - hir::ItemImpl(.., None, _, ref impl_item_refs) => { + hir::ItemKind::Impl(.., None, _, ref impl_item_refs) => { for impl_item_ref in impl_item_refs { if impl_item_ref.vis.node.is_pub() { self.update(impl_item_ref.id.node_id, item_level); } } } - hir::ItemImpl(.., Some(_), _, ref impl_item_refs) => { + hir::ItemKind::Impl(.., Some(_), _, ref impl_item_refs) => { for impl_item_ref in impl_item_refs { self.update(impl_item_ref.id.node_id, item_level); } } - hir::ItemTrait(.., ref trait_item_refs) => { + hir::ItemKind::Trait(.., ref trait_item_refs) => { for trait_item_ref in trait_item_refs { self.update(trait_item_ref.id.node_id, item_level); } } - hir::ItemStruct(ref def, _) | hir::ItemUnion(ref def, _) => { + hir::ItemKind::Struct(ref def, _) | hir::ItemKind::Union(ref def, _) => { if !def.is_struct() { self.update(def.id(), item_level); } @@ -208,43 +208,49 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> { } } } - hir::ItemForeignMod(ref foreign_mod) => { + hir::ItemKind::ForeignMod(ref foreign_mod) => { for foreign_item in &foreign_mod.items { if foreign_item.vis.node.is_pub() { self.update(foreign_item.id, item_level); } } } - hir::ItemExistential(..) | - hir::ItemUse(..) | hir::ItemStatic(..) | hir::ItemConst(..) | - hir::ItemGlobalAsm(..) | hir::ItemTy(..) | hir::ItemMod(..) | hir::ItemTraitAlias(..) | - hir::ItemFn(..) | hir::ItemExternCrate(..) => {} + hir::ItemKind::Existential(..) | + hir::ItemKind::Use(..) | + hir::ItemKind::Static(..) | + hir::ItemKind::Const(..) | + hir::ItemKind::GlobalAsm(..) | + hir::ItemKind::Ty(..) | + hir::ItemKind::Mod(..) | + hir::ItemKind::TraitAlias(..) | + hir::ItemKind::Fn(..) | + hir::ItemKind::ExternCrate(..) => {} } // Mark all items in interfaces of reachable items as reachable match item.node { // The interface is empty - hir::ItemExternCrate(..) => {} + hir::ItemKind::ExternCrate(..) => {} // All nested items are checked by visit_item - hir::ItemMod(..) => {} + hir::ItemKind::Mod(..) => {} // Re-exports are handled in visit_mod - hir::ItemUse(..) => {} + hir::ItemKind::Use(..) => {} // The interface is empty - hir::ItemGlobalAsm(..) => {} - hir::ItemExistential(..) => { + hir::ItemKind::GlobalAsm(..) => {} + hir::ItemKind::Existential(..) => { if item_level.is_some() { // Reach the (potentially private) type and the API being exposed self.reach(item.id).ty().predicates(); } } // Visit everything - hir::ItemConst(..) | hir::ItemStatic(..) | - hir::ItemFn(..) | hir::ItemTy(..) => { + hir::ItemKind::Const(..) | hir::ItemKind::Static(..) | + hir::ItemKind::Fn(..) | hir::ItemKind::Ty(..) => { if item_level.is_some() { self.reach(item.id).generics().predicates().ty(); } } - hir::ItemTrait(.., ref trait_item_refs) => { + hir::ItemKind::Trait(.., ref trait_item_refs) => { if item_level.is_some() { self.reach(item.id).generics().predicates(); @@ -261,13 +267,13 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> { } } } - hir::ItemTraitAlias(..) => { + hir::ItemKind::TraitAlias(..) => { if item_level.is_some() { self.reach(item.id).generics().predicates(); } } // Visit everything except for private impl items - hir::ItemImpl(.., ref trait_ref, _, ref impl_item_refs) => { + hir::ItemKind::Impl(.., ref trait_ref, _, ref impl_item_refs) => { if item_level.is_some() { self.reach(item.id).generics().predicates().impl_trait_ref(); @@ -281,7 +287,7 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> { } // Visit everything, but enum variants have their own levels - hir::ItemEnum(ref def, _) => { + hir::ItemKind::Enum(ref def, _) => { if item_level.is_some() { self.reach(item.id).generics().predicates(); } @@ -297,7 +303,7 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> { } } // Visit everything, but foreign items have their own levels - hir::ItemForeignMod(ref foreign_mod) => { + hir::ItemKind::ForeignMod(ref foreign_mod) => { for foreign_item in &foreign_mod.items { if self.get(foreign_item.id).is_some() { self.reach(foreign_item.id).generics().predicates().ty(); @@ -305,8 +311,8 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> { } } // Visit everything except for private fields - hir::ItemStruct(ref struct_def, _) | - hir::ItemUnion(ref struct_def, _) => { + hir::ItemKind::Struct(ref struct_def, _) | + hir::ItemKind::Union(ref struct_def, _) => { if item_level.is_some() { self.reach(item.id).generics().predicates(); for field in struct_def.fields() { @@ -373,7 +379,8 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> { loop { let module = if module_id == ast::CRATE_NODE_ID { &self.tcx.hir.krate().module - } else if let hir::ItemMod(ref module) = self.tcx.hir.expect_item(module_id).node { + } else if let hir::ItemKind::Mod(ref module) = self.tcx.hir.expect_item(module_id).node + { module } else { unreachable!() @@ -568,7 +575,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NamePrivacyVisitor<'a, 'tcx> { fn visit_expr(&mut self, expr: &'tcx hir::Expr) { match expr.node { - hir::ExprStruct(ref qpath, ref fields, ref base) => { + hir::ExprKind::Struct(ref qpath, ref fields, ref base) => { let def = self.tables.qpath_def(qpath, expr.hir_id); let adt = self.tables.expr_ty(expr).ty_adt_def().unwrap(); let variant = adt.variant_of_def(def); @@ -778,13 +785,13 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> { return; } match expr.node { - hir::ExprAssign(.., ref rhs) | hir::ExprMatch(ref rhs, ..) => { + hir::ExprKind::Assign(.., ref rhs) | hir::ExprKind::Match(ref rhs, ..) => { // Do not report duplicate errors for `x = y` and `match x { ... }`. if self.check_expr_pat_type(rhs.hir_id, rhs.span) { return; } } - hir::ExprMethodCall(_, span, _) => { + hir::ExprKind::MethodCall(_, span, _) => { // Method calls have to be checked specially. self.span = span; if let Some(def) = self.tables.type_dependent_defs().get(expr.hir_id) { @@ -1052,7 +1059,7 @@ impl<'a, 'b, 'tcx, 'v> Visitor<'v> for ObsoleteCheckTypeForPrivatenessVisitor<'a } fn visit_ty(&mut self, ty: &hir::Ty) { - if let hir::TyPath(hir::QPath::Resolved(_, ref path)) = ty.node { + if let hir::TyKind::Path(hir::QPath::Resolved(_, ref path)) = ty.node { if self.inner.path_is_private_type(path) { self.contains_private = true; // found what we're looking for so let's stop @@ -1060,7 +1067,7 @@ impl<'a, 'b, 'tcx, 'v> Visitor<'v> for ObsoleteCheckTypeForPrivatenessVisitor<'a return } } - if let hir::TyPath(_) = ty.node { + if let hir::TyKind::Path(_) = ty.node { if self.at_outer_type { self.outer_type_is_public_path = true; } @@ -1084,13 +1091,13 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> { match item.node { // contents of a private mod can be re-exported, so we need // to check internals. - hir::ItemMod(_) => {} + hir::ItemKind::Mod(_) => {} // An `extern {}` doesn't introduce a new privacy // namespace (the contents have their own privacies). - hir::ItemForeignMod(_) => {} + hir::ItemKind::ForeignMod(_) => {} - hir::ItemTrait(.., ref bounds, _) => { + hir::ItemKind::Trait(.., ref bounds, _) => { if !self.trait_is_public(item.id) { return } @@ -1105,7 +1112,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> { // (i.e. we could just return here to not check them at // all, or some worse estimation of whether an impl is // publicly visible). - hir::ItemImpl(.., ref g, ref trait_ref, ref self_, ref impl_item_refs) => { + hir::ItemKind::Impl(.., ref g, ref trait_ref, ref self_, ref impl_item_refs) => { // `impl [... for] Private` is never visible. let self_contains_private; // impl [... for] Public<...>, but not `impl [... for] @@ -1245,7 +1252,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> { // `type ... = ...;` can contain private types, because // we're introducing a new name. - hir::ItemTy(..) => return, + hir::ItemKind::Ty(..) => return, // not at all public, so we don't care _ if !self.item_is_public(&item.id, &item.vis) => { @@ -1293,7 +1300,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> { } fn visit_ty(&mut self, t: &'tcx hir::Ty) { - if let hir::TyPath(hir::QPath::Resolved(_, ref path)) = t.node { + if let hir::TyKind::Path(hir::QPath::Resolved(_, ref path)) = t.node { if self.path_is_private_type(path) { self.old_error_set.insert(t.id); } @@ -1552,14 +1559,14 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> match item.node { // Crates are always public - hir::ItemExternCrate(..) => {} + hir::ItemKind::ExternCrate(..) => {} // All nested items are checked by visit_item - hir::ItemMod(..) => {} + hir::ItemKind::Mod(..) => {} // Checked in resolve - hir::ItemUse(..) => {} + hir::ItemKind::Use(..) => {} // No subitems - hir::ItemGlobalAsm(..) => {} - hir::ItemExistential(..) => { + hir::ItemKind::GlobalAsm(..) => {} + hir::ItemKind::Existential(..) => { // Check the traits being exposed, as they're separate, // e.g. `impl Iterator<Item=T>` has two predicates, // `X: Iterator` and `<X as Iterator>::Item == T`, @@ -1569,15 +1576,15 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> self.check(item.id, item_visibility).predicates(); } // Subitems of these items have inherited publicity - hir::ItemConst(..) | hir::ItemStatic(..) | hir::ItemFn(..) | - hir::ItemTy(..) => { + hir::ItemKind::Const(..) | hir::ItemKind::Static(..) | hir::ItemKind::Fn(..) | + hir::ItemKind::Ty(..) => { self.check(item.id, item_visibility).generics().predicates().ty(); // Recurse for e.g. `impl Trait` (see `visit_ty`). self.inner_visibility = item_visibility; intravisit::walk_item(self, item); } - hir::ItemTrait(.., ref trait_item_refs) => { + hir::ItemKind::Trait(.., ref trait_item_refs) => { self.check(item.id, item_visibility).generics().predicates(); for trait_item_ref in trait_item_refs { @@ -1593,10 +1600,10 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> } } } - hir::ItemTraitAlias(..) => { + hir::ItemKind::TraitAlias(..) => { self.check(item.id, item_visibility).generics().predicates(); } - hir::ItemEnum(ref def, _) => { + hir::ItemKind::Enum(ref def, _) => { self.check(item.id, item_visibility).generics().predicates(); for variant in &def.variants { @@ -1606,15 +1613,15 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> } } // Subitems of foreign modules have their own publicity - hir::ItemForeignMod(ref foreign_mod) => { + hir::ItemKind::ForeignMod(ref foreign_mod) => { for foreign_item in &foreign_mod.items { let vis = ty::Visibility::from_hir(&foreign_item.vis, item.id, tcx); self.check(foreign_item.id, vis).generics().predicates().ty(); } } // Subitems of structs and unions have their own publicity - hir::ItemStruct(ref struct_def, _) | - hir::ItemUnion(ref struct_def, _) => { + hir::ItemKind::Struct(ref struct_def, _) | + hir::ItemKind::Union(ref struct_def, _) => { self.check(item.id, item_visibility).generics().predicates(); for field in struct_def.fields() { @@ -1624,7 +1631,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> } // An inherent impl is public when its type is public // Subitems of inherent impls have their own publicity - hir::ItemImpl(.., None, _, ref impl_item_refs) => { + hir::ItemKind::Impl(.., None, _, ref impl_item_refs) => { let ty_vis = self.check(item.id, ty::Visibility::Invisible).ty().min_visibility; self.check(item.id, ty_vis).generics().predicates(); @@ -1643,7 +1650,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> } // A trait impl is public when both its type and its trait are public // Subitems of trait impls have inherited publicity - hir::ItemImpl(.., Some(_), _, ref impl_item_refs) => { + hir::ItemKind::Impl(.., Some(_), _, ref impl_item_refs) => { let vis = self.check(item.id, ty::Visibility::Invisible) .ty().impl_trait_ref().min_visibility; self.check(item.id, vis).generics().predicates(); diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index 055fbb236d8..f2620c04754 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -420,7 +420,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { match self.tcx.impl_of_method(self.tcx.hir.local_def_id(id)) { Some(impl_id) => match self.tcx.hir.get_if_local(impl_id) { Some(Node::NodeItem(item)) => match item.node { - hir::ItemImpl(.., ref ty, _) => { + hir::ItemKind::Impl(.., ref ty, _) => { let mut qualname = String::from("<"); qualname.push_str(&self.tcx.hir.node_to_pretty_string(ty.id)); @@ -630,18 +630,18 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { Node::NodeTraitRef(tr) => tr.path.def, Node::NodeItem(&hir::Item { - node: hir::ItemUse(ref path, _), + node: hir::ItemKind::Use(ref path, _), .. }) | Node::NodeVisibility(&Spanned { node: hir::VisibilityKind::Restricted { ref path, .. }, .. }) => path.def, Node::NodeExpr(&hir::Expr { - node: hir::ExprStruct(ref qpath, ..), + node: hir::ExprKind::Struct(ref qpath, ..), .. }) | Node::NodeExpr(&hir::Expr { - node: hir::ExprPath(ref qpath), + node: hir::ExprKind::Path(ref qpath), .. }) | Node::NodePat(&hir::Pat { @@ -666,7 +666,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { }) => HirDef::Local(canonical_id), Node::NodeTy(ty) => if let hir::Ty { - node: hir::TyPath(ref qpath), + node: hir::TyKind::Path(ref qpath), .. } = *ty { diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 5e38c0bbcb4..f85e7b06858 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -1117,60 +1117,60 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o { let tcx = self.tcx(); let result_ty = match ast_ty.node { - hir::TySlice(ref ty) => { + hir::TyKind::Slice(ref ty) => { tcx.mk_slice(self.ast_ty_to_ty(&ty)) } - hir::TyPtr(ref mt) => { + hir::TyKind::Ptr(ref mt) => { tcx.mk_ptr(ty::TypeAndMut { ty: self.ast_ty_to_ty(&mt.ty), mutbl: mt.mutbl }) } - hir::TyRptr(ref region, ref mt) => { + hir::TyKind::Rptr(ref region, ref mt) => { let r = self.ast_region_to_region(region, None); debug!("TyRef r={:?}", r); let t = self.ast_ty_to_ty(&mt.ty); tcx.mk_ref(r, ty::TypeAndMut {ty: t, mutbl: mt.mutbl}) } - hir::TyNever => { + hir::TyKind::Never => { tcx.types.never }, - hir::TyTup(ref fields) => { + hir::TyKind::Tup(ref fields) => { tcx.mk_tup(fields.iter().map(|t| self.ast_ty_to_ty(&t))) } - hir::TyBareFn(ref bf) => { + hir::TyKind::BareFn(ref bf) => { require_c_abi_if_variadic(tcx, &bf.decl, bf.abi, ast_ty.span); tcx.mk_fn_ptr(self.ty_of_fn(bf.unsafety, bf.abi, &bf.decl)) } - hir::TyTraitObject(ref bounds, ref lifetime) => { + hir::TyKind::TraitObject(ref bounds, ref lifetime) => { self.conv_object_ty_poly_trait_ref(ast_ty.span, bounds, lifetime) } - hir::TyPath(hir::QPath::Resolved(ref maybe_qself, ref path)) => { + hir::TyKind::Path(hir::QPath::Resolved(ref maybe_qself, ref path)) => { debug!("ast_ty_to_ty: maybe_qself={:?} path={:?}", maybe_qself, path); let opt_self_ty = maybe_qself.as_ref().map(|qself| { self.ast_ty_to_ty(qself) }); self.def_to_ty(opt_self_ty, path, false) } - hir::TyPath(hir::QPath::TypeRelative(ref qself, ref segment)) => { + hir::TyKind::Path(hir::QPath::TypeRelative(ref qself, ref segment)) => { debug!("ast_ty_to_ty: qself={:?} segment={:?}", qself, segment); let ty = self.ast_ty_to_ty(qself); - let def = if let hir::TyPath(hir::QPath::Resolved(_, ref path)) = qself.node { + let def = if let hir::TyKind::Path(hir::QPath::Resolved(_, ref path)) = qself.node { path.def } else { Def::Err }; self.associated_path_def_to_ty(ast_ty.id, ast_ty.span, ty, def, segment).0 } - hir::TyArray(ref ty, ref length) => { + hir::TyKind::Array(ref ty, ref length) => { let length_def_id = tcx.hir.local_def_id(length.id); let substs = Substs::identity_for_item(tcx, length_def_id); let length = ty::Const::unevaluated(tcx, length_def_id, substs, tcx.types.usize); let array_ty = tcx.mk_ty(ty::TyArray(self.ast_ty_to_ty(&ty), length)); self.normalize_ty(ast_ty.span, array_ty) } - hir::TyTypeof(ref _e) => { + hir::TyKind::Typeof(ref _e) => { struct_span_err!(tcx.sess, ast_ty.span, E0516, "`typeof` is a reserved keyword but unimplemented") .span_label(ast_ty.span, "reserved keyword") @@ -1178,14 +1178,14 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o { tcx.types.err } - hir::TyInfer => { + hir::TyKind::Infer => { // TyInfer also appears as the type of arguments or return - // values in a ExprClosure, or as + // values in a ExprKind::Closure, or as // the type of local variables. Both of these cases are // handled specially and will not descend into this routine. self.ty_infer(ast_ty.span) } - hir::TyErr => { + hir::TyKind::Err => { tcx.types.err } }; @@ -1241,7 +1241,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o { -> Ty<'tcx> { match ty.node { - hir::TyInfer if expected_ty.is_some() => { + hir::TyKind::Infer if expected_ty.is_some() => { self.record_ty(ty.hir_id, expected_ty.unwrap(), ty.span); expected_ty.unwrap() } diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index c260655bd3e..c9b5fd525dd 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -147,7 +147,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // Byte string patterns behave the same way as array patterns // They can denote both statically and dynamically sized byte arrays let mut pat_ty = ty; - if let hir::ExprLit(ref lt) = lt.node { + if let hir::ExprKind::Lit(ref lt) = lt.node { if let ast::LitKind::ByteStr(_) = lt.node { let expected_ty = self.structurally_resolved_type(pat.span, expected); if let ty::TyRef(_, r_ty, _) = expected_ty.sty { diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs index 383820a62bf..ec127d26ab3 100644 --- a/src/librustc_typeck/check/callee.rs +++ b/src/librustc_typeck/check/callee.rs @@ -214,7 +214,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let mut unit_variant = None; if let &ty::TyAdt(adt_def, ..) = t { if adt_def.is_enum() { - if let hir::ExprCall(ref expr, _) = call_expr.node { + if let hir::ExprKind::Call(ref expr, _) = call_expr.node { unit_variant = Some(self.tcx.hir.node_to_pretty_string(expr.id)) } } @@ -240,8 +240,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { path.to_string()); } - if let hir::ExprCall(ref expr, _) = call_expr.node { - let def = if let hir::ExprPath(ref qpath) = expr.node { + if let hir::ExprKind::Call(ref expr, _) = call_expr.node { + let def = if let hir::ExprKind::Path(ref qpath) = expr.node { self.tables.borrow().qpath_def(qpath, expr.hir_id) } else { Def::Err diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs index 4c903b6fe58..220dd122b26 100644 --- a/src/librustc_typeck/check/compare_method.rs +++ b/src/librustc_typeck/check/compare_method.rs @@ -429,8 +429,8 @@ fn extract_spans_for_error_reporting<'a, 'gcx, 'tcx>(infcx: &infer::InferCtxt<'a impl_m_iter.zip(trait_m_iter).find(|&(ref impl_arg, ref trait_arg)| { match (&impl_arg.node, &trait_arg.node) { - (&hir::TyRptr(_, ref impl_mt), &hir::TyRptr(_, ref trait_mt)) | - (&hir::TyPtr(ref impl_mt), &hir::TyPtr(ref trait_mt)) => { + (&hir::TyKind::Rptr(_, ref impl_mt), &hir::TyKind::Rptr(_, ref trait_mt)) | + (&hir::TyKind::Ptr(ref impl_mt), &hir::TyKind::Ptr(ref trait_mt)) => { impl_mt.mutbl != trait_mt.mutbl } _ => false, @@ -822,7 +822,7 @@ fn compare_synthetic_generics<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn visit_ty(&mut self, ty: &'v hir::Ty) { hir::intravisit::walk_ty(self, ty); match ty.node { - hir::TyPath(hir::QPath::Resolved(None, ref path)) => { + hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) => { if let hir::def::Def::TyParam(def_id) = path.def { if def_id == self.1 { self.0 = Some(ty.span); diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs index aee64ad3b55..92b35bd50f3 100644 --- a/src/librustc_typeck/check/demand.rs +++ b/src/librustc_typeck/check/demand.rs @@ -18,7 +18,7 @@ use syntax_pos::Span; use rustc::hir; use rustc::hir::def::Def; use rustc::hir::map::{NodeItem, NodeExpr}; -use rustc::hir::{Item, ItemConst, print}; +use rustc::hir::{Item, ItemKind, print}; use rustc::ty::{self, Ty, AssociatedItem}; use rustc::ty::adjustment::AllowTwoPhase; use errors::{DiagnosticBuilder, CodeMapper}; @@ -196,17 +196,17 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { /// opt.map(|arg| { takes_ref(arg) }); /// ``` fn can_use_as_ref(&self, expr: &hir::Expr) -> Option<(Span, &'static str, String)> { - if let hir::ExprPath(hir::QPath::Resolved(_, ref path)) = expr.node { + if let hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) = expr.node { if let hir::def::Def::Local(id) = path.def { let parent = self.tcx.hir.get_parent_node(id); if let Some(NodeExpr(hir::Expr { id, - node: hir::ExprClosure(_, decl, ..), + node: hir::ExprKind::Closure(_, decl, ..), .. })) = self.tcx.hir.find(parent) { let parent = self.tcx.hir.get_parent_node(*id); if let (Some(NodeExpr(hir::Expr { - node: hir::ExprMethodCall(path, span, expr), + node: hir::ExprKind::MethodCall(path, span, expr), .. })), 1) = (self.tcx.hir.find(parent), decl.inputs.len()) { let self_ty = self.tables.borrow().node_id_to_type(expr[0].hir_id); @@ -262,7 +262,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { (&ty::TyRef(_, exp, _), &ty::TyRef(_, check, _)) => match (&exp.sty, &check.sty) { (&ty::TyStr, &ty::TyArray(arr, _)) | (&ty::TyStr, &ty::TySlice(arr)) if arr == self.tcx.types.u8 => { - if let hir::ExprLit(_) = expr.node { + if let hir::ExprKind::Lit(_) = expr.node { if let Ok(src) = cm.span_to_snippet(sp) { if src.starts_with("b\"") { return Some((sp, @@ -274,7 +274,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { }, (&ty::TyArray(arr, _), &ty::TyStr) | (&ty::TySlice(arr), &ty::TyStr) if arr == self.tcx.types.u8 => { - if let hir::ExprLit(_) = expr.node { + if let hir::ExprKind::Lit(_) = expr.node { if let Ok(src) = cm.span_to_snippet(sp) { if src.starts_with("\"") { return Some((sp, @@ -306,7 +306,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if self.can_coerce(ref_ty, expected) { if let Ok(src) = cm.span_to_snippet(sp) { let sugg_expr = match expr.node { // parenthesize if needed (Issue #46756) - hir::ExprCast(_, _) | hir::ExprBinary(_, _, _) => format!("({})", src), + hir::ExprKind::Cast(_, _) | + hir::ExprKind::Binary(_, _, _) => format!("({})", src), _ => src, }; if let Some(sugg) = self.can_use_as_ref(expr) { @@ -336,7 +337,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { sp.ctxt().outer().expn_info().is_none() { match expr.node { // Maybe remove `&`? - hir::ExprAddrOf(_, ref expr) => { + hir::ExprKind::AddrOf(_, ref expr) => { if !cm.span_to_filename(expr.span).is_real() { return None; } @@ -376,7 +377,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { match self.tcx.hir.find(parent_id) { Some(parent) => { // Shouldn't suggest `.into()` on `const`s. - if let NodeItem(Item { node: ItemConst(_, _), .. }) = parent { + if let NodeItem(Item { node: ItemKind::Const(_, _), .. }) = parent { // FIXME(estebank): modify once we decide to suggest `as` casts return false; } diff --git a/src/librustc_typeck/check/intrinsic.rs b/src/librustc_typeck/check/intrinsic.rs index c93023edcea..e26bf1b4f77 100644 --- a/src/librustc_typeck/check/intrinsic.rs +++ b/src/librustc_typeck/check/intrinsic.rs @@ -35,7 +35,7 @@ fn equate_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let def_id = tcx.hir.local_def_id(it.id); match it.node { - hir::ForeignItemFn(..) => {} + hir::ForeignItemKind::Fn(..) => {} _ => { struct_span_err!(tcx.sess, it.span, E0622, "intrinsic must be a function") @@ -48,7 +48,7 @@ fn equate_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let i_n_tps = tcx.generics_of(def_id).own_counts().types; if i_n_tps != n_tps { let span = match it.node { - hir::ForeignItemFn(_, _, ref generics) => generics.span, + hir::ForeignItemKind::Fn(_, _, ref generics) => generics.span, _ => bug!() }; diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs index 36ce01bcd08..6c3e265619f 100644 --- a/src/librustc_typeck/check/method/confirm.rs +++ b/src/librustc_typeck/check/method/confirm.rs @@ -449,9 +449,9 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> { loop { let last = exprs[exprs.len() - 1]; match last.node { - hir::ExprField(ref expr, _) | - hir::ExprIndex(ref expr, _) | - hir::ExprUnary(hir::UnDeref, ref expr) => exprs.push(&expr), + hir::ExprKind::Field(ref expr, _) | + hir::ExprKind::Index(ref expr, _) | + hir::ExprKind::Unary(hir::UnDeref, ref expr) => exprs.push(&expr), _ => break, } } @@ -493,12 +493,12 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> { } match expr.node { - hir::ExprIndex(ref base_expr, ref index_expr) => { + hir::ExprKind::Index(ref base_expr, ref index_expr) => { let index_expr_ty = self.node_ty(index_expr.hir_id); self.convert_place_op_to_mutable( PlaceOp::Index, expr, base_expr, &[index_expr_ty]); } - hir::ExprUnary(hir::UnDeref, ref base_expr) => { + hir::ExprKind::Unary(hir::UnDeref, ref base_expr) => { self.convert_place_op_to_mutable( PlaceOp::Deref, expr, base_expr, &[]); } diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index 68c71f4ce90..026a9de5052 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -245,7 +245,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { "f32" }; match expr.node { - hir::ExprLit(ref lit) => { // numeric literal + hir::ExprKind::Lit(ref lit) => { // numeric literal let snippet = tcx.sess.codemap().span_to_snippet(lit.span) .unwrap_or("<numeric literal>".to_string()); @@ -257,7 +257,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { snippet, concrete_type)); } - hir::ExprPath(ref qpath) => { // local binding + hir::ExprKind::Path(ref qpath) => { // local binding if let &hir::QPath::Resolved(_, ref path) = &qpath { if let hir::def::Def::Local(node_id) = path.def { let span = tcx.hir.span(node_id); @@ -389,7 +389,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if let Some(expr) = rcvr_expr { if let Ok(expr_string) = tcx.sess.codemap().span_to_snippet(expr.span) { report_function!(expr.span, expr_string); - } else if let hir::ExprPath(hir::QPath::Resolved(_, ref path)) = expr.node { + } else if let hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) = + expr.node + { if let Some(segment) = path.segments.last() { report_function!(expr.span, segment.ident); } @@ -709,7 +711,7 @@ fn compute_all_traits<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Vec<DefId> impl<'v, 'a, 'tcx> itemlikevisit::ItemLikeVisitor<'v> for Visitor<'a, 'tcx> { fn visit_item(&mut self, i: &'v hir::Item) { match i.node { - hir::ItemTrait(..) => { + hir::ItemKind::Trait(..) => { let def_id = self.map.local_def_id(i.id); self.traits.push(def_id); } @@ -810,7 +812,7 @@ impl<'a, 'tcx, 'gcx> hir::intravisit::Visitor<'tcx> for UsePlacementFinder<'a, ' for item_id in &module.item_ids { let item = self.tcx.hir.expect_item(item_id.id); match item.node { - hir::ItemUse(..) => { + hir::ItemKind::Use(..) => { // don't suggest placing a use before the prelude // import or other generated ones if item.span.ctxt().outer().expn_info().is_none() { @@ -820,7 +822,7 @@ impl<'a, 'tcx, 'gcx> hir::intravisit::Visitor<'tcx> for UsePlacementFinder<'a, ' } }, // don't place use before extern crate - hir::ItemExternCrate(_) => {} + hir::ItemKind::ExternCrate(_) => {} // but place them before the first other item _ => if self.span.map_or(true, |span| item.span < span ) { if item.span.ctxt().outer().expn_info().is_none() { diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index c7ad3398873..9f83f8a00b1 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -132,7 +132,7 @@ use syntax_pos::{self, BytePos, Span, MultiSpan}; use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap}; use rustc::hir::itemlikevisit::ItemLikeVisitor; use rustc::hir::map::Node; -use rustc::hir::{self, PatKind, Item_}; +use rustc::hir::{self, PatKind, ItemKind}; use rustc::middle::lang_items; mod autoderef; @@ -759,10 +759,10 @@ fn primary_body_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, match tcx.hir.get(id) { hir::map::NodeItem(item) => { match item.node { - hir::ItemConst(_, body) | - hir::ItemStatic(_, _, body) => + hir::ItemKind::Const(_, body) | + hir::ItemKind::Static(_, _, body) => Some((body, None)), - hir::ItemFn(ref decl, .., body) => + hir::ItemKind::Fn(ref decl, .., body) => Some((body, Some(decl))), _ => None, @@ -1165,7 +1165,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>, } if let Node::NodeItem(item) = fcx.tcx.hir.get(fn_id) { - if let Item_::ItemFn(_, _, ref generics, _) = item.node { + if let ItemKind::Fn(_, _, ref generics, _) = item.node { if !generics.params.is_empty() { fcx.tcx.sess.span_err( span, @@ -1213,7 +1213,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>, } if let Node::NodeItem(item) = fcx.tcx.hir.get(fn_id) { - if let Item_::ItemFn(_, _, ref generics, _) = item.node { + if let ItemKind::Fn(_, _, ref generics, _) = item.node { if !generics.params.is_empty() { fcx.tcx.sess.span_err( span, @@ -1269,25 +1269,25 @@ pub fn check_item_type<'a,'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, it: &'tcx hir::Item let _indenter = indenter(); match it.node { // Consts can play a role in type-checking, so they are included here. - hir::ItemStatic(..) => { + hir::ItemKind::Static(..) => { tcx.typeck_tables_of(tcx.hir.local_def_id(it.id)); } - hir::ItemConst(..) => { + hir::ItemKind::Const(..) => { tcx.typeck_tables_of(tcx.hir.local_def_id(it.id)); if it.attrs.iter().any(|a| a.check_name("wasm_custom_section")) { let def_id = tcx.hir.local_def_id(it.id); check_const_is_u8_array(tcx, def_id, it.span); } } - hir::ItemEnum(ref enum_definition, _) => { + hir::ItemKind::Enum(ref enum_definition, _) => { check_enum(tcx, it.span, &enum_definition.variants, it.id); } - hir::ItemFn(..) => {} // entirely within check_item_body - hir::ItemImpl(.., ref impl_item_refs) => { - debug!("ItemImpl {} with id {}", it.name, it.id); + hir::ItemKind::Fn(..) => {} // entirely within check_item_body + hir::ItemKind::Impl(.., ref impl_item_refs) => { + debug!("ItemKind::Impl {} with id {}", it.name, it.id); let impl_def_id = tcx.hir.local_def_id(it.id); if let Some(impl_trait_ref) = tcx.impl_trait_ref(impl_def_id) { check_impl_items_against_trait(tcx, @@ -1299,23 +1299,23 @@ pub fn check_item_type<'a,'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, it: &'tcx hir::Item check_on_unimplemented(tcx, trait_def_id, it); } } - hir::ItemTrait(..) => { + hir::ItemKind::Trait(..) => { let def_id = tcx.hir.local_def_id(it.id); check_on_unimplemented(tcx, def_id, it); } - hir::ItemStruct(..) => { + hir::ItemKind::Struct(..) => { check_struct(tcx, it.id, it.span); } - hir::ItemUnion(..) => { + hir::ItemKind::Union(..) => { check_union(tcx, it.id, it.span); } - hir::ItemTy(..) => { + hir::ItemKind::Ty(..) => { let def_id = tcx.hir.local_def_id(it.id); let pty_ty = tcx.type_of(def_id); let generics = tcx.generics_of(def_id); check_bounds_are_used(tcx, &generics, pty_ty); } - hir::ItemForeignMod(ref m) => { + hir::ItemKind::ForeignMod(ref m) => { check_abi(tcx, it.span, m.abi); if m.abi == Abi::RustIntrinsic { @@ -1340,7 +1340,7 @@ pub fn check_item_type<'a,'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, it: &'tcx hir::Item err.emit(); } - if let hir::ForeignItemFn(ref fn_decl, _, _) = item.node { + if let hir::ForeignItemKind::Fn(ref fn_decl, _, _) = item.node { require_c_abi_if_variadic(tcx, fn_decl, m.abi, item.span); } } @@ -2347,52 +2347,52 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { fn is_place_expr(&self, expr: &hir::Expr) -> bool { match expr.node { - hir::ExprPath(hir::QPath::Resolved(_, ref path)) => { + hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => { match path.def { Def::Local(..) | Def::Upvar(..) | Def::Static(..) | Def::Err => true, _ => false, } } - hir::ExprType(ref e, _) => { + hir::ExprKind::Type(ref e, _) => { self.is_place_expr(e) } - hir::ExprUnary(hir::UnDeref, _) | - hir::ExprField(..) | - hir::ExprIndex(..) => { + hir::ExprKind::Unary(hir::UnDeref, _) | + hir::ExprKind::Field(..) | + hir::ExprKind::Index(..) => { true } // Partially qualified paths in expressions can only legally // refer to associated items which are always rvalues. - hir::ExprPath(hir::QPath::TypeRelative(..)) | - - hir::ExprCall(..) | - hir::ExprMethodCall(..) | - hir::ExprStruct(..) | - hir::ExprTup(..) | - hir::ExprIf(..) | - hir::ExprMatch(..) | - hir::ExprClosure(..) | - hir::ExprBlock(..) | - hir::ExprRepeat(..) | - hir::ExprArray(..) | - hir::ExprBreak(..) | - hir::ExprContinue(..) | - hir::ExprRet(..) | - hir::ExprWhile(..) | - hir::ExprLoop(..) | - hir::ExprAssign(..) | - hir::ExprInlineAsm(..) | - hir::ExprAssignOp(..) | - hir::ExprLit(_) | - hir::ExprUnary(..) | - hir::ExprBox(..) | - hir::ExprAddrOf(..) | - hir::ExprBinary(..) | - hir::ExprYield(..) | - hir::ExprCast(..) => { + hir::ExprKind::Path(hir::QPath::TypeRelative(..)) | + + hir::ExprKind::Call(..) | + hir::ExprKind::MethodCall(..) | + hir::ExprKind::Struct(..) | + hir::ExprKind::Tup(..) | + hir::ExprKind::If(..) | + hir::ExprKind::Match(..) | + hir::ExprKind::Closure(..) | + hir::ExprKind::Block(..) | + hir::ExprKind::Repeat(..) | + hir::ExprKind::Array(..) | + hir::ExprKind::Break(..) | + hir::ExprKind::Continue(..) | + hir::ExprKind::Ret(..) | + hir::ExprKind::While(..) | + hir::ExprKind::Loop(..) | + hir::ExprKind::Assign(..) | + hir::ExprKind::InlineAsm(..) | + hir::ExprKind::AssignOp(..) | + hir::ExprKind::Lit(_) | + hir::ExprKind::Unary(..) | + hir::ExprKind::Box(..) | + hir::ExprKind::AddrOf(..) | + hir::ExprKind::Binary(..) | + hir::ExprKind::Yield(..) | + hir::ExprKind::Cast(..) => { false } } @@ -2763,7 +2763,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } let is_closure = match arg.node { - hir::ExprClosure(..) => true, + hir::ExprKind::Closure(..) => true, _ => false }; @@ -2915,7 +2915,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if let Some(mut err) = self.demand_suptype_diag(expr.span, expected_ty, ty) { // Add help to type error if this is an `if` condition with an assignment match (expected, &expr.node) { - (ExpectIfCondition, &hir::ExprAssign(ref lhs, ref rhs)) => { + (ExpectIfCondition, &hir::ExprKind::Assign(ref lhs, ref rhs)) => { let msg = "try comparing for equality"; if let (Ok(left), Ok(right)) = ( self.tcx.sess.codemap().span_to_snippet(lhs.span), @@ -3625,9 +3625,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // Warn for non-block expressions with diverging children. match expr.node { - hir::ExprBlock(..) | - hir::ExprLoop(..) | hir::ExprWhile(..) | - hir::ExprIf(..) | hir::ExprMatch(..) => {} + hir::ExprKind::Block(..) | + hir::ExprKind::Loop(..) | hir::ExprKind::While(..) | + hir::ExprKind::If(..) | hir::ExprKind::Match(..) => {} _ => self.warn_if_unreachable(expr.id, expr.span, "expression") } @@ -3659,7 +3659,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let tcx = self.tcx; let id = expr.id; match expr.node { - hir::ExprBox(ref subexpr) => { + hir::ExprKind::Box(ref subexpr) => { let expected_inner = expected.to_option(self).map_or(NoExpectation, |ty| { match ty.sty { ty::TyAdt(def, _) if def.is_box() @@ -3671,16 +3671,16 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { tcx.mk_box(referent_ty) } - hir::ExprLit(ref lit) => { + hir::ExprKind::Lit(ref lit) => { self.check_lit(&lit, expected) } - hir::ExprBinary(op, ref lhs, ref rhs) => { + hir::ExprKind::Binary(op, ref lhs, ref rhs) => { self.check_binop(expr, op, lhs, rhs) } - hir::ExprAssignOp(op, ref lhs, ref rhs) => { + hir::ExprKind::AssignOp(op, ref lhs, ref rhs) => { self.check_binop_assign(expr, op, lhs, rhs) } - hir::ExprUnary(unop, ref oprnd) => { + hir::ExprKind::Unary(unop, ref oprnd) => { let expected_inner = match unop { hir::UnNot | hir::UnNeg => { expected @@ -3748,7 +3748,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } oprnd_t } - hir::ExprAddrOf(mutbl, ref oprnd) => { + hir::ExprKind::AddrOf(mutbl, ref oprnd) => { let hint = expected.only_has_type(self).map_or(NoExpectation, |ty| { match ty.sty { ty::TyRef(_, ty, _) | ty::TyRawPtr(ty::TypeAndMut { ty, .. }) => { @@ -3788,7 +3788,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { tcx.mk_ref(region, tm) } } - hir::ExprPath(ref qpath) => { + hir::ExprKind::Path(ref qpath) => { let (def, opt_ty, segs) = self.resolve_ty_and_def_ufcs(qpath, expr.id, expr.span); let ty = if def != Def::Err { self.instantiate_value_path(segs, opt_ty, def, expr.span, id) @@ -3804,7 +3804,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { ty } - hir::ExprInlineAsm(_, ref outputs, ref inputs) => { + hir::ExprKind::InlineAsm(_, ref outputs, ref inputs) => { for output in outputs { self.check_expr(output); } @@ -3813,7 +3813,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } tcx.mk_nil() } - hir::ExprBreak(destination, ref expr_opt) => { + hir::ExprKind::Break(destination, ref expr_opt) => { if let Ok(target_id) = destination.target_id { let (e_ty, cause); if let Some(ref e) = *expr_opt { @@ -3886,7 +3886,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // ... except when we try to 'break rust;'. // ICE this expression in particular (see #43162). - if let hir::ExprPath(hir::QPath::Resolved(_, ref path)) = e.node { + if let hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) = e.node { if path.segments.len() == 1 && path.segments[0].ident.name == "rust" { fatally_break_rust(self.tcx.sess); } @@ -3897,7 +3897,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } } - hir::ExprContinue(destination) => { + hir::ExprKind::Continue(destination) => { if let Ok(_) = destination.target_id { tcx.types.never } else { @@ -3905,7 +3905,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { tcx.types.err } } - hir::ExprRet(ref expr_opt) => { + hir::ExprKind::Ret(ref expr_opt) => { if self.ret_coercion.is_none() { struct_span_err!(self.tcx.sess, expr.span, E0572, "return statement outside of function body").emit(); @@ -3918,7 +3918,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } tcx.types.never } - hir::ExprAssign(ref lhs, ref rhs) => { + hir::ExprKind::Assign(ref lhs, ref rhs) => { let lhs_ty = self.check_expr_with_needs(&lhs, Needs::MutPlace); let rhs_ty = self.check_expr_coercable_to_type(&rhs, lhs_ty); @@ -3948,11 +3948,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { tcx.mk_nil() } } - hir::ExprIf(ref cond, ref then_expr, ref opt_else_expr) => { + hir::ExprKind::If(ref cond, ref then_expr, ref opt_else_expr) => { self.check_then_else(&cond, then_expr, opt_else_expr.as_ref().map(|e| &**e), expr.span, expected) } - hir::ExprWhile(ref cond, ref body, _) => { + hir::ExprKind::While(ref cond, ref body, _) => { let ctxt = BreakableCtxt { // cannot use break with a value from a while loop coerce: None, @@ -3976,7 +3976,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { self.tcx.mk_nil() } - hir::ExprLoop(ref body, _, source) => { + hir::ExprKind::Loop(ref body, _, source) => { let coerce = match source { // you can only use break with a value from a normal `loop { }` hir::LoopSource::Loop => { @@ -4016,22 +4016,22 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } ctxt.coerce.map(|c| c.complete(self)).unwrap_or(self.tcx.mk_nil()) } - hir::ExprMatch(ref discrim, ref arms, match_src) => { + hir::ExprKind::Match(ref discrim, ref arms, match_src) => { self.check_match(expr, &discrim, arms, expected, match_src) } - hir::ExprClosure(capture, ref decl, body_id, _, gen) => { + hir::ExprKind::Closure(capture, ref decl, body_id, _, gen) => { self.check_expr_closure(expr, capture, &decl, body_id, gen, expected) } - hir::ExprBlock(ref body, _) => { + hir::ExprKind::Block(ref body, _) => { self.check_block_with_expected(&body, expected) } - hir::ExprCall(ref callee, ref args) => { + hir::ExprKind::Call(ref callee, ref args) => { self.check_call(expr, &callee, args, expected) } - hir::ExprMethodCall(ref segment, span, ref args) => { + hir::ExprKind::MethodCall(ref segment, span, ref args) => { self.check_method_call(expr, segment, span, args, expected, needs) } - hir::ExprCast(ref e, ref t) => { + hir::ExprKind::Cast(ref e, ref t) => { // Find the type of `e`. Supply hints based on the type we are casting to, // if appropriate. let t_cast = self.to_ty(t); @@ -4056,12 +4056,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } } } - hir::ExprType(ref e, ref t) => { + hir::ExprKind::Type(ref e, ref t) => { let ty = self.to_ty(&t); self.check_expr_eq_type(&e, ty); ty } - hir::ExprArray(ref args) => { + hir::ExprKind::Array(ref args) => { let uty = expected.to_option(self).and_then(|uty| { match uty.sty { ty::TyArray(ty, _) | ty::TySlice(ty) => Some(ty), @@ -4085,7 +4085,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { }; tcx.mk_array(element_ty, args.len() as u64) } - hir::ExprRepeat(ref element, ref count) => { + hir::ExprKind::Repeat(ref element, ref count) => { let count_def_id = tcx.hir.local_def_id(count.id); let param_env = ty::ParamEnv::empty(); let substs = Substs::identity_for_item(tcx.global_tcx(), count_def_id); @@ -4148,7 +4148,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { tcx.types.err } } - hir::ExprTup(ref elts) => { + hir::ExprKind::Tup(ref elts) => { let flds = expected.only_has_type(self).and_then(|ty| { let ty = self.resolve_type_vars_with_obligations(ty); match ty.sty { @@ -4178,13 +4178,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { tuple } } - hir::ExprStruct(ref qpath, ref fields, ref base_expr) => { + hir::ExprKind::Struct(ref qpath, ref fields, ref base_expr) => { self.check_expr_struct(expr, expected, qpath, fields, base_expr) } - hir::ExprField(ref base, field) => { + hir::ExprKind::Field(ref base, field) => { self.check_field(expr, needs, &base, field) } - hir::ExprIndex(ref base, ref idx) => { + hir::ExprKind::Index(ref base, ref idx) => { let base_t = self.check_expr_with_needs(&base, needs); let idx_t = self.check_expr(&idx); @@ -4210,7 +4210,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let mut needs_note = true; // If the index is an integer, we can show the actual // fixed expression: - if let hir::ExprLit(ref lit) = idx.node { + if let hir::ExprKind::Lit(ref lit) = idx.node { if let ast::LitKind::Int(i, ast::LitIntType::Unsuffixed) = lit.node { let snip = tcx.sess.codemap().span_to_snippet(base.span); @@ -4233,7 +4233,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } } } - hir::ExprYield(ref value) => { + hir::ExprKind::Yield(ref value) => { match self.yield_ty { Some(ty) => { self.check_expr_coercable_to_type(&value, ty); @@ -4265,7 +4265,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { hir::QPath::TypeRelative(ref qself, ref segment) => { let ty = self.to_ty(qself); - let def = if let hir::TyPath(hir::QPath::Resolved(_, ref path)) = qself.node { + let def = if let hir::TyKind::Path(hir::QPath::Resolved(_, ref path)) = qself.node { path.def } else { Def::Err @@ -4377,15 +4377,15 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { pub fn check_stmt(&self, stmt: &'gcx hir::Stmt) { // Don't do all the complex logic below for DeclItem. match stmt.node { - hir::StmtDecl(ref decl, _) => { + hir::StmtKind::Decl(ref decl, _) => { match decl.node { - hir::DeclLocal(_) => {} - hir::DeclItem(_) => { + hir::DeclKind::Local(_) => {} + hir::DeclKind::Item(_) => { return; } } } - hir::StmtExpr(..) | hir::StmtSemi(..) => {} + hir::StmtKind::Expr(..) | hir::StmtKind::Semi(..) => {} } self.warn_if_unreachable(stmt.node.id(), stmt.span, "statement"); @@ -4397,19 +4397,19 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { self.has_errors.set(false); match stmt.node { - hir::StmtDecl(ref decl, _) => { + hir::StmtKind::Decl(ref decl, _) => { match decl.node { - hir::DeclLocal(ref l) => { + hir::DeclKind::Local(ref l) => { self.check_decl_local(&l); } - hir::DeclItem(_) => {/* ignore for now */} + hir::DeclKind::Item(_) => {/* ignore for now */} } } - hir::StmtExpr(ref expr, _) => { + hir::StmtKind::Expr(ref expr, _) => { // Check with expected type of () self.check_expr_has_type_or_error(&expr, self.tcx.mk_nil()); } - hir::StmtSemi(ref expr, _) => { + hir::StmtKind::Semi(ref expr, _) => { self.check_expr(&expr); } } @@ -4548,7 +4548,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let parent = self.tcx.hir.get(fn_id); if let Node::NodeItem(&hir::Item { - name, node: hir::ItemFn(ref decl, ..), .. + name, node: hir::ItemKind::Fn(ref decl, ..), .. }) = parent { decl.clone().and_then(|decl| { // This is less than ideal, it will not suggest a return type span on any @@ -4641,13 +4641,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // `BlockTailExpression` only relevant if the tail expr would be // useful on its own. match expression.node { - hir::ExprCall(..) | - hir::ExprMethodCall(..) | - hir::ExprIf(..) | - hir::ExprWhile(..) | - hir::ExprLoop(..) | - hir::ExprMatch(..) | - hir::ExprBlock(..) => { + hir::ExprKind::Call(..) | + hir::ExprKind::MethodCall(..) | + hir::ExprKind::If(..) | + hir::ExprKind::While(..) | + hir::ExprKind::Loop(..) | + hir::ExprKind::Match(..) | + hir::ExprKind::Block(..) => { let sp = self.tcx.sess.codemap().next_point(cause_span); err.span_suggestion(sp, "try adding a semicolon", @@ -4733,7 +4733,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { None => return, }; let last_expr = match last_stmt.node { - hir::StmtSemi(ref e, _) => e, + hir::StmtKind::Semi(ref e, _) => e, _ => return, }; let last_expr_ty = self.node_ty(last_expr.hir_id); @@ -5048,7 +5048,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { match self.tcx.hir.get(self.tcx.hir.get_parent_node(node_id)) { Node::NodeExpr(expr) => { match expr.node { - hir::ExprCall(ref callee, ..) => { + hir::ExprKind::Call(ref callee, ..) => { if callee.id == node_id { return } diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs index 0a33252d4cd..46746d4bd29 100644 --- a/src/librustc_typeck/check/op.rs +++ b/src/librustc_typeck/check/op.rs @@ -285,20 +285,20 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } } let missing_trait = match op.node { - hir::BiAdd => Some("std::ops::AddAssign"), - hir::BiSub => Some("std::ops::SubAssign"), - hir::BiMul => Some("std::ops::MulAssign"), - hir::BiDiv => Some("std::ops::DivAssign"), - hir::BiRem => Some("std::ops::RemAssign"), - hir::BiBitAnd => Some("std::ops::BitAndAssign"), - hir::BiBitXor => Some("std::ops::BitXorAssign"), - hir::BiBitOr => Some("std::ops::BitOrAssign"), - hir::BiShl => Some("std::ops::ShlAssign"), - hir::BiShr => Some("std::ops::ShrAssign"), + hir::BinOpKind::Add => Some("std::ops::AddAssign"), + hir::BinOpKind::Sub => Some("std::ops::SubAssign"), + hir::BinOpKind::Mul => Some("std::ops::MulAssign"), + hir::BinOpKind::Div => Some("std::ops::DivAssign"), + hir::BinOpKind::Rem => Some("std::ops::RemAssign"), + hir::BinOpKind::BitAnd => Some("std::ops::BitAndAssign"), + hir::BinOpKind::BitXor => Some("std::ops::BitXorAssign"), + hir::BinOpKind::BitOr => Some("std::ops::BitOrAssign"), + hir::BinOpKind::Shl => Some("std::ops::ShlAssign"), + hir::BinOpKind::Shr => Some("std::ops::ShrAssign"), _ => None }; if let Some(missing_trait) = missing_trait { - if op.node == hir::BiAdd && + if op.node == hir::BinOpKind::Add && self.check_str_addition(expr, lhs_expr, rhs_expr, lhs_ty, rhs_ty, &mut err) { // This has nothing here because it means we did string @@ -353,23 +353,26 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } } let missing_trait = match op.node { - hir::BiAdd => Some("std::ops::Add"), - hir::BiSub => Some("std::ops::Sub"), - hir::BiMul => Some("std::ops::Mul"), - hir::BiDiv => Some("std::ops::Div"), - hir::BiRem => Some("std::ops::Rem"), - hir::BiBitAnd => Some("std::ops::BitAnd"), - hir::BiBitXor => Some("std::ops::BitXor"), - hir::BiBitOr => Some("std::ops::BitOr"), - hir::BiShl => Some("std::ops::Shl"), - hir::BiShr => Some("std::ops::Shr"), - hir::BiEq | hir::BiNe => Some("std::cmp::PartialEq"), - hir::BiLt | hir::BiLe | hir::BiGt | hir::BiGe => - Some("std::cmp::PartialOrd"), - _ => None + hir::BinOpKind::Add => Some("std::ops::Add"), + hir::BinOpKind::Sub => Some("std::ops::Sub"), + hir::BinOpKind::Mul => Some("std::ops::Mul"), + hir::BinOpKind::Div => Some("std::ops::Div"), + hir::BinOpKind::Rem => Some("std::ops::Rem"), + hir::BinOpKind::BitAnd => Some("std::ops::BitAnd"), + hir::BinOpKind::BitXor => Some("std::ops::BitXor"), + hir::BinOpKind::BitOr => Some("std::ops::BitOr"), + hir::BinOpKind::Shl => Some("std::ops::Shl"), + hir::BinOpKind::Shr => Some("std::ops::Shr"), + hir::BinOpKind::Eq | + hir::BinOpKind::Ne => Some("std::cmp::PartialEq"), + hir::BinOpKind::Lt | + hir::BinOpKind::Le | + hir::BinOpKind::Gt | + hir::BinOpKind::Ge => Some("std::cmp::PartialOrd"), + _ => None }; if let Some(missing_trait) = missing_trait { - if op.node == hir::BiAdd && + if op.node == hir::BinOpKind::Add && self.check_str_addition(expr, lhs_expr, rhs_expr, lhs_ty, rhs_ty, &mut err) { // This has nothing here because it means we did string @@ -508,20 +511,20 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { }; let (opname, trait_did) = if let Op::Binary(op, IsAssign::Yes) = op { match op.node { - hir::BiAdd => ("add_assign", lang.add_assign_trait()), - hir::BiSub => ("sub_assign", lang.sub_assign_trait()), - hir::BiMul => ("mul_assign", lang.mul_assign_trait()), - hir::BiDiv => ("div_assign", lang.div_assign_trait()), - hir::BiRem => ("rem_assign", lang.rem_assign_trait()), - hir::BiBitXor => ("bitxor_assign", lang.bitxor_assign_trait()), - hir::BiBitAnd => ("bitand_assign", lang.bitand_assign_trait()), - hir::BiBitOr => ("bitor_assign", lang.bitor_assign_trait()), - hir::BiShl => ("shl_assign", lang.shl_assign_trait()), - hir::BiShr => ("shr_assign", lang.shr_assign_trait()), - hir::BiLt | hir::BiLe | - hir::BiGe | hir::BiGt | - hir::BiEq | hir::BiNe | - hir::BiAnd | hir::BiOr => { + hir::BinOpKind::Add => ("add_assign", lang.add_assign_trait()), + hir::BinOpKind::Sub => ("sub_assign", lang.sub_assign_trait()), + hir::BinOpKind::Mul => ("mul_assign", lang.mul_assign_trait()), + hir::BinOpKind::Div => ("div_assign", lang.div_assign_trait()), + hir::BinOpKind::Rem => ("rem_assign", lang.rem_assign_trait()), + hir::BinOpKind::BitXor => ("bitxor_assign", lang.bitxor_assign_trait()), + hir::BinOpKind::BitAnd => ("bitand_assign", lang.bitand_assign_trait()), + hir::BinOpKind::BitOr => ("bitor_assign", lang.bitor_assign_trait()), + hir::BinOpKind::Shl => ("shl_assign", lang.shl_assign_trait()), + hir::BinOpKind::Shr => ("shr_assign", lang.shr_assign_trait()), + hir::BinOpKind::Lt | hir::BinOpKind::Le | + hir::BinOpKind::Ge | hir::BinOpKind::Gt | + hir::BinOpKind::Eq | hir::BinOpKind::Ne | + hir::BinOpKind::And | hir::BinOpKind::Or => { span_bug!(span, "impossible assignment operation: {}=", op.node.as_str()) @@ -529,23 +532,23 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } } else if let Op::Binary(op, IsAssign::No) = op { match op.node { - hir::BiAdd => ("add", lang.add_trait()), - hir::BiSub => ("sub", lang.sub_trait()), - hir::BiMul => ("mul", lang.mul_trait()), - hir::BiDiv => ("div", lang.div_trait()), - hir::BiRem => ("rem", lang.rem_trait()), - hir::BiBitXor => ("bitxor", lang.bitxor_trait()), - hir::BiBitAnd => ("bitand", lang.bitand_trait()), - hir::BiBitOr => ("bitor", lang.bitor_trait()), - hir::BiShl => ("shl", lang.shl_trait()), - hir::BiShr => ("shr", lang.shr_trait()), - hir::BiLt => ("lt", lang.partial_ord_trait()), - hir::BiLe => ("le", lang.partial_ord_trait()), - hir::BiGe => ("ge", lang.partial_ord_trait()), - hir::BiGt => ("gt", lang.partial_ord_trait()), - hir::BiEq => ("eq", lang.eq_trait()), - hir::BiNe => ("ne", lang.eq_trait()), - hir::BiAnd | hir::BiOr => { + hir::BinOpKind::Add => ("add", lang.add_trait()), + hir::BinOpKind::Sub => ("sub", lang.sub_trait()), + hir::BinOpKind::Mul => ("mul", lang.mul_trait()), + hir::BinOpKind::Div => ("div", lang.div_trait()), + hir::BinOpKind::Rem => ("rem", lang.rem_trait()), + hir::BinOpKind::BitXor => ("bitxor", lang.bitxor_trait()), + hir::BinOpKind::BitAnd => ("bitand", lang.bitand_trait()), + hir::BinOpKind::BitOr => ("bitor", lang.bitor_trait()), + hir::BinOpKind::Shl => ("shl", lang.shl_trait()), + hir::BinOpKind::Shr => ("shr", lang.shr_trait()), + hir::BinOpKind::Lt => ("lt", lang.partial_ord_trait()), + hir::BinOpKind::Le => ("le", lang.partial_ord_trait()), + hir::BinOpKind::Ge => ("ge", lang.partial_ord_trait()), + hir::BinOpKind::Gt => ("gt", lang.partial_ord_trait()), + hir::BinOpKind::Eq => ("eq", lang.eq_trait()), + hir::BinOpKind::Ne => ("ne", lang.eq_trait()), + hir::BinOpKind::And | hir::BinOpKind::Or => { span_bug!(span, "&& and || are not overloadable") } } @@ -608,31 +611,31 @@ enum BinOpCategory { impl BinOpCategory { fn from(op: hir::BinOp) -> BinOpCategory { match op.node { - hir::BiShl | hir::BiShr => + hir::BinOpKind::Shl | hir::BinOpKind::Shr => BinOpCategory::Shift, - hir::BiAdd | - hir::BiSub | - hir::BiMul | - hir::BiDiv | - hir::BiRem => + hir::BinOpKind::Add | + hir::BinOpKind::Sub | + hir::BinOpKind::Mul | + hir::BinOpKind::Div | + hir::BinOpKind::Rem => BinOpCategory::Math, - hir::BiBitXor | - hir::BiBitAnd | - hir::BiBitOr => + hir::BinOpKind::BitXor | + hir::BinOpKind::BitAnd | + hir::BinOpKind::BitOr => BinOpCategory::Bitwise, - hir::BiEq | - hir::BiNe | - hir::BiLt | - hir::BiLe | - hir::BiGe | - hir::BiGt => + hir::BinOpKind::Eq | + hir::BinOpKind::Ne | + hir::BinOpKind::Lt | + hir::BinOpKind::Le | + hir::BinOpKind::Ge | + hir::BinOpKind::Gt => BinOpCategory::Comparison, - hir::BiAnd | - hir::BiOr => + hir::BinOpKind::And | + hir::BinOpKind::Or => BinOpCategory::Shortcircuit, } } diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs index 79ee322d109..8aa5658d291 100644 --- a/src/librustc_typeck/check/regionck.rs +++ b/src/librustc_typeck/check/regionck.rs @@ -495,9 +495,9 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for RegionCtxt<'a, 'gcx, 'tcx> { // provided as arguments outlive the call. if is_method_call { let origin = match expr.node { - hir::ExprMethodCall(..) => + hir::ExprKind::MethodCall(..) => infer::ParameterOrigin::MethodCall, - hir::ExprUnary(op, _) if op == hir::UnDeref => + hir::ExprKind::Unary(op, _) if op == hir::UnDeref => infer::ParameterOrigin::OverloadedDeref, _ => infer::ParameterOrigin::OverloadedOperator @@ -525,13 +525,13 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for RegionCtxt<'a, 'gcx, 'tcx> { debug!("regionck::visit_expr(e={:?}, repeating_scope={}) - visiting subexprs", expr, self.repeating_scope); match expr.node { - hir::ExprPath(_) => { + hir::ExprKind::Path(_) => { let substs = self.tables.borrow().node_substs(expr.hir_id); let origin = infer::ParameterOrigin::Path; self.substs_wf_in_scope(origin, substs, expr.span, expr_region); } - hir::ExprCall(ref callee, ref args) => { + hir::ExprKind::Call(ref callee, ref args) => { if is_method_call { self.constrain_call(expr, Some(&callee), args.iter().map(|e| &*e)); } else { @@ -542,13 +542,13 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for RegionCtxt<'a, 'gcx, 'tcx> { intravisit::walk_expr(self, expr); } - hir::ExprMethodCall(.., ref args) => { + hir::ExprKind::MethodCall(.., ref args) => { self.constrain_call(expr, Some(&args[0]), args[1..].iter().map(|e| &*e)); intravisit::walk_expr(self, expr); } - hir::ExprAssignOp(_, ref lhs, ref rhs) => { + hir::ExprKind::AssignOp(_, ref lhs, ref rhs) => { if is_method_call { self.constrain_call(expr, Some(&lhs), Some(&**rhs).into_iter()); } @@ -556,20 +556,20 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for RegionCtxt<'a, 'gcx, 'tcx> { intravisit::walk_expr(self, expr); } - hir::ExprIndex(ref lhs, ref rhs) if is_method_call => { + hir::ExprKind::Index(ref lhs, ref rhs) if is_method_call => { self.constrain_call(expr, Some(&lhs), Some(&**rhs).into_iter()); intravisit::walk_expr(self, expr); }, - hir::ExprBinary(_, ref lhs, ref rhs) if is_method_call => { - // As `ExprMethodCall`, but the call is via an overloaded op. + hir::ExprKind::Binary(_, ref lhs, ref rhs) if is_method_call => { + // As `ExprKind::MethodCall`, but the call is via an overloaded op. self.constrain_call(expr, Some(&lhs), Some(&**rhs).into_iter()); intravisit::walk_expr(self, expr); } - hir::ExprBinary(_, ref lhs, ref rhs) => { + hir::ExprKind::Binary(_, ref lhs, ref rhs) => { // If you do `x OP y`, then the types of `x` and `y` must // outlive the operation you are performing. let lhs_ty = self.resolve_expr_type_adjusted(&lhs); @@ -581,7 +581,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for RegionCtxt<'a, 'gcx, 'tcx> { intravisit::walk_expr(self, expr); } - hir::ExprUnary(hir::UnDeref, ref base) => { + hir::ExprKind::Unary(hir::UnDeref, ref base) => { // For *a, the lifetime of a must enclose the deref if is_method_call { self.constrain_call(expr, Some(base), None::<hir::Expr>.iter()); @@ -596,14 +596,14 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for RegionCtxt<'a, 'gcx, 'tcx> { intravisit::walk_expr(self, expr); } - hir::ExprUnary(_, ref lhs) if is_method_call => { + hir::ExprKind::Unary(_, ref lhs) if is_method_call => { // As above. self.constrain_call(expr, Some(&lhs), None::<hir::Expr>.iter()); intravisit::walk_expr(self, expr); } - hir::ExprIndex(ref vec_expr, _) => { + hir::ExprKind::Index(ref vec_expr, _) => { // For a[b], the lifetime of a must enclose the deref let vec_type = self.resolve_expr_type_adjusted(&vec_expr); self.constrain_index(expr, vec_type); @@ -611,7 +611,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for RegionCtxt<'a, 'gcx, 'tcx> { intravisit::walk_expr(self, expr); } - hir::ExprCast(ref source, _) => { + hir::ExprKind::Cast(ref source, _) => { // Determine if we are casting `source` to a trait // instance. If so, we have to be sure that the type of // the source obeys the trait's region bound. @@ -619,7 +619,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for RegionCtxt<'a, 'gcx, 'tcx> { intravisit::walk_expr(self, expr); } - hir::ExprAddrOf(m, ref base) => { + hir::ExprKind::AddrOf(m, ref base) => { self.link_addr_of(expr, m, &base); // Require that when you write a `&expr` expression, the @@ -635,23 +635,23 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for RegionCtxt<'a, 'gcx, 'tcx> { intravisit::walk_expr(self, expr); } - hir::ExprMatch(ref discr, ref arms, _) => { + hir::ExprKind::Match(ref discr, ref arms, _) => { self.link_match(&discr, &arms[..]); intravisit::walk_expr(self, expr); } - hir::ExprClosure(.., body_id, _, _) => { + hir::ExprKind::Closure(.., body_id, _, _) => { self.check_expr_fn_block(expr, body_id); } - hir::ExprLoop(ref body, _, _) => { + hir::ExprKind::Loop(ref body, _, _) => { let repeating_scope = self.set_repeating_scope(body.id); intravisit::walk_expr(self, expr); self.set_repeating_scope(repeating_scope); } - hir::ExprWhile(ref cond, ref body, _) => { + hir::ExprKind::While(ref cond, ref body, _) => { let repeating_scope = self.set_repeating_scope(cond.id); self.visit_expr(&cond); @@ -661,9 +661,9 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for RegionCtxt<'a, 'gcx, 'tcx> { self.set_repeating_scope(repeating_scope); } - hir::ExprRet(Some(ref ret_expr)) => { + hir::ExprKind::Ret(Some(ref ret_expr)) => { let call_site_scope = self.call_site_scope; - debug!("visit_expr ExprRet ret_expr.id {} call_site_scope: {:?}", + debug!("visit_expr ExprKind::Ret ret_expr.id {} call_site_scope: {:?}", ret_expr.id, call_site_scope); let call_site_region = self.tcx.mk_region(ty::ReScope(call_site_scope.unwrap())); self.type_of_node_must_outlive(infer::CallReturn(ret_expr.span), diff --git a/src/librustc_typeck/check/upvar.rs b/src/librustc_typeck/check/upvar.rs index e24269bca57..61fe90be217 100644 --- a/src/librustc_typeck/check/upvar.rs +++ b/src/librustc_typeck/check/upvar.rs @@ -74,7 +74,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for InferBorrowKindVisitor<'a, 'gcx, 'tcx> { fn visit_expr(&mut self, expr: &'gcx hir::Expr) { match expr.node { - hir::ExprClosure(cc, _, body_id, _, _) => { + hir::ExprKind::Closure(cc, _, body_id, _, _) => { let body = self.fcx.tcx.hir.body(body_id); self.visit_body(body); self.fcx diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index 85fdcd417ff..d876f41ce13 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -97,7 +97,7 @@ pub fn check_item_well_formed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: Def // // won't be allowed unless there's an *explicit* implementation of `Send` // for `T` - hir::ItemImpl(_, polarity, defaultness, _, ref trait_ref, ref self_ty, _) => { + hir::ItemKind::Impl(_, polarity, defaultness, _, ref trait_ref, ref self_ty, _) => { let is_auto = tcx.impl_trait_ref(tcx.hir.local_def_id(item.id)) .map_or(false, |trait_ref| tcx.trait_is_auto(trait_ref.def_id)); if let (hir::Defaultness::Default { .. }, true) = (defaultness, is_auto) { @@ -114,37 +114,37 @@ pub fn check_item_well_formed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: Def } } } - hir::ItemFn(..) => { + hir::ItemKind::Fn(..) => { check_item_fn(tcx, item); } - hir::ItemStatic(..) => { + hir::ItemKind::Static(..) => { check_item_type(tcx, item); } - hir::ItemConst(..) => { + hir::ItemKind::Const(..) => { check_item_type(tcx, item); } - hir::ItemStruct(ref struct_def, ref ast_generics) => { + hir::ItemKind::Struct(ref struct_def, ref ast_generics) => { check_type_defn(tcx, item, false, |fcx| { vec![fcx.non_enum_variant(struct_def)] }); check_variances_for_type_defn(tcx, item, ast_generics); } - hir::ItemUnion(ref struct_def, ref ast_generics) => { + hir::ItemKind::Union(ref struct_def, ref ast_generics) => { check_type_defn(tcx, item, true, |fcx| { vec![fcx.non_enum_variant(struct_def)] }); check_variances_for_type_defn(tcx, item, ast_generics); } - hir::ItemEnum(ref enum_def, ref ast_generics) => { + hir::ItemKind::Enum(ref enum_def, ref ast_generics) => { check_type_defn(tcx, item, true, |fcx| { fcx.enum_variants(enum_def) }); check_variances_for_type_defn(tcx, item, ast_generics); } - hir::ItemTrait(..) => { + hir::ItemKind::Trait(..) => { check_trait(tcx, item); } _ => {} diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index b7233217d5f..3207ac44948 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -117,7 +117,8 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> { // operating on scalars, we clear the overload. fn fix_scalar_builtin_expr(&mut self, e: &hir::Expr) { match e.node { - hir::ExprUnary(hir::UnNeg, ref inner) | hir::ExprUnary(hir::UnNot, ref inner) => { + hir::ExprKind::Unary(hir::UnNeg, ref inner) | + hir::ExprKind::Unary(hir::UnNot, ref inner) => { let inner_ty = self.fcx.node_ty(inner.hir_id); let inner_ty = self.fcx.resolve_type_vars_if_possible(&inner_ty); @@ -127,8 +128,8 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> { tables.node_substs_mut().remove(e.hir_id); } } - hir::ExprBinary(ref op, ref lhs, ref rhs) - | hir::ExprAssignOp(ref op, ref lhs, ref rhs) => { + hir::ExprKind::Binary(ref op, ref lhs, ref rhs) + | hir::ExprKind::AssignOp(ref op, ref lhs, ref rhs) => { let lhs_ty = self.fcx.node_ty(lhs.hir_id); let lhs_ty = self.fcx.resolve_type_vars_if_possible(&lhs_ty); @@ -141,14 +142,14 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> { tables.node_substs_mut().remove(e.hir_id); match e.node { - hir::ExprBinary(..) => { + hir::ExprKind::Binary(..) => { if !op.node.is_by_value() { let mut adjustments = tables.adjustments_mut(); adjustments.get_mut(lhs.hir_id).map(|a| a.pop()); adjustments.get_mut(rhs.hir_id).map(|a| a.pop()); } } - hir::ExprAssignOp(..) => { + hir::ExprKind::AssignOp(..) => { tables .adjustments_mut() .get_mut(lhs.hir_id) @@ -167,7 +168,7 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> { // to use builtin indexing because the index type is known to be // usize-ish fn fix_index_builtin_expr(&mut self, e: &hir::Expr) { - if let hir::ExprIndex(ref base, ref index) = e.node { + if let hir::ExprKind::Index(ref base, ref index) = e.node { let mut tables = self.fcx.tables.borrow_mut(); match tables.expr_ty_adjusted(&base).sty { @@ -227,7 +228,7 @@ impl<'cx, 'gcx, 'tcx> Visitor<'gcx> for WritebackCx<'cx, 'gcx, 'tcx> { self.visit_node_id(e.span, e.hir_id); match e.node { - hir::ExprClosure(_, _, body, _, _) => { + hir::ExprKind::Closure(_, _, body, _, _) => { let body = self.fcx.tcx.hir.body(body); for arg in &body.arguments { self.visit_node_id(e.span, arg.hir_id); @@ -235,12 +236,12 @@ impl<'cx, 'gcx, 'tcx> Visitor<'gcx> for WritebackCx<'cx, 'gcx, 'tcx> { self.visit_body(body); } - hir::ExprStruct(_, ref fields, _) => { + hir::ExprKind::Struct(_, ref fields, _) => { for field in fields { self.visit_field_id(field.id); } } - hir::ExprField(..) => { + hir::ExprKind::Field(..) => { self.visit_field_id(e.id); } _ => {} diff --git a/src/librustc_typeck/check_unused.rs b/src/librustc_typeck/check_unused.rs index 3a8ed0ea25f..1a57dfd745e 100644 --- a/src/librustc_typeck/check_unused.rs +++ b/src/librustc_typeck/check_unused.rs @@ -42,7 +42,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for CheckVisitor<'a, 'tcx> { if item.vis.node.is_pub() || item.span.is_dummy() { return; } - if let hir::ItemUse(ref path, _) = item.node { + if let hir::ItemKind::Use(ref path, _) = item.node { self.check_import(item.id, path.span); } } @@ -196,7 +196,7 @@ struct ExternCrateToLint { impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for CollectExternCrateVisitor<'a, 'tcx> { fn visit_item(&mut self, item: &hir::Item) { - if let hir::ItemExternCrate(orig_name) = item.node { + if let hir::ItemKind::ExternCrate(orig_name) = item.node { let extern_crate_def_id = self.tcx.hir.local_def_id(item.id); self.crates_to_lint.push( ExternCrateToLint { diff --git a/src/librustc_typeck/coherence/builtin.rs b/src/librustc_typeck/coherence/builtin.rs index 393904583ca..4d9a4a03a6b 100644 --- a/src/librustc_typeck/coherence/builtin.rs +++ b/src/librustc_typeck/coherence/builtin.rs @@ -24,7 +24,7 @@ use rustc::infer; use rustc::hir::def_id::DefId; use rustc::hir::map as hir_map; -use rustc::hir::{self, ItemImpl}; +use rustc::hir::{self, ItemKind}; pub fn check_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, trait_def_id: DefId) { Checker { tcx, trait_def_id } @@ -64,7 +64,7 @@ fn visit_implementation_of_drop<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, match tcx.hir.find(impl_node_id) { Some(hir_map::NodeItem(item)) => { let span = match item.node { - ItemImpl(.., ref ty, _) => ty.span, + ItemKind::Impl(.., ref ty, _) => ty.span, _ => item.span, }; struct_span_err!(tcx.sess, @@ -115,7 +115,7 @@ fn visit_implementation_of_copy<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, Ok(()) => {} Err(CopyImplementationError::InfrigingFields(fields)) => { let item = tcx.hir.expect_item(impl_node_id); - let span = if let ItemImpl(.., Some(ref tr), _, _) = item.node { + let span = if let ItemKind::Impl(.., Some(ref tr), _, _) = item.node { tr.path.span } else { span @@ -132,7 +132,7 @@ fn visit_implementation_of_copy<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } Err(CopyImplementationError::NotAnAdt) => { let item = tcx.hir.expect_item(impl_node_id); - let span = if let ItemImpl(.., ref ty, _) = item.node { + let span = if let ItemKind::Impl(.., ref ty, _) = item.node { ty.span } else { span @@ -336,7 +336,7 @@ pub fn coerce_unsized_info<'a, 'gcx>(gcx: TyCtxt<'a, 'gcx, 'gcx>, return err_info; } else if diff_fields.len() > 1 { let item = gcx.hir.expect_item(impl_node_id); - let span = if let ItemImpl(.., Some(ref t), _, _) = item.node { + let span = if let ItemKind::Impl(.., Some(ref t), _, _) = item.node { t.path.span } else { gcx.hir.span(impl_node_id) diff --git a/src/librustc_typeck/coherence/inherent_impls.rs b/src/librustc_typeck/coherence/inherent_impls.rs index 532f1da4f30..02a18fa47df 100644 --- a/src/librustc_typeck/coherence/inherent_impls.rs +++ b/src/librustc_typeck/coherence/inherent_impls.rs @@ -94,7 +94,7 @@ struct InherentCollect<'a, 'tcx: 'a> { impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> { fn visit_item(&mut self, item: &hir::Item) { let ty = match item.node { - hir::ItemImpl(.., None, ref ty, _) => ty, + hir::ItemKind::Impl(.., None, ref ty, _) => ty, _ => return }; diff --git a/src/librustc_typeck/coherence/inherent_impls_overlap.rs b/src/librustc_typeck/coherence/inherent_impls_overlap.rs index 6a346b02b79..c0260d6714d 100644 --- a/src/librustc_typeck/coherence/inherent_impls_overlap.rs +++ b/src/librustc_typeck/coherence/inherent_impls_overlap.rs @@ -122,10 +122,10 @@ impl<'a, 'tcx> InherentOverlapChecker<'a, 'tcx> { impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentOverlapChecker<'a, 'tcx> { fn visit_item(&mut self, item: &'v hir::Item) { match item.node { - hir::ItemEnum(..) | - hir::ItemStruct(..) | - hir::ItemTrait(..) | - hir::ItemUnion(..) => { + hir::ItemKind::Enum(..) | + hir::ItemKind::Struct(..) | + hir::ItemKind::Trait(..) | + hir::ItemKind::Union(..) => { let type_def_id = self.tcx.hir.local_def_id(item.id); self.check_for_overlapping_inherent_impls(type_def_id); } diff --git a/src/librustc_typeck/coherence/orphan.rs b/src/librustc_typeck/coherence/orphan.rs index 6d6594e5543..9be509b3588 100644 --- a/src/librustc_typeck/coherence/orphan.rs +++ b/src/librustc_typeck/coherence/orphan.rs @@ -34,7 +34,7 @@ impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for OrphanChecker<'cx, 'tcx> { fn visit_item(&mut self, item: &hir::Item) { let def_id = self.tcx.hir.local_def_id(item.id); match item.node { - hir::ItemImpl(.., Some(_), _, _) => { + hir::ItemKind::Impl(.., Some(_), _, _) => { // "Trait" impl debug!("coherence2::orphan check: trait impl {}", self.tcx.hir.node_to_string(item.id)); diff --git a/src/librustc_typeck/coherence/unsafety.rs b/src/librustc_typeck/coherence/unsafety.rs index 5a442881a63..9e19854a571 100644 --- a/src/librustc_typeck/coherence/unsafety.rs +++ b/src/librustc_typeck/coherence/unsafety.rs @@ -84,7 +84,7 @@ impl<'cx, 'tcx, 'v> UnsafetyChecker<'cx, 'tcx> { impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for UnsafetyChecker<'cx, 'tcx> { fn visit_item(&mut self, item: &'v hir::Item) { match item.node { - hir::ItemImpl(unsafety, polarity, _, ref generics, ..) => { + hir::ItemKind::Impl(unsafety, polarity, _, ref generics, ..) => { self.check_unsafety_coherence(item, Some(generics), unsafety, polarity); } _ => {} diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 5fa98e3ebe6..4b628d6ffad 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -129,7 +129,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CollectItemTypesVisitor<'a, 'tcx> { } fn visit_expr(&mut self, expr: &'tcx hir::Expr) { - if let hir::ExprClosure(..) = expr.node { + if let hir::ExprKind::Closure(..) = expr.node { let def_id = self.tcx.hir.local_def_id(expr.id); self.tcx.generics_of(def_id); self.tcx.type_of(def_id); @@ -266,13 +266,13 @@ fn type_param_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, NodeItem(item) => { match item.node { - ItemFn(.., ref generics, _) | - ItemImpl(_, _, _, ref generics, ..) | - ItemTy(_, ref generics) | - ItemEnum(_, ref generics) | - ItemStruct(_, ref generics) | - ItemUnion(_, ref generics) => generics, - ItemTrait(_, _, ref generics, ..) => { + ItemKind::Fn(.., ref generics, _) | + ItemKind::Impl(_, _, _, ref generics, ..) | + ItemKind::Ty(_, ref generics) | + ItemKind::Enum(_, ref generics) | + ItemKind::Struct(_, ref generics) | + ItemKind::Union(_, ref generics) => generics, + ItemKind::Trait(_, _, ref generics, ..) => { // Implied `Self: Trait` and supertrait bounds. if param_id == item_node_id { result.predicates.push( @@ -287,7 +287,7 @@ fn type_param_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, NodeForeignItem(item) => { match item.node { - ForeignItemFn(_, _, ref generics) => generics, + ForeignItemKind::Fn(_, _, ref generics) => generics, _ => return result } } @@ -346,7 +346,7 @@ fn is_param<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, param_id: ast::NodeId) -> bool { - if let hir::TyPath(hir::QPath::Resolved(None, ref path)) = ast_ty.node { + if let hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) = ast_ty.node { match path.def { Def::SelfTy(Some(def_id), None) | Def::TyParam(def_id) => { @@ -365,45 +365,45 @@ fn convert_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: ast::NodeId) { let def_id = tcx.hir.local_def_id(item_id); match it.node { // These don't define types. - hir::ItemExternCrate(_) | - hir::ItemUse(..) | - hir::ItemMod(_) | - hir::ItemGlobalAsm(_) => {} - hir::ItemForeignMod(ref foreign_mod) => { + hir::ItemKind::ExternCrate(_) | + hir::ItemKind::Use(..) | + hir::ItemKind::Mod(_) | + hir::ItemKind::GlobalAsm(_) => {} + hir::ItemKind::ForeignMod(ref foreign_mod) => { for item in &foreign_mod.items { let def_id = tcx.hir.local_def_id(item.id); tcx.generics_of(def_id); tcx.type_of(def_id); tcx.predicates_of(def_id); - if let hir::ForeignItemFn(..) = item.node { + if let hir::ForeignItemKind::Fn(..) = item.node { tcx.fn_sig(def_id); } } } - hir::ItemEnum(ref enum_definition, _) => { + hir::ItemKind::Enum(ref enum_definition, _) => { tcx.generics_of(def_id); tcx.type_of(def_id); tcx.predicates_of(def_id); convert_enum_variant_types(tcx, def_id, &enum_definition.variants); }, - hir::ItemImpl(..) => { + hir::ItemKind::Impl(..) => { tcx.generics_of(def_id); tcx.type_of(def_id); tcx.impl_trait_ref(def_id); tcx.predicates_of(def_id); }, - hir::ItemTrait(..) => { + hir::ItemKind::Trait(..) => { tcx.generics_of(def_id); tcx.trait_def(def_id); tcx.at(it.span).super_predicates_of(def_id); tcx.predicates_of(def_id); }, - hir::ItemTraitAlias(..) => { + hir::ItemKind::TraitAlias(..) => { span_err!(tcx.sess, it.span, E0645, "trait aliases are not yet implemented (see issue #41517)"); }, - hir::ItemStruct(ref struct_def, _) | - hir::ItemUnion(ref struct_def, _) => { + hir::ItemKind::Struct(ref struct_def, _) | + hir::ItemKind::Union(ref struct_def, _) => { tcx.generics_of(def_id); tcx.type_of(def_id); tcx.predicates_of(def_id); @@ -419,12 +419,15 @@ fn convert_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: ast::NodeId) { convert_variant_ctor(tcx, struct_def.id()); } }, - hir::ItemExistential(..) => {} - hir::ItemTy(..) | hir::ItemStatic(..) | hir::ItemConst(..) | hir::ItemFn(..) => { + hir::ItemKind::Existential(..) => {} + hir::ItemKind::Ty(..) | + hir::ItemKind::Static(..) | + hir::ItemKind::Const(..) | + hir::ItemKind::Fn(..) => { tcx.generics_of(def_id); tcx.type_of(def_id); tcx.predicates_of(def_id); - if let hir::ItemFn(..) = it.node { + if let hir::ItemKind::Fn(..) = it.node { tcx.fn_sig(def_id); } } @@ -561,7 +564,7 @@ fn adt_def<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let repr = ReprOptions::new(tcx, def_id); let (kind, variants) = match item.node { - ItemEnum(ref def, _) => { + ItemKind::Enum(ref def, _) => { let mut distance_from_explicit = 0; (AdtKind::Enum, def.variants.iter().map(|v| { let did = tcx.hir.local_def_id(v.node.data.id()); @@ -576,7 +579,7 @@ fn adt_def<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, convert_struct_variant(tcx, did, v.node.name, discr, &v.node.data) }).collect()) } - ItemStruct(ref def, _) => { + ItemKind::Struct(ref def, _) => { // Use separate constructor id for unit/tuple structs and reuse did for braced structs. let ctor_id = if !def.is_struct() { Some(tcx.hir.local_def_id(def.id())) @@ -588,7 +591,7 @@ fn adt_def<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty::VariantDiscr::Relative(0), def) ]) } - ItemUnion(ref def, _) => { + ItemKind::Union(ref def, _) => { (AdtKind::Union, vec![ convert_struct_variant(tcx, def_id, item.name, ty::VariantDiscr::Relative(0), def) @@ -614,8 +617,8 @@ fn super_predicates_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, }; let (generics, bounds) = match item.node { - hir::ItemTrait(.., ref generics, ref supertraits, _) => (generics, supertraits), - hir::ItemTraitAlias(ref generics, ref supertraits) => (generics, supertraits), + hir::ItemKind::Trait(.., ref generics, ref supertraits, _) => (generics, supertraits), + hir::ItemKind::TraitAlias(ref generics, ref supertraits) => (generics, supertraits), _ => span_bug!(item.span, "super_predicates invoked on non-trait"), }; @@ -658,8 +661,8 @@ fn trait_def<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let item = tcx.hir.expect_item(node_id); let (is_auto, unsafety) = match item.node { - hir::ItemTrait(is_auto, unsafety, ..) => (is_auto == hir::IsAuto::Yes, unsafety), - hir::ItemTraitAlias(..) => (false, hir::Unsafety::Normal), + hir::ItemKind::Trait(is_auto, unsafety, ..) => (is_auto == hir::IsAuto::Yes, unsafety), + hir::ItemKind::TraitAlias(..) => (false, hir::Unsafety::Normal), _ => span_bug!(item.span, "trait_def_of_item invoked on non-trait"), }; @@ -701,7 +704,7 @@ fn has_late_bound_regions<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn visit_ty(&mut self, ty: &'tcx hir::Ty) { if self.has_late_bound_regions.is_some() { return } match ty.node { - hir::TyBareFn(..) => { + hir::TyKind::BareFn(..) => { self.outer_index.shift_in(1); intravisit::walk_ty(self, ty); self.outer_index.shift_out(1); @@ -774,12 +777,12 @@ fn has_late_bound_regions<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, _ => None, }, hir_map::NodeForeignItem(item) => match item.node { - hir::ForeignItemFn(ref fn_decl, _, ref generics) => + hir::ForeignItemKind::Fn(ref fn_decl, _, ref generics) => has_late_bound_regions(tcx, generics, fn_decl), _ => None, }, hir_map::NodeItem(item) => match item.node { - hir::ItemFn(ref fn_decl, .., ref generics, _) => + hir::ItemKind::Fn(ref fn_decl, .., ref generics, _) => has_late_bound_regions(tcx, generics, fn_decl), _ => None, }, @@ -805,12 +808,12 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let parent_id = tcx.hir.get_parent(node_id); Some(tcx.hir.local_def_id(parent_id)) } - NodeExpr(&hir::Expr { node: hir::ExprClosure(..), .. }) => { + NodeExpr(&hir::Expr { node: hir::ExprKind::Closure(..), .. }) => { Some(tcx.closure_base_def_id(def_id)) } NodeItem(item) => { match item.node { - ItemExistential(hir::ExistTy { impl_trait_fn, .. }) => impl_trait_fn, + ItemKind::Existential(hir::ExistTy { impl_trait_fn, .. }) => impl_trait_fn, _ => None, } }, @@ -828,19 +831,20 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, NodeItem(item) => { match item.node { - ItemFn(.., ref generics, _) | - ItemImpl(_, _, _, ref generics, ..) => generics, - - ItemTy(_, ref generics) | - ItemEnum(_, ref generics) | - ItemStruct(_, ref generics) | - ItemExistential(hir::ExistTy { ref generics, .. }) | - ItemUnion(_, ref generics) => { + ItemKind::Fn(.., ref generics, _) | + ItemKind::Impl(_, _, _, ref generics, ..) => generics, + + ItemKind::Ty(_, ref generics) | + ItemKind::Enum(_, ref generics) | + ItemKind::Struct(_, ref generics) | + ItemKind::Existential(hir::ExistTy { ref generics, .. }) | + ItemKind::Union(_, ref generics) => { allow_defaults = true; generics } - ItemTrait(_, _, ref generics, ..) | ItemTraitAlias(ref generics, ..) => { + ItemKind::Trait(_, _, ref generics, ..) | + ItemKind::TraitAlias(ref generics, ..) => { // Add in the self type parameter. // // Something of a hack: use the node id for the trait, also as @@ -869,9 +873,9 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, NodeForeignItem(item) => { match item.node { - ForeignItemStatic(..) => &no_generics, - ForeignItemFn(_, _, ref generics) => generics, - ForeignItemType => &no_generics, + ForeignItemKind::Static(..) => &no_generics, + ForeignItemKind::Fn(_, _, ref generics) => generics, + ForeignItemKind::Type => &no_generics, } } @@ -946,7 +950,7 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, // provide junk type parameter defs - the only place that // cares about anything but the length is instantiation, // and we don't do that for closures. - if let NodeExpr(&hir::Expr { node: hir::ExprClosure(.., gen), .. }) = node { + if let NodeExpr(&hir::Expr { node: hir::ExprKind::Closure(.., gen), .. }) = node { let dummy_args = if gen.is_some() { &["<yield_ty>", "<return_ty>", "<witness>"][..] } else { @@ -1043,33 +1047,33 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, NodeItem(item) => { match item.node { - ItemStatic(ref t, ..) | ItemConst(ref t, _) | - ItemTy(ref t, _) | ItemImpl(.., ref t, _) => { + ItemKind::Static(ref t, ..) | ItemKind::Const(ref t, _) | + ItemKind::Ty(ref t, _) | ItemKind::Impl(.., ref t, _) => { icx.to_ty(t) } - ItemFn(..) => { + ItemKind::Fn(..) => { let substs = Substs::identity_for_item(tcx, def_id); tcx.mk_fn_def(def_id, substs) } - ItemEnum(..) | - ItemStruct(..) | - ItemUnion(..) => { + ItemKind::Enum(..) | + ItemKind::Struct(..) | + ItemKind::Union(..) => { let def = tcx.adt_def(def_id); let substs = Substs::identity_for_item(tcx, def_id); tcx.mk_adt(def, substs) } // this is only reachable once we have named existential types - ItemExistential(hir::ExistTy { impl_trait_fn: None, .. }) => unimplemented!(), + ItemKind::Existential(hir::ExistTy { impl_trait_fn: None, .. }) => unimplemented!(), // existential types desugared from impl Trait - ItemExistential(hir::ExistTy { impl_trait_fn: Some(owner), .. }) => { + ItemKind::Existential(hir::ExistTy { impl_trait_fn: Some(owner), .. }) => { tcx.typeck_tables_of(owner).concrete_existential_types[&def_id] }, - ItemTrait(..) | ItemTraitAlias(..) | - ItemMod(..) | - ItemForeignMod(..) | - ItemGlobalAsm(..) | - ItemExternCrate(..) | - ItemUse(..) => { + ItemKind::Trait(..) | ItemKind::TraitAlias(..) | + ItemKind::Mod(..) | + ItemKind::ForeignMod(..) | + ItemKind::GlobalAsm(..) | + ItemKind::ExternCrate(..) | + ItemKind::Use(..) => { span_bug!( item.span, "compute_type_of_item: unexpected item type: {:?}", @@ -1080,17 +1084,17 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, NodeForeignItem(foreign_item) => { match foreign_item.node { - ForeignItemFn(..) => { + ForeignItemKind::Fn(..) => { let substs = Substs::identity_for_item(tcx, def_id); tcx.mk_fn_def(def_id, substs) } - ForeignItemStatic(ref t, _) => icx.to_ty(t), - ForeignItemType => tcx.mk_foreign(def_id), + ForeignItemKind::Static(ref t, _) => icx.to_ty(t), + ForeignItemKind::Type => tcx.mk_foreign(def_id), } } NodeStructCtor(&ref def) | - NodeVariant(&Spanned { node: hir::Variant_ { data: ref def, .. }, .. }) => { + NodeVariant(&Spanned { node: hir::VariantKind { data: ref def, .. }, .. }) => { match *def { VariantData::Unit(..) | VariantData::Struct(..) => { tcx.type_of(tcx.hir.get_parent_did(node_id)) @@ -1104,7 +1108,7 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, NodeField(field) => icx.to_ty(&field.ty), - NodeExpr(&hir::Expr { node: hir::ExprClosure(.., gen), .. }) => { + NodeExpr(&hir::Expr { node: hir::ExprKind::Closure(.., gen), .. }) => { if gen.is_some() { let hir_id = tcx.hir.node_to_hir_id(node_id); return tcx.typeck_tables_of(def_id).node_id_to_type(hir_id); @@ -1118,12 +1122,12 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } NodeAnonConst(_) => match tcx.hir.get(tcx.hir.get_parent_node(node_id)) { - NodeTy(&hir::Ty { node: TyArray(_, ref constant), .. }) | - NodeTy(&hir::Ty { node: TyTypeof(ref constant), .. }) | - NodeExpr(&hir::Expr { node: ExprRepeat(_, ref constant), .. }) + NodeTy(&hir::Ty { node: hir::TyKind::Array(_, ref constant), .. }) | + NodeTy(&hir::Ty { node: hir::TyKind::Typeof(ref constant), .. }) | + NodeExpr(&hir::Expr { node: ExprKind::Repeat(_, ref constant), .. }) if constant.id == node_id => tcx.types.usize, - NodeVariant(&Spanned { node: Variant_ { disr_expr: Some(ref e), .. }, .. }) + NodeVariant(&Spanned { node: VariantKind { disr_expr: Some(ref e), .. }, .. }) if e.id == node_id => { tcx.adt_def(tcx.hir.get_parent_did(node_id)) .repr.discr_type().to_ty(tcx) @@ -1165,17 +1169,17 @@ fn fn_sig<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, AstConv::ty_of_fn(&icx, sig.header.unsafety, sig.header.abi, &sig.decl) } - NodeItem(hir::Item { node: ItemFn(decl, header, _, _), .. }) => { + NodeItem(hir::Item { node: ItemKind::Fn(decl, header, _, _), .. }) => { AstConv::ty_of_fn(&icx, header.unsafety, header.abi, decl) } - NodeForeignItem(&hir::ForeignItem { node: ForeignItemFn(ref fn_decl, _, _), .. }) => { + NodeForeignItem(&hir::ForeignItem { node: ForeignItemKind::Fn(ref fn_decl, _, _), .. }) => { let abi = tcx.hir.get_foreign_abi(node_id); compute_sig_of_foreign_fn_decl(tcx, def_id, fn_decl, abi) } NodeStructCtor(&VariantData::Tuple(ref fields, _)) | - NodeVariant(&Spanned { node: hir::Variant_ { + NodeVariant(&Spanned { node: hir::VariantKind { data: VariantData::Tuple(ref fields, _), .. }, .. }) => { let ty = tcx.type_of(tcx.hir.get_parent_did(node_id)); @@ -1191,7 +1195,7 @@ fn fn_sig<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, )) } - NodeExpr(&hir::Expr { node: hir::ExprClosure(..), .. }) => { + NodeExpr(&hir::Expr { node: hir::ExprKind::Closure(..), .. }) => { // Closure signatures are not like other function // signatures and cannot be accessed through `fn_sig`. For // example, a closure signature excludes the `self` @@ -1223,7 +1227,7 @@ fn impl_trait_ref<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let node_id = tcx.hir.as_local_node_id(def_id).unwrap(); match tcx.hir.expect_item(node_id).node { - hir::ItemImpl(.., ref opt_trait_ref, _, _) => { + hir::ItemKind::Impl(.., ref opt_trait_ref, _, _) => { opt_trait_ref.as_ref().map(|ast_trait_ref| { let selfty = tcx.type_of(def_id); AstConv::instantiate_mono_trait_ref(&icx, ast_trait_ref, selfty) @@ -1238,7 +1242,7 @@ fn impl_polarity<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, -> hir::ImplPolarity { let node_id = tcx.hir.as_local_node_id(def_id).unwrap(); match tcx.hir.expect_item(node_id).node { - hir::ItemImpl(_, polarity, ..) => polarity, + hir::ItemKind::Impl(_, polarity, ..) => polarity, ref item => bug!("impl_polarity: {:?} not an impl", item) } } @@ -1371,23 +1375,23 @@ fn explicit_predicates_of<'a, 'tcx>( NodeItem(item) => { match item.node { - ItemImpl(_, _, defaultness, ref generics, ..) => { + ItemKind::Impl(_, _, defaultness, ref generics, ..) => { if defaultness.is_default() { is_default_impl_trait = tcx.impl_trait_ref(def_id); } generics } - ItemFn(.., ref generics, _) | - ItemTy(_, ref generics) | - ItemEnum(_, ref generics) | - ItemStruct(_, ref generics) | - ItemUnion(_, ref generics) => generics, + ItemKind::Fn(.., ref generics, _) | + ItemKind::Ty(_, ref generics) | + ItemKind::Enum(_, ref generics) | + ItemKind::Struct(_, ref generics) | + ItemKind::Union(_, ref generics) => generics, - ItemTrait(_, _, ref generics, .., ref items) => { + ItemKind::Trait(_, _, ref generics, .., ref items) => { is_trait = Some((ty::TraitRef::identity(tcx, def_id), items)); generics } - ItemExistential(ref exist_ty) => { + ItemKind::Existential(ref exist_ty) => { let substs = Substs::identity_for_item(tcx, def_id); let anon_ty = tcx.mk_anon(def_id, substs); @@ -1412,9 +1416,9 @@ fn explicit_predicates_of<'a, 'tcx>( NodeForeignItem(item) => { match item.node { - ForeignItemStatic(..) => &no_generics, - ForeignItemFn(_, _, ref generics) => generics, - ForeignItemType => &no_generics, + ForeignItemKind::Static(..) => &no_generics, + ForeignItemKind::Fn(_, _, ref generics) => generics, + ForeignItemKind::Type => &no_generics, } } @@ -1578,7 +1582,7 @@ fn explicit_predicates_of<'a, 'tcx>( // before uses of `U`. This avoids false ambiguity errors // in trait checking. See `setup_constraining_predicates` // for details. - if let NodeItem(&Item { node: ItemImpl(..), .. }) = node { + if let NodeItem(&Item { node: ItemKind::Impl(..), .. }) = node { let self_ty = tcx.type_of(def_id); let trait_ref = tcx.impl_trait_ref(def_id); ctp::setup_constraining_predicates(tcx, diff --git a/src/librustc_typeck/impl_wf_check.rs b/src/librustc_typeck/impl_wf_check.rs index b57bb1fccfb..b7921301957 100644 --- a/src/librustc_typeck/impl_wf_check.rs +++ b/src/librustc_typeck/impl_wf_check.rs @@ -72,7 +72,7 @@ struct ImplWfCheck<'a, 'tcx: 'a> { impl<'a, 'tcx> ItemLikeVisitor<'tcx> for ImplWfCheck<'a, 'tcx> { fn visit_item(&mut self, item: &'tcx hir::Item) { match item.node { - hir::ItemImpl(.., ref impl_item_refs) => { + hir::ItemKind::Impl(.., ref impl_item_refs) => { let impl_def_id = self.tcx.hir.local_def_id(item.id); enforce_impl_params_are_constrained(self.tcx, impl_def_id, diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index b50f55effad..e343fb1a57b 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -189,7 +189,7 @@ fn check_main_fn_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, match tcx.hir.find(main_id) { Some(hir_map::NodeItem(it)) => { match it.node { - hir::ItemFn(.., ref generics, _) => { + hir::ItemKind::Fn(.., ref generics, _) => { let mut error = false; if !generics.params.is_empty() { let msg = format!("`main` function is not allowed to have generic \ @@ -261,7 +261,7 @@ fn check_start_fn_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, match tcx.hir.find(start_id) { Some(hir_map::NodeItem(it)) => { match it.node { - hir::ItemFn(.., ref generics, _) => { + hir::ItemKind::Fn(.., ref generics, _) => { let mut error = false; if !generics.params.is_empty() { struct_span_err!(tcx.sess, generics.span, E0132, diff --git a/src/librustc_typeck/outlives/implicit_infer.rs b/src/librustc_typeck/outlives/implicit_infer.rs index a015122d62e..e378f1a2dce 100644 --- a/src/librustc_typeck/outlives/implicit_infer.rs +++ b/src/librustc_typeck/outlives/implicit_infer.rs @@ -77,7 +77,7 @@ impl<'cx, 'tcx> ItemLikeVisitor<'tcx> for InferVisitor<'cx, 'tcx> { let mut item_required_predicates = RequiredPredicates::default(); match item.node { - hir::ItemUnion(..) | hir::ItemEnum(..) | hir::ItemStruct(..) => { + hir::ItemKind::Union(..) | hir::ItemKind::Enum(..) | hir::ItemKind::Struct(..) => { let adt_def = self.tcx.adt_def(item_did); // Iterate over all fields in item_did diff --git a/src/librustc_typeck/outlives/mod.rs b/src/librustc_typeck/outlives/mod.rs index 9c483924992..5801a6ada3f 100644 --- a/src/librustc_typeck/outlives/mod.rs +++ b/src/librustc_typeck/outlives/mod.rs @@ -41,7 +41,7 @@ fn inferred_outlives_of<'a, 'tcx>( match tcx.hir.get(id) { hir_map::NodeItem(item) => match item.node { - hir::ItemStruct(..) | hir::ItemEnum(..) | hir::ItemUnion(..) => { + hir::ItemKind::Struct(..) | hir::ItemKind::Enum(..) | hir::ItemKind::Union(..) => { let crate_map = tcx.inferred_outlives_crate(LOCAL_CRATE); let predicates = crate_map diff --git a/src/librustc_typeck/variance/constraints.rs b/src/librustc_typeck/variance/constraints.rs index ad7a3051f64..9fecf5e73e7 100644 --- a/src/librustc_typeck/variance/constraints.rs +++ b/src/librustc_typeck/variance/constraints.rs @@ -80,8 +80,8 @@ pub fn add_constraints_from_crate<'a, 'tcx>(terms_cx: TermsContext<'a, 'tcx>) impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for ConstraintContext<'a, 'tcx> { fn visit_item(&mut self, item: &hir::Item) { match item.node { - hir::ItemStruct(ref struct_def, _) | - hir::ItemUnion(ref struct_def, _) => { + hir::ItemKind::Struct(ref struct_def, _) | + hir::ItemKind::Union(ref struct_def, _) => { self.visit_node_helper(item.id); if let hir::VariantData::Tuple(..) = *struct_def { @@ -89,7 +89,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for ConstraintContext<'a, 'tcx> { } } - hir::ItemEnum(ref enum_def, _) => { + hir::ItemKind::Enum(ref enum_def, _) => { self.visit_node_helper(item.id); for variant in &enum_def.variants { @@ -99,13 +99,13 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for ConstraintContext<'a, 'tcx> { } } - hir::ItemFn(..) => { + hir::ItemKind::Fn(..) => { self.visit_node_helper(item.id); } - hir::ItemForeignMod(ref foreign_mod) => { + hir::ItemKind::ForeignMod(ref foreign_mod) => { for foreign_item in &foreign_mod.items { - if let hir::ForeignItemFn(..) = foreign_item.node { + if let hir::ForeignItemKind::Fn(..) = foreign_item.node { self.visit_node_helper(foreign_item.id); } } diff --git a/src/librustc_typeck/variance/mod.rs b/src/librustc_typeck/variance/mod.rs index adea9788b3c..3d70550c1df 100644 --- a/src/librustc_typeck/variance/mod.rs +++ b/src/librustc_typeck/variance/mod.rs @@ -62,10 +62,10 @@ fn variances_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_def_id: DefId) }; match tcx.hir.get(id) { hir::map::NodeItem(item) => match item.node { - hir::ItemEnum(..) | - hir::ItemStruct(..) | - hir::ItemUnion(..) | - hir::ItemFn(..) => {} + hir::ItemKind::Enum(..) | + hir::ItemKind::Struct(..) | + hir::ItemKind::Union(..) | + hir::ItemKind::Fn(..) => {} _ => unsupported() }, @@ -83,7 +83,7 @@ fn variances_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_def_id: DefId) }, hir::map::NodeForeignItem(item) => match item.node { - hir::ForeignItemFn(..) => {} + hir::ForeignItemKind::Fn(..) => {} _ => unsupported() }, diff --git a/src/librustc_typeck/variance/terms.rs b/src/librustc_typeck/variance/terms.rs index b9ab00130b3..0aec31609b0 100644 --- a/src/librustc_typeck/variance/terms.rs +++ b/src/librustc_typeck/variance/terms.rs @@ -142,8 +142,8 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for TermsContext<'a, 'tcx> { self.tcx.hir.node_to_string(item.id)); match item.node { - hir::ItemStruct(ref struct_def, _) | - hir::ItemUnion(ref struct_def, _) => { + hir::ItemKind::Struct(ref struct_def, _) | + hir::ItemKind::Union(ref struct_def, _) => { self.add_inferreds_for_item(item.id); if let hir::VariantData::Tuple(..) = *struct_def { @@ -151,7 +151,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for TermsContext<'a, 'tcx> { } } - hir::ItemEnum(ref enum_def, _) => { + hir::ItemKind::Enum(ref enum_def, _) => { self.add_inferreds_for_item(item.id); for variant in &enum_def.variants { @@ -161,13 +161,13 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for TermsContext<'a, 'tcx> { } } - hir::ItemFn(..) => { + hir::ItemKind::Fn(..) => { self.add_inferreds_for_item(item.id); } - hir::ItemForeignMod(ref foreign_mod) => { + hir::ItemKind::ForeignMod(ref foreign_mod) => { for foreign_item in &foreign_mod.items { - if let hir::ForeignItemFn(..) = foreign_item.node { + if let hir::ForeignItemKind::Fn(..) = foreign_item.node { self.add_inferreds_for_item(foreign_item.id); } } diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index 527aef80a8d..0cdab134815 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -10,6 +10,7 @@ use rustc::traits::auto_trait as auto; use rustc::ty::TypeFoldable; +use rustc::hir; use std::fmt::Debug; use super::*; @@ -65,9 +66,9 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> { let did = self.cx.tcx.hir.local_def_id(id); let def_ctor = match *item { - hir::ItemStruct(_, _) => Def::Struct, - hir::ItemUnion(_, _) => Def::Union, - hir::ItemEnum(_, _) => Def::Enum, + hir::ItemKind::Struct(_, _) => Def::Struct, + hir::ItemKind::Union(_, _) => Def::Union, + hir::ItemKind::Enum(_, _) => Def::Enum, _ => panic!("Unexpected type {:?} {:?}", item, id), }; @@ -216,7 +217,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> { let ty = hir::Ty { id: ast::DUMMY_NODE_ID, - node: hir::Ty_::TyPath(hir::QPath::Resolved(None, P(new_path))), + node: hir::TyKind::Path(hir::QPath::Resolved(None, P(new_path))), span: DUMMY_SP, hir_id: hir::DUMMY_HIR_ID, }; @@ -279,7 +280,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> { debug!("ty_param_to_ty({:?}) {:?}", param, param.def_id); hir::Ty { id: ast::DUMMY_NODE_ID, - node: hir::Ty_::TyPath(hir::QPath::Resolved( + node: hir::TyKind::Path(hir::QPath::Resolved( None, P(hir::Path { span: DUMMY_SP, diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 030b36c2212..2bf1f6e553f 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -283,10 +283,10 @@ impl Clean<ExternalCrate> for CrateNum { cx.tcx.hir.krate().module.item_ids.iter().filter_map(|&id| { let item = cx.tcx.hir.expect_item(id.id); match item.node { - hir::ItemMod(_) => { + hir::ItemKind::Mod(_) => { as_primitive(Def::Mod(cx.tcx.hir.local_def_id(id.id))) } - hir::ItemUse(ref path, hir::UseKind::Single) + hir::ItemKind::Use(ref path, hir::UseKind::Single) if item.vis.node.is_pub() => { as_primitive(path.def).map(|(_, prim, attrs)| { // Pretend the primitive is local. @@ -325,10 +325,10 @@ impl Clean<ExternalCrate> for CrateNum { cx.tcx.hir.krate().module.item_ids.iter().filter_map(|&id| { let item = cx.tcx.hir.expect_item(id.id); match item.node { - hir::ItemMod(_) => { + hir::ItemKind::Mod(_) => { as_keyword(Def::Mod(cx.tcx.hir.local_def_id(id.id))) } - hir::ItemUse(ref path, hir::UseKind::Single) + hir::ItemKind::Use(ref path, hir::UseKind::Single) if item.vis.node.is_pub() => { as_keyword(path.def).map(|(_, prim, attrs)| { (cx.tcx.hir.local_def_id(id.id), prim, attrs) @@ -2586,7 +2586,7 @@ pub struct PolyTrait { /// it does not preserve mutability or boxes. #[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Debug, Hash)] pub enum Type { - /// structs/enums/traits (most that'd be an hir::TyPath) + /// structs/enums/traits (most that'd be an hir::TyKind::Path) ResolvedPath { path: Path, typarams: Option<Vec<GenericBound>>, @@ -2852,9 +2852,9 @@ impl Clean<Type> for hir::Ty { fn clean(&self, cx: &DocContext) -> Type { use rustc::hir::*; match self.node { - TyNever => Never, - TyPtr(ref m) => RawPointer(m.mutbl.clean(cx), box m.ty.clean(cx)), - TyRptr(ref l, ref m) => { + TyKind::Never => Never, + TyKind::Ptr(ref m) => RawPointer(m.mutbl.clean(cx), box m.ty.clean(cx)), + TyKind::Rptr(ref l, ref m) => { let lifetime = if l.is_elided() { None } else { @@ -2863,8 +2863,8 @@ impl Clean<Type> for hir::Ty { BorrowedRef {lifetime: lifetime, mutability: m.mutbl.clean(cx), type_: box m.ty.clean(cx)} } - TySlice(ref ty) => Slice(box ty.clean(cx)), - TyArray(ref ty, ref length) => { + TyKind::Slice(ref ty) => Slice(box ty.clean(cx)), + TyKind::Array(ref ty, ref length) => { let def_id = cx.tcx.hir.local_def_id(length.id); let param_env = cx.tcx.param_env(def_id); let substs = Substs::identity_for_item(cx.tcx, def_id); @@ -2878,8 +2878,8 @@ impl Clean<Type> for hir::Ty { let length = print_const(cx, length); Array(box ty.clean(cx), length) }, - TyTup(ref tys) => Tuple(tys.clean(cx)), - TyPath(hir::QPath::Resolved(None, ref path)) => { + TyKind::Tup(ref tys) => Tuple(tys.clean(cx)), + TyKind::Path(hir::QPath::Resolved(None, ref path)) => { if let Some(new_ty) = cx.ty_substs.borrow().get(&path.def).cloned() { return new_ty; } @@ -2900,7 +2900,7 @@ impl Clean<Type> for hir::Ty { } }; - if let Some(&hir::ItemTy(ref ty, ref generics)) = alias { + if let Some(&hir::ItemKind::Ty(ref ty, ref generics)) = alias { let provided_params = &path.segments.last().unwrap(); let mut ty_substs = FxHashMap(); let mut lt_substs = FxHashMap(); @@ -2965,7 +2965,7 @@ impl Clean<Type> for hir::Ty { } resolve_type(cx, path.clean(cx), self.id) } - TyPath(hir::QPath::Resolved(Some(ref qself), ref p)) => { + TyKind::Path(hir::QPath::Resolved(Some(ref qself), ref p)) => { let mut segments: Vec<_> = p.segments.clone().into(); segments.pop(); let trait_path = hir::Path { @@ -2979,7 +2979,7 @@ impl Clean<Type> for hir::Ty { trait_: box resolve_type(cx, trait_path.clean(cx), self.id) } } - TyPath(hir::QPath::TypeRelative(ref qself, ref segment)) => { + TyKind::Path(hir::QPath::TypeRelative(ref qself, ref segment)) => { let mut def = Def::Err; let ty = hir_ty_to_ty(cx.tcx, self); if let ty::TyProjection(proj) = ty.sty { @@ -2996,7 +2996,7 @@ impl Clean<Type> for hir::Ty { trait_: box resolve_type(cx, trait_path.clean(cx), self.id) } } - TyTraitObject(ref bounds, ref lifetime) => { + TyKind::TraitObject(ref bounds, ref lifetime) => { match bounds[0].clean(cx).trait_ { ResolvedPath { path, typarams: None, did, is_generic } => { let mut bounds: Vec<self::GenericBound> = bounds[1..].iter().map(|bound| { @@ -3011,9 +3011,9 @@ impl Clean<Type> for hir::Ty { _ => Infer // shouldn't happen } } - TyBareFn(ref barefn) => BareFunction(box barefn.clean(cx)), - TyInfer | TyErr => Infer, - TyTypeof(..) => panic!("Unimplemented type {:?}", self.node), + TyKind::BareFn(ref barefn) => BareFunction(box barefn.clean(cx)), + TyKind::Infer | TyKind::Err => Infer, + TyKind::Typeof(..) => panic!("Unimplemented type {:?}", self.node), } } } @@ -4018,7 +4018,7 @@ impl Clean<Vec<Item>> for hir::ForeignMod { impl Clean<Item> for hir::ForeignItem { fn clean(&self, cx: &DocContext) -> Item { let inner = match self.node { - hir::ForeignItemFn(ref decl, ref names, ref generics) => { + hir::ForeignItemKind::Fn(ref decl, ref names, ref generics) => { let (generics, decl) = enter_impl_trait(cx, || { (generics.clean(cx), (&**decl, &names[..]).clean(cx)) }); @@ -4033,14 +4033,14 @@ impl Clean<Item> for hir::ForeignItem { }, }) } - hir::ForeignItemStatic(ref ty, mutbl) => { + hir::ForeignItemKind::Static(ref ty, mutbl) => { ForeignStaticItem(Static { type_: ty.clean(cx), mutability: if mutbl {Mutable} else {Immutable}, expr: "".to_string(), }) } - hir::ForeignItemType => { + hir::ForeignItemKind::Type => { ForeignTypeItem } }; @@ -4370,7 +4370,7 @@ pub fn path_to_def_local(tcx: &TyCtxt, path: &[&str]) -> Option<DefId> { } items = match &item.node { - &hir::ItemMod(ref m) => m.item_ids.clone(), + &hir::ItemKind::Mod(ref m) => m.item_ids.clone(), _ => panic!("Unexpected item {:?} in path {:?} path") }; break; diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index 53032b9b98c..bd35cc0acda 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -706,7 +706,7 @@ impl<'a, 'hir> intravisit::Visitor<'hir> for HirCollector<'a, 'hir> { } fn visit_item(&mut self, item: &'hir hir::Item) { - let name = if let hir::ItemImpl(.., ref ty, _) = item.node { + let name = if let hir::ItemKind::Impl(.., ref ty, _) = item.node { self.map.node_to_pretty_string(ty.id) } else { item.name.to_string() diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index b7a9f95fdc0..875ba111ec0 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -297,7 +297,7 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> { if !self.view_item_stack.insert(def_node_id) { return false } let ret = match tcx.hir.get(def_node_id) { - hir_map::NodeItem(&hir::Item { node: hir::ItemMod(ref m), .. }) if glob => { + hir_map::NodeItem(&hir::Item { node: hir::ItemKind::Mod(ref m), .. }) if glob => { let prev = mem::replace(&mut self.inlining, true); for i in &m.item_ids { let i = self.cx.tcx.hir.expect_item(i.id); @@ -340,7 +340,7 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> { } match item.node { - hir::ItemForeignMod(ref fm) => { + hir::ItemKind::ForeignMod(ref fm) => { // If inlining we only want to include public functions. om.foreigns.push(if self.inlining { hir::ForeignMod { @@ -353,8 +353,8 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> { } // If we're inlining, skip private items. _ if self.inlining && !item.vis.node.is_pub() => {} - hir::ItemGlobalAsm(..) => {} - hir::ItemExternCrate(orig_name) => { + hir::ItemKind::GlobalAsm(..) => {} + hir::ItemKind::ExternCrate(orig_name) => { let def_id = self.cx.tcx.hir.local_def_id(item.id); om.extern_crates.push(ExternCrate { cnum: self.cx.tcx.extern_mod_stmt_cnum(def_id) @@ -366,8 +366,8 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> { whence: item.span, }) } - hir::ItemUse(_, hir::UseKind::ListStem) => {} - hir::ItemUse(ref path, kind) => { + hir::ItemKind::Use(_, hir::UseKind::ListStem) => {} + hir::ItemKind::Use(ref path, kind) => { let is_glob = kind == hir::UseKind::Glob; // struct and variant constructors always show up alongside their definitions, we've @@ -409,7 +409,7 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> { whence: item.span, }); } - hir::ItemMod(ref m) => { + hir::ItemKind::Mod(ref m) => { om.mods.push(self.visit_mod_contents(item.span, item.attrs.clone(), item.vis.clone(), @@ -417,15 +417,15 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> { m, Some(name))); }, - hir::ItemEnum(ref ed, ref gen) => + hir::ItemKind::Enum(ref ed, ref gen) => om.enums.push(self.visit_enum_def(item, name, ed, gen)), - hir::ItemStruct(ref sd, ref gen) => + hir::ItemKind::Struct(ref sd, ref gen) => om.structs.push(self.visit_variant_data(item, name, sd, gen)), - hir::ItemUnion(ref sd, ref gen) => + hir::ItemKind::Union(ref sd, ref gen) => om.unions.push(self.visit_union_data(item, name, sd, gen)), - hir::ItemFn(ref fd, header, ref gen, body) => + hir::ItemKind::Fn(ref fd, header, ref gen, body) => om.fns.push(self.visit_fn(item, name, &**fd, header, gen, body)), - hir::ItemTy(ref ty, ref gen) => { + hir::ItemKind::Ty(ref ty, ref gen) => { let t = Typedef { ty: ty.clone(), gen: gen.clone(), @@ -439,7 +439,7 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> { }; om.typedefs.push(t); }, - hir::ItemStatic(ref ty, ref mut_, ref exp) => { + hir::ItemKind::Static(ref ty, ref mut_, ref exp) => { let s = Static { type_: ty.clone(), mutability: mut_.clone(), @@ -454,7 +454,7 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> { }; om.statics.push(s); }, - hir::ItemConst(ref ty, ref exp) => { + hir::ItemKind::Const(ref ty, ref exp) => { let s = Constant { type_: ty.clone(), expr: exp.clone(), @@ -468,7 +468,7 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> { }; om.constants.push(s); }, - hir::ItemTrait(is_auto, unsafety, ref gen, ref b, ref item_ids) => { + hir::ItemKind::Trait(is_auto, unsafety, ref gen, ref b, ref item_ids) => { let items = item_ids.iter() .map(|ti| self.cx.tcx.hir.trait_item(ti.id).clone()) .collect(); @@ -488,11 +488,11 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> { }; om.traits.push(t); }, - hir::ItemTraitAlias(..) => { + hir::ItemKind::TraitAlias(..) => { unimplemented!("trait objects are not yet implemented") }, - hir::ItemImpl(unsafety, + hir::ItemKind::Impl(unsafety, polarity, defaultness, ref gen, @@ -523,7 +523,7 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> { om.impls.push(i); } }, - hir::ItemExistential(_) => { + hir::ItemKind::Existential(_) => { // FIXME(oli-obk): actually generate docs for real existential items } } diff --git a/src/test/compile-fail/borrowck/two-phase-nonrecv-autoref.rs b/src/test/compile-fail/borrowck/two-phase-nonrecv-autoref.rs index 4303048138d..30752e8ddb1 100644 --- a/src/test/compile-fail/borrowck/two-phase-nonrecv-autoref.rs +++ b/src/test/compile-fail/borrowck/two-phase-nonrecv-autoref.rs @@ -52,7 +52,7 @@ fn deref_coercion(x: &mut u32) { // - [x] coerce_unsized e.g. `&[T; n]`, `&mut [T; n] -> &[T]`, // `&mut [T; n] -> &mut [T]`, `&Concrete -> &Trait` // - [x] Method Call Receivers (the case we want to support!) -// - [x] ExprIndex and ExprUnary Deref; only need to handle coerce_index_op +// - [x] ExprKind::Index and ExprKind::Unary Deref; only need to handle coerce_index_op // - [x] overloaded_binops fn overloaded_call_traits() { diff --git a/src/tools/clippy b/src/tools/clippy -Subproject 5e085e43104f6748a9717bb78de8b634712638b +Subproject 8f61a792f4f54f24adf9a8cb7824bfdb259c50e |
