>),
+ Struct(QPath, HirVec, Option>),
/// 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, AnonConst),
+ Repeat(P, AnonConst),
/// A suspension point for generators. This is `yield ` in Rust.
- ExprYield(P),
+ Yield(P),
}
/// 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
/// `::new`, and `T::X::Y::method` into `<<::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, P)
}
@@ -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),
+ Slice(P),
/// A fixed length array (`[T; n]`)
- TyArray(P, AnonConst),
+ Array(P, 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),
+ BareFn(P),
/// The never type (`!`)
- TyNever,
+ Never,
/// A tuple (`(A, B, C, D,...)`)
- TyTup(HirVec),
+ Tup(HirVec),
/// A path to a type definition (`module::module::...::Type`), or an
/// associated type, e.g. ` as Trait>::Type` or `::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, Lifetime),
+ TraitObject(HirVec, 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,
pub data: VariantData,
@@ -1884,7 +1882,7 @@ pub struct Variant_ {
pub disr_expr: Option,
}
-pub type Variant = Spanned;
+pub type Variant = Spanned;
#[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,
- 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),
+ ExternCrate(Option),
/// `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, UseKind),
+ Use(P, UseKind),
/// A `static` item
- ItemStatic(P, Mutability, BodyId),
+ Static(P, Mutability, BodyId),
/// A `const` item
- ItemConst(P, BodyId),
+ Const(P, BodyId),
/// A function declaration
- ItemFn(P, FnHeader, Generics, BodyId),
+ Fn(P, 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(P),
/// A type alias, e.g. `type Foo = Bar`
- ItemTy(P, Generics),
+ Ty(P, Generics),
/// A type alias, e.g. `type Foo = Bar`
- ItemExistential(ExistTy),
+ Existential(ExistTy),
/// An enum definition, e.g. `enum Foo {C, D}`
- ItemEnum(EnumDef, Generics),
+ Enum(EnumDef, Generics),
/// A struct definition, e.g. `struct Foo {x: A}`
- ItemStruct(VariantData, Generics),
+ Struct(VariantData, Generics),
/// A union definition, e.g. `union Foo {x: A, y: B}`
- ItemUnion(VariantData, Generics),
+ Union(VariantData, Generics),
/// Represents a Trait Declaration
- ItemTrait(IsAuto, Unsafety, Generics, GenericBounds, HirVec),
+ Trait(IsAuto, Unsafety, Generics, GenericBounds, HirVec),
/// Represents a Trait Alias Declaration
- ItemTraitAlias(Generics, GenericBounds),
+ TraitAlias(Generics, GenericBounds),
/// An implementation, eg `impl Trait for Foo { .. }`
- ItemImpl(Unsafety,
- ImplPolarity,
- Defaultness,
- Generics,
- Option, // (optional) trait this impl implements
- P, // self
- HirVec),
+ Impl(Unsafety,
+ ImplPolarity,
+ Defaultness,
+ Generics,
+ Option, // (optional) trait this impl implements
+ P, // self
+ HirVec),
}
-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 {
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,
- 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, HirVec, Generics),
+ Fn(P, HirVec, Generics),
/// A foreign static item (`static ext: u8`), with optional mutability
/// (the boolean is true when mutable)
- ForeignItemStatic(P, bool),
+ Static(P, 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 377990ef561a..e637a18d1cd0 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,
+ Add => AssocOp::Add,
+ Sub => AssocOp::Subtract,
+ Mul => AssocOp::Multiply,
+ Div => AssocOp::Divide,
+ Rem => AssocOp::Modulus,
- BiAnd => AssocOp::LAnd,
- BiOr => AssocOp::LOr,
+ And => AssocOp::LAnd,
+ Or => AssocOp::LOr,
- BiBitXor => AssocOp::BitXor,
- BiBitAnd => AssocOp::BitAnd,
- BiBitOr => AssocOp::BitOr,
- BiShl => AssocOp::ShiftLeft,
- BiShr => AssocOp::ShiftRight,
+ BitXor => AssocOp::BitXor,
+ BitAnd => AssocOp::BitAnd,
+ BitOr => AssocOp::BitOr,
+ Shl => AssocOp::ShiftLeft,
+ Shr => AssocOp::ShiftRight,
- BiEq => AssocOp::Equal,
- BiLt => AssocOp::Less,
- BiLe => AssocOp::LessEqual,
- BiNe => AssocOp::NotEqual,
- BiGe => AssocOp::GreaterEqual,
- BiGt => AssocOp::Greater,
+ 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 b6add3e6f120..d1fb05ceafbf 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!(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::BinOp_);
+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> 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> 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 5487da97d5b2..2924016670bf 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 432826238dbc..8da0dc365b04 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 b148a7401f8b..21be09b0ba19 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[ 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 18b8c70c3ef7..f4ef197e5b42 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 180469a5d848..da59bced760d 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 {
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 = ;` where refers to a struct_ctor,
// DefMap maps 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 ebc796466629..feeb508d676c 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 a83aa47fd4f1..5beafe2b601b 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 27f7dbf508db..668bac1e4795 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 07a9dd75d4ca..b828b1bd30a9 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 3b89a9d2de51..0602dc55c43d 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 476f3f5799da..a504697008ef 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 a11c8f5dc044..ebdc9c922b1d 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)
{
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 369f65c214aa..05a6cd9c243d 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 {
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 9bf5c4d72b70..fdcae38fc6a7 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 67dfad50f443..6876b1490f37 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 a5caacea9861..df26ac670601 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) {
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 684022f8e8a3..875c7199f6d1 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 8f7f9d09423f..c7bb90bfcb09 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 bbfcfb798909..5aa6542a027d 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 f118d22c54d3..d5425aff6ba6 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 046318b3619c..002e8697588f 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 241950fb6bff..7ce6863a7c98 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 79b438236921..3ae1e5aac507 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 {
// 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 28e76a80513f..94357f348497 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 ea26e271c9bb..d4d0b67523e1 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(op: hir::BinOp_,
+fn cast_shift_rhs(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 7e55642814bb..60bba635a788 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 199c40bb704e..6e3096d4cd5b 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 7625e4c7e0f2..58a32ad9774f 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 e142a7d9c1ce..b512a6f1bb4b 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 2b30f680092e..5b2092ea9eb1 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::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::ItemEnum(..) |
- hir::ItemStruct(..) |
- hir::ItemUnion(..) |
- hir::ItemTrait(..) |
- hir::ItemTraitAlias(..) |
- hir::ItemImpl(..) => None,
+ hir::ItemKind::Enum(..) |
+ hir::ItemKind::Struct(..) |
+ hir::ItemKind::Union(..) |
+ hir::ItemKind::Trait(..) |
+ hir::ItemKind::TraitAlias(..) |
+ hir::ItemKind::Impl(..) => None,
- hir::ItemMod(ref m) => search_mod(this, m, idx, names),
+ 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 eeb87e417570..39e674a6095b 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`
- HirItem::ItemTy(..) => ("ItemTy", LABELS_HIR_ONLY),
+ HirItem::Ty(..) => ("ItemTy", LABELS_HIR_ONLY),
// An enum definition, e.g. `enum Foo {C, D}`
- HirItem::ItemEnum(..) => ("ItemEnum", LABELS_ADT),
+ HirItem::Enum(..) => ("ItemEnum", LABELS_ADT),
// A struct definition, e.g. `struct Foo {x: A}`
- HirItem::ItemStruct(..) => ("ItemStruct", LABELS_ADT),
+ HirItem::Struct(..) => ("ItemStruct", LABELS_ADT),
// A union definition, e.g. `union Foo {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 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 6bc364b72618..fd5a152311de 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 0b33e397d188..8a674449880b 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 e5bd6a7f610f..ad4a4fbff649 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(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 81b4ae3f6e8d..3d64fa572d1e 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 72f91dcea608..b9cb97ed7d0c 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 c44d891b7f39..e96d56fb3889 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 b699885b0eb9..008e1e363ff5 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 70b8c7b11fdb..327b2abc4d31 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 f903dbd97a81..c481d1d325b3 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 03eaee362c70..e7f00b577b39 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 16dec2725ff0..fc0e64d0a8a6 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 5ef1eef133d9..6c8b5d97b6ff 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 8c73771e57b2..13b2a0ab8741 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 18ae7c774591..35f9dcee99f8 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 636969e26322..53511c1c127d 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 ce917b8ca551..a2d620db9243 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>) {
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 44f9477c2ecb..9c341b38e34f 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 7768e96d0361..b4f0a7cd6c4b 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 eff0dbe1235f..8ef20126e035 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 6fbe4e0f240b..d223dc2a3533 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 88af8b49b9e7..f2728593db4d 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 16e2e4b0393b..ab383287773a 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]- ` has two predicates,
// `X: Iterator` and `::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_resolve/lib.rs b/src/librustc_resolve/lib.rs
index f3086d3ab2b1..f388b911feb6 100644
--- a/src/librustc_resolve/lib.rs
+++ b/src/librustc_resolve/lib.rs
@@ -1412,9 +1412,6 @@ pub struct Resolver<'a> {
/// Avoid duplicated errors for "name already defined".
name_already_seen: FxHashMap,
- /// If `#![feature(proc_macro)]` is set
- proc_macro_enabled: bool,
-
/// A set of procedural macros imported by `#[macro_use]` that have already been warned about
warned_proc_macros: FxHashSet,
@@ -1713,7 +1710,7 @@ impl<'a> Resolver<'a> {
// The `proc_macro` and `decl_macro` features imply `use_extern_macros`
use_extern_macros:
- features.use_extern_macros || features.proc_macro || features.decl_macro,
+ features.use_extern_macros || features.decl_macro,
crate_loader,
macro_names: FxHashSet(),
@@ -1727,7 +1724,6 @@ impl<'a> Resolver<'a> {
local_macro_def_scopes: FxHashMap(),
name_already_seen: FxHashMap(),
whitelisted_legacy_custom_derives: Vec::new(),
- proc_macro_enabled: features.proc_macro,
warned_proc_macros: FxHashSet(),
potentially_unused_imports: Vec::new(),
struct_constructors: DefIdMap(),
@@ -4509,7 +4505,7 @@ impl<'a> Resolver<'a> {
}
fn check_proc_macro_attrs(&mut self, attrs: &[ast::Attribute]) {
- if self.proc_macro_enabled { return; }
+ if self.use_extern_macros { return; }
for attr in attrs {
if attr.path.segments.len() > 1 {
diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs
index c99172efc7c5..f076d884f609 100644
--- a/src/librustc_resolve/macros.rs
+++ b/src/librustc_resolve/macros.rs
@@ -429,7 +429,7 @@ impl<'a> Resolver<'a> {
*item = mem::replace(item, dummy_item).map_attrs(|mut attrs| {
let inert_attr = attr.take().unwrap();
attr::mark_known(&inert_attr);
- if self.proc_macro_enabled {
+ if self.use_extern_macros {
*attr = expand::find_attr_invoc(&mut attrs);
}
attrs.push(inert_attr);
diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs
index 055fbb236d8f..f2620c04754b 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 5e38c0bbcb4a..f85e7b068588 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 c260655bd3e8..c9b5fd525dd8 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 383820a62bff..ec127d26ab30 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 4c903b6fe585..220dd122b267 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 aee64ad3b550..92b35bd50f3c 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 c93023edcea0..e26bf1b4f77c 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 36ce01bcd08b..6c3e265619fe 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 68c71f4ce90e..026a9de5052c 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("".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
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 c7ad3398873e..9f83f8a00b1f 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::ExprKind::Path(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::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 0a33252d4cd0..46746d4bd298 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 79ee322d1095..8aa5658d291d 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::.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::.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 e24269bca571..61fe90be2177 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 85fdcd417ff9..d876f41ce130 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 b7233217d5f3..3207ac44948f 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 3a8ed0ea25fa..1a57dfd745e3 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 393904583ca4..4d9a4a03a6b5 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 532f1da4f301..02a18fa47dff 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 6a346b02b794..c0260d6714d0 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 6d6594e55437..9be509b35880 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 5a442881a631..9e19854a571f 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 5fa98e3ebe69..4b628d6ffad7 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,
+ ItemKind::Fn(.., ref generics, _) |
+ ItemKind::Impl(_, _, _, ref generics, ..) => generics,
- ItemTy(_, ref generics) |
- ItemEnum(_, ref generics) |
- ItemStruct(_, ref generics) |
- ItemExistential(hir::ExistTy { ref generics, .. }) |
- ItemUnion(_, ref 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() {
&["", "", ""][..]
} 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 b57bb1fccfb5..b7921301957c 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 b50f55effad4..e343fb1a57b1 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 a015122d62e7..e378f1a2dce3 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 9c483924992d..5801a6ada3f2 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 ad7a3051f640..9fecf5e73e76 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 adea9788b3c5..3d70550c1dfb 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 b9ab00130b3c..0aec31609b06 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 527aef80a8d9..0cdab1348159 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 030b36c2212a..2bf1f6e553f3 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -283,10 +283,10 @@ impl Clean 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 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>,
@@ -2852,9 +2852,9 @@ impl Clean 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 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