From f12eca47e09dc0aa7420e51c090a22cd72f44159 Mon Sep 17 00:00:00 2001 From: csmoe <35686186+csmoe@users.noreply.github.com> Date: Wed, 11 Jul 2018 22:41:03 +0800 Subject: [PATCH] TyKind --- src/librustc/hir/intravisit.rs | 23 +++++---- src/librustc/hir/lowering.rs | 50 +++++++++---------- src/librustc/hir/map/mod.rs | 1 + src/librustc/hir/mod.rs | 35 +++++++------ src/librustc/hir/print.rs | 26 +++++----- src/librustc/ich/impls_hir.rs | 26 +++++----- .../nice_region_error/find_anon_type.rs | 12 ++--- src/librustc/middle/resolve_lifetime.rs | 28 +++++------ src/librustc/traits/error_reporting.rs | 2 +- src/librustc_borrowck/borrowck/mod.rs | 4 +- src/librustc_lint/builtin.rs | 2 +- src/librustc_metadata/encoder.rs | 2 +- .../error_reporting/region_name.rs | 14 +++--- src/librustc_privacy/lib.rs | 6 +-- src/librustc_save_analysis/lib.rs | 2 +- src/librustc_typeck/astconv.rs | 30 +++++------ src/librustc_typeck/check/compare_method.rs | 6 +-- src/librustc_typeck/check/mod.rs | 2 +- src/librustc_typeck/collect.rs | 8 +-- src/librustdoc/clean/auto_trait.rs | 4 +- src/librustdoc/clean/mod.rs | 2 +- 21 files changed, 143 insertions(+), 142 deletions(-) diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index 11800d7f9c9e..8c97d5e74af3 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -50,6 +50,7 @@ use super::itemlikevisit::DeepVisitor; use std::cmp; use std::u32; +use std::result::Result::Err; #[derive(Copy, Clone)] pub enum FnKind<'a> { @@ -576,41 +577,41 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) { visitor.visit_id(typ.id); match typ.node { - TySlice(ref ty) => { + TyKind::Slice(ref ty) => { visitor.visit_ty(ty) } - TyPtr(ref mutable_type) => { + TyKind::Ptr(ref mutable_type) => { visitor.visit_ty(&mutable_type.ty) } - TyRptr(ref lifetime, ref mutable_type) => { + TyKind::Rptr(ref lifetime, ref mutable_type) => { visitor.visit_lifetime(lifetime); visitor.visit_ty(&mutable_type.ty) } - TyNever => {}, - TyTup(ref tuple_element_types) => { + TyKind::Never => {}, + TyKind::Tup(ref tuple_element_types) => { walk_list!(visitor, visit_ty, tuple_element_types); } - TyBareFn(ref function_declaration) => { + TyKind::BareFn(ref function_declaration) => { walk_list!(visitor, visit_generic_param, &function_declaration.generic_params); visitor.visit_fn_decl(&function_declaration.decl); } - TyPath(ref qpath) => { + TyKind::Path(ref qpath) => { visitor.visit_qpath(qpath, typ.id, typ.span); } - TyArray(ref ty, ref length) => { + TyKind::Array(ref ty, ref length) => { visitor.visit_ty(ty); visitor.visit_anon_const(length) } - TyTraitObject(ref bounds, ref lifetime) => { + TyKind::TraitObject(ref bounds, ref lifetime) => { for bound in bounds { visitor.visit_poly_trait_ref(bound, TraitBoundModifier::None); } visitor.visit_lifetime(lifetime); } - TyTypeof(ref expression) => { + TyKind::Typeof(ref expression) => { visitor.visit_anon_const(expression) } - TyInfer | TyErr => {} + TyKind::Infer | TyKind::Err => {} } } diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index a583ef0c09f1..060f0e036b6a 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -1080,17 +1080,17 @@ impl<'a> LoweringContext<'a> { fn lower_ty_direct(&mut self, t: &Ty, mut itctx: ImplTraitContext) -> hir::Ty { let kind = match t.node { - TyKind::Infer => hir::TyInfer, - TyKind::Err => hir::TyErr, - TyKind::Slice(ref ty) => hir::TySlice(self.lower_ty(ty, itctx)), - TyKind::Ptr(ref mt) => hir::TyPtr(self.lower_mt(mt, itctx)), + TyKind::Infer => hir::TyKind::Infer, + TyKind::Err => hir::TyKind::Err, + TyKind::Slice(ref ty) => hir::TyKind::Slice(self.lower_ty(ty, itctx)), + TyKind::Ptr(ref mt) => hir::TyKind::Ptr(self.lower_mt(mt, itctx)), TyKind::Rptr(ref region, ref mt) => { let span = t.span.shrink_to_lo(); let lifetime = match *region { Some(ref lt) => self.lower_lifetime(lt), None => self.elided_ref_lifetime(span), }; - hir::TyRptr(lifetime, self.lower_mt(mt, itctx)) + hir::TyKind::Rptr(lifetime, self.lower_mt(mt, itctx)) } TyKind::BareFn(ref f) => self.with_in_scope_lifetime_defs( &f.generic_params, @@ -1098,7 +1098,7 @@ impl<'a> LoweringContext<'a> { this.with_anonymous_lifetime_mode( AnonymousLifetimeMode::PassThrough, |this| { - hir::TyBareFn(P(hir::BareFnTy { + hir::TyKind::BareFn(P(hir::BareFnTy { generic_params: this.lower_generic_params( &f.generic_params, &NodeMap(), @@ -1113,9 +1113,9 @@ impl<'a> LoweringContext<'a> { ) }, ), - TyKind::Never => hir::TyNever, + TyKind::Never => hir::TyKind::Never, TyKind::Tup(ref tys) => { - hir::TyTup(tys.iter().map(|ty| { + hir::TyKind::Tup(tys.iter().map(|ty| { self.lower_ty_direct(ty, itctx.reborrow()) }).collect()) } @@ -1126,12 +1126,12 @@ impl<'a> LoweringContext<'a> { let id = self.lower_node_id(t.id); let qpath = self.lower_qpath(t.id, qself, path, ParamMode::Explicit, itctx); let ty = self.ty_path(id, t.span, qpath); - if let hir::TyTraitObject(..) = ty.node { + if let hir::TyKind::TraitObject(..) = ty.node { self.maybe_lint_bare_trait(t.span, t.id, qself.is_none() && path.is_global()); } return ty; } - TyKind::ImplicitSelf => hir::TyPath(hir::QPath::Resolved( + TyKind::ImplicitSelf => hir::TyKind::Path(hir::QPath::Resolved( None, P(hir::Path { def: self.expect_full_def(t.id), @@ -1140,10 +1140,10 @@ impl<'a> LoweringContext<'a> { }), )), TyKind::Array(ref ty, ref length) => { - hir::TyArray(self.lower_ty(ty, itctx), self.lower_anon_const(length)) + hir::TyKind::Array(self.lower_ty(ty, itctx), self.lower_anon_const(length)) } TyKind::Typeof(ref expr) => { - hir::TyTypeof(self.lower_anon_const(expr)) + hir::TyKind::Typeof(self.lower_anon_const(expr)) } TyKind::TraitObject(ref bounds, kind) => { let mut lifetime_bound = None; @@ -1167,7 +1167,7 @@ impl<'a> LoweringContext<'a> { if kind != TraitObjectSyntax::Dyn { self.maybe_lint_bare_trait(t.span, t.id, false); } - hir::TyTraitObject(bounds, lifetime_bound) + hir::TyKind::TraitObject(bounds, lifetime_bound) } TyKind::ImplTrait(def_node_id, ref bounds) => { let span = t.span; @@ -1206,7 +1206,7 @@ impl<'a> LoweringContext<'a> { } }); - hir::TyPath(hir::QPath::Resolved( + hir::TyKind::Path(hir::QPath::Resolved( None, P(hir::Path { span, @@ -1223,7 +1223,7 @@ impl<'a> LoweringContext<'a> { "`impl Trait` not allowed outside of function \ and inherent method return types" ); - hir::TyErr + hir::TyKind::Err } } } @@ -1245,7 +1245,7 @@ impl<'a> LoweringContext<'a> { fn_def_id: DefId, exist_ty_node_id: NodeId, lower_bounds: impl FnOnce(&mut LoweringContext) -> hir::GenericBounds, - ) -> hir::Ty_ { + ) -> hir::TyKind { // Make sure we know that some funky desugaring has been going on here. // This is a first: there is code in other places like for loop // desugaring that explicitly states that we don't want to track that. @@ -1320,7 +1320,7 @@ impl<'a> LoweringContext<'a> { })) }], }); - hir::TyPath(hir::QPath::Resolved(None, path)) + hir::TyKind::Path(hir::QPath::Resolved(None, path)) }) } @@ -1365,7 +1365,7 @@ impl<'a> LoweringContext<'a> { fn visit_ty(&mut self, t: &'v hir::Ty) { // Don't collect elided lifetimes used inside of `fn()` syntax - if let hir::Ty_::TyBareFn(_) = t.node { + if let hir::TyKind::BareFn(_) = t.node { let old_collect_elided_lifetimes = self.collect_elided_lifetimes; self.collect_elided_lifetimes = false; @@ -1805,7 +1805,7 @@ impl<'a> LoweringContext<'a> { let inputs = inputs.iter().map(|ty| this.lower_ty_direct(ty, DISALLOWED)).collect(); let mk_tup = |this: &mut Self, tys, span| { let LoweredNodeId { node_id, hir_id } = this.next_id(); - hir::Ty { node: hir::TyTup(tys), id: node_id, hir_id, span } + hir::Ty { node: hir::TyKind::Tup(tys), id: node_id, hir_id, span } }; ( @@ -1985,7 +1985,7 @@ impl<'a> LoweringContext<'a> { fn visit_ty(&mut self, t: &'v hir::Ty) { // Don't collect elided lifetimes used inside of `fn()` syntax - if let &hir::Ty_::TyBareFn(_) = &t.node { + if let &hir::TyKind::BareFn(_) = &t.node { let old_collect_elided_lifetimes = self.collect_elided_lifetimes; self.collect_elided_lifetimes = false; @@ -2105,7 +2105,7 @@ impl<'a> LoweringContext<'a> { P(hir::Ty { id: node_id, hir_id: hir_id, - node: hir::TyTup(hir_vec![]), + node: hir::TyKind::Tup(hir_vec![]), span: *span, }) } @@ -4624,7 +4624,7 @@ impl<'a> LoweringContext<'a> { let mut id = id; let node = match qpath { hir::QPath::Resolved(None, path) => { - // Turn trait object paths into `TyTraitObject` instead. + // Turn trait object paths into `TyKind::TraitObject` instead. if let Def::Trait(_) = path.def { let principal = hir::PolyTraitRef { bound_generic_params: hir::HirVec::new(), @@ -4638,12 +4638,12 @@ impl<'a> LoweringContext<'a> { // The original ID is taken by the `PolyTraitRef`, // so the `Ty` itself needs a different one. id = self.next_id(); - hir::TyTraitObject(hir_vec![principal], self.elided_dyn_bound(span)) + hir::TyKind::TraitObject(hir_vec![principal], self.elided_dyn_bound(span)) } else { - hir::TyPath(hir::QPath::Resolved(None, path)) + hir::TyKind::Path(hir::QPath::Resolved(None, path)) } } - _ => hir::TyPath(qpath), + _ => hir::TyKind::Path(qpath), }; hir::Ty { id: id.node_id, diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index ae77f634d791..3397c7b8432a 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -33,6 +33,7 @@ use hir::svh::Svh; use util::nodemap::FxHashMap; use std::io; +use std::result::Result::Err; use ty::TyCtxt; pub mod blocks; diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 5a185b966fd1..edacada9be4d 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -17,7 +17,6 @@ pub use self::ForeignItem_::*; pub use self::Item_::*; pub use self::Mutability::*; pub use self::PrimTy::*; -pub use self::Ty_::*; pub use self::UnOp::*; pub use self::UnsafeSource::*; @@ -439,7 +438,7 @@ impl GenericArgs { match arg { GenericArg::Lifetime(_) => {} GenericArg::Type(ref ty) => { - if let TyTup(ref tys) = ty.node { + if let TyKind::Tup(ref tys) = ty.node { return tys; } break; @@ -1448,7 +1447,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) } @@ -1638,7 +1637,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, } @@ -1679,36 +1678,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)] diff --git a/src/librustc/hir/print.rs b/src/librustc/hir/print.rs index 1078a0bec34a..5c1378fd9414 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("?")?; } } @@ -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(":")?; diff --git a/src/librustc/ich/impls_hir.rs b/src/librustc/ich/impls_hir.rs index e045ea64135a..d8f7e09f6b4f 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 { 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..022d4fb8d1e7 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 @@ -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/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index 9fcb4420da15..cec5197acc8e 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -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. @@ -1287,7 +1287,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, }; @@ -1912,7 +1912,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 +1927,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 +2007,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 +2023,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 +2578,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/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 9f154a389f18..9fd2748e5ead 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -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())) diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index 19593b20c5aa..3ae1e5aac507 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -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_lint/builtin.rs b/src/librustc_lint/builtin.rs index e22f98031892..0ebb1a2bca82 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -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 diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index 0237c3f08c19..7721fa00f1a2 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -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); } 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..b8c50e885299 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,7 @@ 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 +287,7 @@ 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 +305,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_privacy/lib.rs b/src/librustc_privacy/lib.rs index 1d39fedc22c0..cd1bc4b44903 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -1052,7 +1052,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 +1060,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; } @@ -1293,7 +1293,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); } diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index dec5ea1d1539..7355ae4a7c84 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -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 c9f9cf4d5fe4..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 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/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/mod.rs b/src/librustc_typeck/check/mod.rs index f1097e02f082..6cbe1f42acce 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -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 diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index d956d86798b9..a8cf09154463 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -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) => { @@ -701,7 +701,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); @@ -1118,8 +1118,8 @@ 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), .. }) | + 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, diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index 527aef80a8d9..cbb8b3e39621 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -216,7 +216,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::TyPath(hir::QPath::Resolved(None, P(new_path))), span: DUMMY_SP, hir_id: hir::DUMMY_HIR_ID, }; @@ -279,7 +279,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::TyPath(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..a8980cbd5c89 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -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>,