Skip to content
Permalink
Browse files

Rename `Ty.node` to `Ty.kind`

  • Loading branch information...
varkor committed Sep 26, 2019
1 parent d4573c9 commit c3d8791373005ef08c876aa649ede245efd2352d
Showing with 138 additions and 137 deletions.
  1. +1 −1 src/librustc/hir/intravisit.rs
  2. +17 −16 src/librustc/hir/lowering.rs
  3. +2 −2 src/librustc/hir/lowering/item.rs
  4. +1 −1 src/librustc/hir/map/def_collector.rs
  5. +2 −2 src/librustc/hir/mod.rs
  6. +2 −2 src/librustc/hir/print.rs
  7. +2 −2 src/librustc/ich/impls_hir.rs
  8. +1 −1 src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs
  9. +1 −1 src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs
  10. +2 −2 src/librustc/lint/internal.rs
  11. +1 −1 src/librustc/middle/dead.rs
  12. +11 −11 src/librustc/middle/resolve_lifetime.rs
  13. +1 −1 src/librustc/traits/error_reporting.rs
  14. +1 −1 src/librustc_interface/util.rs
  15. +2 −2 src/librustc_lint/builtin.rs
  16. +1 −1 src/librustc_metadata/encoder.rs
  17. +2 −2 src/librustc_mir/borrow_check/conflict_errors.rs
  18. +1 −1 src/librustc_mir/borrow_check/mutability_errors.rs
  19. +2 −2 src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs
  20. +5 −5 src/librustc_passes/ast_validation.rs
  21. +3 −3 src/librustc_privacy/lib.rs
  22. +6 −6 src/librustc_resolve/build_reduced_graph.rs
  23. +1 −1 src/librustc_resolve/late.rs
  24. +1 −1 src/librustc_resolve/late/diagnostics.rs
  25. +2 −2 src/librustc_save_analysis/dump_visitor.rs
  26. +2 −2 src/librustc_save_analysis/lib.rs
  27. +1 −1 src/librustc_save_analysis/sig.rs
  28. +4 −4 src/librustc_typeck/astconv.rs
  29. +2 −2 src/librustc_typeck/check/compare_method.rs
  30. +1 −1 src/librustc_typeck/check/demand.rs
  31. +4 −4 src/librustc_typeck/check/mod.rs
  32. +10 −10 src/librustc_typeck/collect.rs
  33. +2 −2 src/librustdoc/clean/mod.rs
  34. +8 −8 src/libsyntax/ast.rs
  35. +1 −1 src/libsyntax/ext/base.rs
  36. +2 −2 src/libsyntax/ext/build.rs
  37. +2 −2 src/libsyntax/ext/expand.rs
  38. +3 −3 src/libsyntax/ext/placeholders.rs
  39. +2 −2 src/libsyntax/feature_gate/check.rs
  40. +2 −2 src/libsyntax/mut_visit.rs
  41. +5 −5 src/libsyntax/parse/diagnostics.rs
  42. +1 −1 src/libsyntax/parse/parser.rs
  43. +2 −2 src/libsyntax/parse/parser/expr.rs
  44. +3 −3 src/libsyntax/parse/parser/item.rs
  45. +3 −3 src/libsyntax/parse/parser/ty.rs
  46. +2 −2 src/libsyntax/print/pprust.rs
  47. +1 −1 src/libsyntax/visit.rs
  48. +1 −1 src/libsyntax_ext/concat_idents.rs
  49. +2 −2 src/libsyntax_ext/deriving/generic/mod.rs
  50. +1 −1 src/libsyntax_ext/test.rs
@@ -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)
}
@@ -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;
}
@@ -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() =>
@@ -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);
@@ -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,
}

@@ -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(":");
@@ -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);
})
}
@@ -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);
@@ -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;
@@ -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()?;
@@ -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);
@@ -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
@@ -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()]
@@ -738,7 +738,7 @@ impl<'a> ReplaceBodyWithLoop<'a> {
fn should_ignore_fn(ret_ty: &ast::FnDecl) -> bool {
if let ast::FunctionRetTy::Ty(ref ty) = ret_ty.output {
fn involves_impl_trait(ty: &ast::Ty) -> bool {
match ty.node {
match ty.kind {
ast::TyKind::ImplTrait(..) => true,
ast::TyKind::Slice(ref subty) |
ast::TyKind::Array(ref subty, _) |
@@ -1090,7 +1090,7 @@ impl TypeAliasBounds {
match *qpath {
hir::QPath::TypeRelative(ref ty, _) => {
// If this is a type variable, we found a `T::Assoc`.
match ty.node {
match ty.kind {
hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) => {
match path.res {
Res::Def(DefKind::TyParam, _) => true,
@@ -1750,7 +1750,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExplicitOutlivesRequirements {
hir::WherePredicate::BoundPredicate(predicate) => {
// FIXME we can also infer bounds on associated types,
// and should check for them here.
match predicate.bounded_ty.node {
match predicate.bounded_ty.kind {
hir::TyKind::Path(hir::QPath::Resolved(
None,
ref path,
@@ -1799,7 +1799,7 @@ impl EncodeContext<'tcx> {
}

fn encode_info_for_ty(&mut self, ty: &hir::Ty) {
match ty.node {
match ty.kind {
hir::TyKind::Array(_, ref length) => {
let def_id = self.tcx.hir().local_def_id(length.hir_id);
self.record(def_id, EncodeContext::encode_info_for_anon_const, def_id);

0 comments on commit c3d8791

Please sign in to comment.
You can’t perform that action at this time.