This commit is contained in:
csmoe 2018-07-11 22:41:03 +08:00 committed by Oliver Schneider
parent 6a16b38198
commit f12eca47e0
21 changed files with 143 additions and 142 deletions

View File

@ -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 => {}
}
}

View File

@ -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,

View File

@ -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;

View File

@ -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
/// `<Vec>::new`, and `T::X::Y::method` into `<<<T>::X>::Y>::method`,
/// the `X` and `Y` nodes each being a `TyPath(QPath::TypeRelative(..))`.
/// the `X` and `Y` nodes each being a `TyKind::Path(QPath::TypeRelative(..))`.
TypeRelative(P<Ty>, P<PathSegment>)
}
@ -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<Ty>),
Slice(P<Ty>),
/// A fixed length array (`[T; n]`)
TyArray(P<Ty>, AnonConst),
Array(P<Ty>, AnonConst),
/// A raw pointer (`*const T` or `*mut T`)
TyPtr(MutTy),
Ptr(MutTy),
/// A reference (`&'a T` or `&'a mut T`)
TyRptr(Lifetime, MutTy),
Rptr(Lifetime, MutTy),
/// A bare function (e.g. `fn(usize) -> bool`)
TyBareFn(P<BareFnTy>),
BareFn(P<BareFnTy>),
/// The never type (`!`)
TyNever,
Never,
/// A tuple (`(A, B, C, D,...)`)
TyTup(HirVec<Ty>),
Tup(HirVec<Ty>),
/// A path to a type definition (`module::module::...::Type`), or an
/// associated type, e.g. `<Vec<T> as Trait>::Type` or `<T>::Target`.
///
/// Type parameters may be stored in each `PathSegment`.
TyPath(QPath),
Path(QPath),
/// A trait object type `Bound1 + Bound2 + Bound3`
/// where `Bound` is a trait or a lifetime.
TyTraitObject(HirVec<PolyTraitRef>, Lifetime),
TraitObject(HirVec<PolyTraitRef>, Lifetime),
/// Unused for now
TyTypeof(AnonConst),
/// TyInfer means the type should be inferred instead of it having been
Typeof(AnonConst),
/// TyKind::Infer means the type should be inferred instead of it having been
/// specified. This can appear anywhere in a type.
TyInfer,
Infer,
/// Placeholder for a type that has failed to be defined.
TyErr,
Err,
}
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]

View File

@ -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(":")?;

View File

@ -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 {

View File

@ -109,20 +109,20 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> {
fn visit_ty(&mut self, arg: &'gcx hir::Ty) {
match arg.node {
hir::TyBareFn(_) => {
hir::TyKind::BareFn(_) => {
self.current_index.shift_in(1);
intravisit::walk_ty(self, arg);
self.current_index.shift_out(1);
return;
}
hir::TyTraitObject(ref bounds, _) => for bound in bounds {
hir::TyKind::TraitObject(ref bounds, _) => for bound in bounds {
self.current_index.shift_in(1);
self.visit_poly_trait_ref(bound, hir::TraitBoundModifier::None);
self.current_index.shift_out(1);
},
hir::TyRptr(ref lifetime, _) => {
hir::TyKind::Rptr(ref lifetime, _) => {
// the lifetime of the TyRptr
let hir_id = self.tcx.hir.node_to_hir_id(lifetime.id);
match (self.tcx.named_region(hir_id), self.bound_region) {
@ -190,8 +190,8 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> {
}
}
}
// Checks if it is of type `hir::TyPath` which corresponds to a struct.
hir::TyPath(_) => {
// Checks if it is of type `hir::TyKind::Path` which corresponds to a struct.
hir::TyKind::Path(_) => {
let subvisitor = &mut TyPathVisitor {
tcx: self.tcx,
found_it: false,
@ -213,7 +213,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> {
}
// The visitor captures the corresponding `hir::Ty` of the anonymous region
// in the case of structs ie. `hir::TyPath`.
// in the case of structs ie. `hir::TyKind::Path`.
// This visitor would be invoked for each lifetime corresponding to a struct,
// and would walk the types like Vec<Ref> in the above example and Ref looking for the HIR
// where that lifetime appears. This allows us to highlight the

View File

@ -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

View File

@ -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()))

View File

@ -1131,7 +1131,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
fn suggest_mut_for_immutable(&self, pty: &hir::Ty, is_implicit_self: bool) -> Option<String> {
// Check whether the argument is an immutable reference
debug!("suggest_mut_for_immutable({:?}, {:?})", pty, is_implicit_self);
if let hir::TyRptr(lifetime, hir::MutTy {
if let hir::TyKind::Rptr(lifetime, hir::MutTy {
mutbl: hir::Mutability::MutImmutable,
ref ty
}) = pty.node {
@ -1259,7 +1259,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
// avoid suggesting `mut &self`.
return
}
if let Some(&hir::TyRptr(
if let Some(&hir::TyKind::Rptr(
_,
hir::MutTy {
mutbl: hir::MutMutable,

View File

@ -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

View File

@ -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);
}

View File

@ -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));
}

View File

@ -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);
}

View File

@ -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
{

View File

@ -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()
}

View File

@ -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);

View File

@ -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

View File

@ -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,

View File

@ -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,

View File

@ -2586,7 +2586,7 @@ pub struct PolyTrait {
/// it does not preserve mutability or boxes.
#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Debug, Hash)]
pub enum Type {
/// structs/enums/traits (most that'd be an hir::TyPath)
/// structs/enums/traits (most that'd be an hir::TyKind::Path)
ResolvedPath {
path: Path,
typarams: Option<Vec<GenericBound>>,