Rename Ty.node to Ty.kind

This commit is contained in:
varkor 2019-09-26 17:25:31 +01:00
parent d4573c9c1e
commit c3d8791373
50 changed files with 138 additions and 137 deletions

View file

@ -594,7 +594,7 @@ pub fn walk_variant<'v, V: Visitor<'v>>(visitor: &mut V,
pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) {
visitor.visit_id(typ.hir_id);
match typ.node {
match typ.kind {
TyKind::Slice(ref ty) => {
visitor.visit_ty(ty)
}

View file

@ -346,7 +346,7 @@ struct ImplTraitTypeIdVisitor<'a> { ids: &'a mut SmallVec<[NodeId; 1]> }
impl<'a, 'b> Visitor<'a> for ImplTraitTypeIdVisitor<'b> {
fn visit_ty(&mut self, ty: &'a Ty) {
match ty.node {
match ty.kind {
| TyKind::Typeof(_)
| TyKind::BareFn(_)
=> return,
@ -497,7 +497,7 @@ impl<'a> LoweringContext<'a> {
}
fn visit_ty(&mut self, t: &'tcx Ty) {
match t.node {
match t.kind {
// Mirrors the case in visit::walk_ty
TyKind::BareFn(ref f) => {
walk_list!(
@ -1104,7 +1104,7 @@ impl<'a> LoweringContext<'a> {
let ty = this.lower_ty(
&Ty {
id: this.sess.next_node_id(),
node: TyKind::ImplTrait(impl_trait_node_id, bounds.clone()),
kind: TyKind::ImplTrait(impl_trait_node_id, bounds.clone()),
span: constraint.span,
},
itctx,
@ -1165,14 +1165,14 @@ impl<'a> LoweringContext<'a> {
let id = self.lower_node_id(t.id);
let qpath = self.lower_qpath(t.id, qself, path, param_mode, itctx);
let ty = self.ty_path(id, t.span, qpath);
if let hir::TyKind::TraitObject(..) = ty.node {
if let hir::TyKind::TraitObject(..) = ty.kind {
self.maybe_lint_bare_trait(t.span, t.id, qself.is_none() && path.is_global());
}
ty
}
fn lower_ty_direct(&mut self, t: &Ty, mut itctx: ImplTraitContext<'_>) -> hir::Ty {
let kind = match t.node {
let kind = match t.kind {
TyKind::Infer => hir::TyKind::Infer,
TyKind::Err => hir::TyKind::Err,
TyKind::Slice(ref ty) => hir::TyKind::Slice(self.lower_ty(ty, itctx)),
@ -1345,7 +1345,7 @@ impl<'a> LoweringContext<'a> {
};
hir::Ty {
node: kind,
kind,
span: t.span,
hir_id: self.lower_node_id(t.id),
}
@ -1505,7 +1505,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::TyKind::BareFn(_) = t.node {
if let hir::TyKind::BareFn(_) = t.kind {
let old_collect_elided_lifetimes = self.collect_elided_lifetimes;
self.collect_elided_lifetimes = false;
@ -2026,7 +2026,7 @@ impl<'a> LoweringContext<'a> {
.map(|ty| this.lower_ty_direct(ty, ImplTraitContext::disallowed()))
.collect();
let mk_tup = |this: &mut Self, tys, span| {
hir::Ty { node: hir::TyKind::Tup(tys), hir_id: this.next_id(), span }
hir::Ty { kind: hir::TyKind::Tup(tys), hir_id: this.next_id(), span }
};
(
hir::GenericArgs {
@ -2179,16 +2179,16 @@ impl<'a> LoweringContext<'a> {
_ => false,
};
match arg.ty.node {
match arg.ty.kind {
TyKind::ImplicitSelf if is_mutable_pat => hir::ImplicitSelfKind::Mut,
TyKind::ImplicitSelf => hir::ImplicitSelfKind::Imm,
// Given we are only considering `ImplicitSelf` types, we needn't consider
// the case where we have a mutable pattern to a reference as that would
// no longer be an `ImplicitSelf`.
TyKind::Rptr(_, ref mt) if mt.ty.node.is_implicit_self() &&
TyKind::Rptr(_, ref mt) if mt.ty.kind.is_implicit_self() &&
mt.mutbl == ast::Mutability::Mutable =>
hir::ImplicitSelfKind::MutRef,
TyKind::Rptr(_, ref mt) if mt.ty.node.is_implicit_self() =>
TyKind::Rptr(_, ref mt) if mt.ty.kind.is_implicit_self() =>
hir::ImplicitSelfKind::ImmRef,
_ => hir::ImplicitSelfKind::None,
}
@ -2403,7 +2403,7 @@ impl<'a> LoweringContext<'a> {
let opaque_ty_ref = hir::TyKind::Def(hir::ItemId { id: opaque_ty_id }, generic_args.into());
hir::FunctionRetTy::Return(P(hir::Ty {
node: opaque_ty_ref,
kind: opaque_ty_ref,
span,
hir_id: self.next_id(),
}))
@ -2424,7 +2424,7 @@ impl<'a> LoweringContext<'a> {
FunctionRetTy::Default(ret_ty_span) => {
P(hir::Ty {
hir_id: self.next_id(),
node: hir::TyKind::Tup(hir_vec![]),
kind: hir::TyKind::Tup(hir_vec![]),
span: *ret_ty_span,
})
}
@ -3164,7 +3164,7 @@ impl<'a> LoweringContext<'a> {
}
fn ty_path(&mut self, mut hir_id: hir::HirId, span: Span, qpath: hir::QPath) -> hir::Ty {
let node = match qpath {
let kind = match qpath {
hir::QPath::Resolved(None, path) => {
// Turn trait object paths into `TyKind::TraitObject` instead.
match path.res {
@ -3188,9 +3188,10 @@ impl<'a> LoweringContext<'a> {
}
_ => hir::TyKind::Path(qpath),
};
hir::Ty {
hir_id,
node,
kind,
span,
}
}
@ -3394,7 +3395,7 @@ pub fn is_range_literal(sess: &Session, expr: &hir::Expr) -> bool {
// `..=` desugars into `::std::ops::RangeInclusive::new(...)`.
ExprKind::Call(ref func, _) => {
if let ExprKind::Path(QPath::TypeRelative(ref ty, ref segment)) = func.kind {
if let TyKind::Path(QPath::Resolved(None, ref path)) = ty.node {
if let TyKind::Path(QPath::Resolved(None, ref path)) = ty.kind {
let new_call = segment.ident.as_str() == "new";
return is_range_path(&path) && is_lit(sess, &expr.span) && new_call;
}

View file

@ -789,7 +789,7 @@ impl LoweringContext<'_> {
}
fn lower_struct_field(&mut self, (index, f): (usize, &StructField)) -> hir::StructField {
let ty = if let TyKind::Path(ref qself, ref path) = f.ty.node {
let ty = if let TyKind::Path(ref qself, ref path) = f.ty.kind {
let t = self.lower_path_ty(
&f.ty,
qself,
@ -1343,7 +1343,7 @@ impl LoweringContext<'_> {
);
};
// Check if the where clause type is a plain type parameter.
match bound_pred.bounded_ty.node {
match bound_pred.bounded_ty.kind {
TyKind::Path(None, ref path)
if path.segments.len() == 1
&& bound_pred.bound_generic_params.is_empty() =>

View file

@ -292,7 +292,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
}
fn visit_ty(&mut self, ty: &'a Ty) {
match ty.node {
match ty.kind {
TyKind::Mac(..) => return self.visit_macro_invoc(ty.id),
TyKind::ImplTrait(node_id, _) => {
self.create_def(node_id, DefPathData::ImplTrait, ty.span);

View file

@ -479,7 +479,7 @@ impl GenericArgs {
match arg {
GenericArg::Lifetime(_) => {}
GenericArg::Type(ref ty) => {
if let TyKind::Tup(ref tys) = ty.node {
if let TyKind::Tup(ref tys) = ty.kind {
return tys;
}
break;
@ -1939,7 +1939,7 @@ impl TypeBinding {
#[derive(RustcEncodable, RustcDecodable)]
pub struct Ty {
pub hir_id: HirId,
pub node: TyKind,
pub kind: TyKind,
pub span: Span,
}

View file

@ -286,7 +286,7 @@ impl<'a> State<'a> {
pub fn print_type(&mut self, ty: &hir::Ty) {
self.maybe_print_comment(ty.span.lo());
self.ibox(0);
match ty.node {
match ty.kind {
hir::TyKind::Slice(ref ty) => {
self.s.word("[");
self.print_type(&ty);
@ -1880,7 +1880,7 @@ impl<'a> State<'a> {
s.ann.nested(s, Nested::BodyParamPat(body_id, i));
i += 1;
if let hir::TyKind::Infer = ty.node {
if let hir::TyKind::Infer = ty.kind {
// Print nothing.
} else {
s.s.word(":");

View file

@ -144,11 +144,11 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::Ty {
hcx.while_hashing_hir_bodies(true, |hcx| {
let hir::Ty {
hir_id: _,
ref node,
ref kind,
ref span,
} = *self;
node.hash_stable(hcx, hasher);
kind.hash_stable(hcx, hasher);
span.hash_stable(hcx, hasher);
})
}

View file

@ -98,7 +98,7 @@ impl Visitor<'tcx> for FindNestedTypeVisitor<'tcx> {
}
fn visit_ty(&mut self, arg: &'tcx hir::Ty) {
match arg.node {
match arg.kind {
hir::TyKind::BareFn(_) => {
self.current_index.shift_in(1);
intravisit::walk_ty(self, arg);

View file

@ -87,7 +87,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
return None;
}
if let FunctionRetTy::Return(ty) = &fndecl.output {
if let (TyKind::Def(_, _), ty::ReStatic) = (&ty.node, sub) {
if let (TyKind::Def(_, _), ty::ReStatic) = (&ty.kind, sub) {
// This is an impl Trait return that evaluates de need of 'static.
// We handle this case better in `static_impl_trait`.
return None;

View file

@ -94,7 +94,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TyTyKind {
}
fn check_ty(&mut self, cx: &LateContext<'_, '_>, ty: &'tcx Ty) {
match &ty.node {
match &ty.kind {
TyKind::Path(qpath) => {
if let QPath::Resolved(_, path) = qpath {
if let Some(last) = path.segments.iter().last() {
@ -169,7 +169,7 @@ fn lint_ty_kind_usage(cx: &LateContext<'_, '_>, segment: &PathSegment) -> bool {
}
fn is_ty_or_ty_ctxt(cx: &LateContext<'_, '_>, ty: &Ty) -> Option<String> {
match &ty.node {
match &ty.kind {
TyKind::Path(qpath) => {
if let QPath::Resolved(_, path) = qpath {
let did = path.res.opt_def_id()?;

View file

@ -292,7 +292,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> {
}
fn visit_ty(&mut self, ty: &'tcx hir::Ty) {
match ty.node {
match ty.kind {
TyKind::Def(item_id, _) => {
let item = self.tcx.hir().expect_item(item_id.id);
intravisit::walk_item(self, item);

View file

@ -558,8 +558,8 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
fn visit_ty(&mut self, ty: &'tcx hir::Ty) {
debug!("visit_ty: id={:?} ty={:?}", ty.hir_id, ty);
debug!("visit_ty: ty.node={:?}", ty.node);
match ty.node {
debug!("visit_ty: ty.kind={:?}", ty.kind);
match ty.kind {
hir::TyKind::BareFn(ref c) => {
let next_early_index = self.next_early_index();
let was_in_fn_syntax = self.is_in_fn_syntax;
@ -1352,7 +1352,7 @@ fn object_lifetime_defaults_for_item(
continue;
}
let res = match data.bounded_ty.node {
let res = match data.bounded_ty.kind {
hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) => path.res,
_ => continue,
};
@ -1487,7 +1487,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
let mut elide_use = None;
let mut find_arg_use_span = |inputs: &hir::HirVec<hir::Ty>| {
for input in inputs {
match input.node {
match input.kind {
hir::TyKind::Rptr(lt, _) => {
if lt.name.ident() == name {
// include the trailing whitespace between the lifetime and type names
@ -2270,8 +2270,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
}
fn visit_ty(&mut self, ty: &'a hir::Ty) {
if let hir::TyKind::Rptr(lifetime_ref, ref mt) = ty.node {
if let hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) = mt.ty.node
if let hir::TyKind::Rptr(lifetime_ref, ref mt) = ty.kind {
if let hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) = mt.ty.kind
{
if self.is_self_ty(path.res) {
if let Some(lifetime) = self.map.defs.get(&lifetime_ref.hir_id) {
@ -2286,7 +2286,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
let mut visitor = SelfVisitor {
map: self.map,
impl_self: impl_self.map(|ty| &ty.node),
impl_self: impl_self.map(|ty| &ty.kind),
lifetime: Set1::Empty,
};
visitor.visit_ty(&inputs[0]);
@ -2364,10 +2364,10 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
}
fn visit_ty(&mut self, ty: &hir::Ty) {
if let hir::TyKind::BareFn(_) = ty.node {
if let hir::TyKind::BareFn(_) = ty.kind {
self.outer_index.shift_in(1);
}
match ty.node {
match ty.kind {
hir::TyKind::TraitObject(ref bounds, ref lifetime) => {
for bound in bounds {
self.visit_poly_trait_ref(bound, hir::TraitBoundModifier::None);
@ -2384,7 +2384,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
intravisit::walk_ty(self, ty);
}
}
if let hir::TyKind::BareFn(_) = ty.node {
if let hir::TyKind::BareFn(_) = ty.kind {
self.outer_index.shift_out(1);
}
}
@ -2991,7 +2991,7 @@ fn insert_late_bound_lifetimes(
}
fn visit_ty(&mut self, ty: &'v hir::Ty) {
match ty.node {
match ty.kind {
hir::TyKind::Path(hir::QPath::Resolved(Some(_), _))
| hir::TyKind::Path(hir::QPath::TypeRelative(..)) => {
// ignore lifetimes appearing in associated type

View file

@ -1177,7 +1177,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
..
}) => {
(self.tcx.sess.source_map().def_span(span), decl.inputs.iter()
.map(|arg| match arg.clone().node {
.map(|arg| match arg.clone().kind {
hir::TyKind::Tup(ref tys) => ArgKind::Tuple(
Some(arg.span),
vec![("_".to_owned(), "_".to_owned()); tys.len()]