Rename Ty.node
to Ty.kind
This commit is contained in:
parent
d4573c9c1e
commit
c3d8791373
@ -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 @@ enum AnonymousLifetimeMode {
|
||||
|
||||
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 @@ fn visit_foreign_item(&mut self, i: &'tcx ForeignItem) {
|
||||
}
|
||||
|
||||
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 @@ fn lower_assoc_ty_constraint(
|
||||
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 @@ fn lower_path_ty(
|
||||
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 @@ fn lower_ty_direct(&mut self, t: &Ty, mut itctx: ImplTraitContext<'_>) -> hir::T
|
||||
};
|
||||
|
||||
hir::Ty {
|
||||
node: kind,
|
||||
kind,
|
||||
span: t.span,
|
||||
hir_id: self.lower_node_id(t.id),
|
||||
}
|
||||
@ -1505,7 +1505,7 @@ fn visit_generic_args(&mut self, span: Span, parameters: &'v hir::GenericArgs) {
|
||||
|
||||
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 @@ fn lower_parenthesized_parameter_data(
|
||||
.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 @@ fn lower_fn_decl(
|
||||
_ => 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 @@ fn lower_async_fn_ret_ty(
|
||||
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 @@ fn lower_async_fn_output_type_to_future_bound(
|
||||
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 @@ fn std_path(
|
||||
}
|
||||
|
||||
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 @@ fn ty_path(&mut self, mut hir_id: hir::HirId, span: Span, qpath: hir::QPath) ->
|
||||
}
|
||||
_ => hir::TyKind::Path(qpath),
|
||||
};
|
||||
|
||||
hir::Ty {
|
||||
hir_id,
|
||||
node,
|
||||
kind,
|
||||
span,
|
||||
}
|
||||
}
|
||||
@ -3394,7 +3395,7 @@ fn is_lit(sess: &Session, span: &Span) -> 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 @@ fn lower_variant_data(&mut self, vdata: &VariantData) -> hir::VariantData {
|
||||
}
|
||||
|
||||
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 @@ pub(super) fn lower_generics(
|
||||
);
|
||||
};
|
||||
// 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 @@ fn visit_expr(&mut self, expr: &'a Expr) {
|
||||
}
|
||||
|
||||
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 @@ pub fn inputs(&self) -> &[Ty] {
|
||||
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 @@ pub fn ty(&self) -> &Ty {
|
||||
#[derive(RustcEncodable, RustcDecodable)]
|
||||
pub struct Ty {
|
||||
pub hir_id: HirId,
|
||||
pub node: TyKind,
|
||||
pub kind: TyKind,
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
|
@ -286,7 +286,7 @@ pub fn print_opt_lifetime(&mut self, lifetime: &hir::Lifetime) {
|
||||
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 @@ fn print_closure_params(&mut self, decl: &hir::FnDecl, body_id: hir::BodyId) {
|
||||
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 @@ fn hash_stable<W: StableHasherResult>(&self,
|
||||
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 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, '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 @@ pub(super) fn try_report_named_anon_conflict(&self) -> Option<DiagnosticBuilder<
|
||||
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 @@ fn check_path(&mut self, cx: &LateContext<'_, '_>, path: &'tcx Path, _: HirId) {
|
||||
}
|
||||
|
||||
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 @@ fn visit_path(&mut self, path: &'tcx hir::Path, _: hir::HirId) {
|
||||
}
|
||||
|
||||
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 @@ fn visit_foreign_item(&mut self, item: &'tcx hir::ForeignItem) {
|
||||
|
||||
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 add_bounds(set: &mut Set1<hir::LifetimeName>, bounds: &[hir::GenericBound]) {
|
||||
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 @@ fn suggest_eliding_single_use_lifetime(
|
||||
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 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'a> {
|
||||
}
|
||||
|
||||
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 @@ fn visit_ty(&mut self, ty: &'a hir::Ty) {
|
||||
|
||||
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 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'v> {
|
||||
}
|
||||
|
||||
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 @@ fn visit_ty(&mut self, ty: &hir::Ty) {
|
||||
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 nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'v> {
|
||||
}
|
||||
|
||||
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 @@ pub fn get_fn_like_arguments(&self, node: Node<'_>) -> (Span, Vec<ArgKind>) {
|
||||
..
|
||||
}) => {
|
||||
(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 @@ fn run<R, F: FnOnce(&mut Self) -> R>(&mut self, is_const: bool, action: F) -> R
|
||||
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 @@ fn is_type_variable_assoc(qpath: &hir::QPath) -> bool {
|
||||
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 @@ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) {
|
||||
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 @@ fn encode_info_for_generics(&mut self, generics: &hir::Generics) {
|
||||
}
|
||||
|
||||
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);
|
||||
|
@ -1845,7 +1845,7 @@ fn annotate_fn_sig(
|
||||
// Need to use the `rustc::ty` types to compare against the
|
||||
// `return_region`. Then use the `rustc::hir` type to get only
|
||||
// the lifetime span.
|
||||
if let hir::TyKind::Rptr(lifetime, _) = &fn_decl.inputs[index].node {
|
||||
if let hir::TyKind::Rptr(lifetime, _) = &fn_decl.inputs[index].kind {
|
||||
// With access to the lifetime, we can get
|
||||
// the span of it.
|
||||
arguments.push((*argument, lifetime.span));
|
||||
@ -1866,7 +1866,7 @@ fn annotate_fn_sig(
|
||||
let return_ty = *sig.output().skip_binder();
|
||||
let mut return_span = fn_decl.output.span();
|
||||
if let hir::FunctionRetTy::Return(ty) = &fn_decl.output {
|
||||
if let hir::TyKind::Rptr(lifetime, _) = ty.node {
|
||||
if let hir::TyKind::Rptr(lifetime, _) = ty.kind {
|
||||
return_span = lifetime.span;
|
||||
}
|
||||
}
|
||||
|
@ -642,7 +642,7 @@ fn annotate_struct_field(
|
||||
if let hir::TyKind::Rptr(lifetime, hir::MutTy {
|
||||
mutbl: hir::Mutability::MutImmutable,
|
||||
ref ty
|
||||
}) = field.ty.node {
|
||||
}) = field.ty.kind {
|
||||
// Get the snippets in two parts - the named lifetime (if there is one) and
|
||||
// type being referenced, that way we can reconstruct the snippet without loss
|
||||
// of detail.
|
||||
|
@ -425,7 +425,7 @@ fn give_name_if_we_can_match_hir_ty_from_argument(
|
||||
let mir_hir_id = infcx.tcx.hir().as_local_hir_id(mir_def_id)?;
|
||||
let fn_decl = infcx.tcx.hir().fn_decl_by_hir_id(mir_hir_id)?;
|
||||
let argument_hir_ty: &hir::Ty = &fn_decl.inputs[argument_index];
|
||||
match argument_hir_ty.node {
|
||||
match argument_hir_ty.kind {
|
||||
// This indicates a variable with no type annotation, like
|
||||
// `|x|`... in that case, we can't highlight the type but
|
||||
// must highlight the variable.
|
||||
@ -527,7 +527,7 @@ fn give_name_if_we_can_match_hir_ty(
|
||||
&mut vec![(argument_ty, argument_hir_ty)];
|
||||
|
||||
while let Some((ty, hir_ty)) = search_stack.pop() {
|
||||
match (&ty.kind, &hir_ty.node) {
|
||||
match (&ty.kind, &hir_ty.kind) {
|
||||
// Check if the `argument_ty` is `&'X ..` where `'X`
|
||||
// is the region we are looking for -- if so, and we have a `&T`
|
||||
// on the RHS, then we want to highlight the `&` like so:
|
||||
|
@ -107,7 +107,7 @@ fn visit_assoc_ty_constraint_from_generic_args(&mut self, constraint: &'a AssocT
|
||||
// rust-lang/rust#57979: bug in old `visit_generic_args` called
|
||||
// `walk_ty` rather than `visit_ty`, skipping outer `impl Trait`
|
||||
// if it happened to occur at `ty`.
|
||||
if let TyKind::ImplTrait(..) = ty.node {
|
||||
if let TyKind::ImplTrait(..) = ty.kind {
|
||||
self.warning_period_57979_didnt_record_next_impl_trait = true;
|
||||
}
|
||||
}
|
||||
@ -126,7 +126,7 @@ fn visit_ty_from_generic_args(&mut self, ty: &'a Ty) {
|
||||
// rust-lang/rust#57979: bug in old `visit_generic_args` called
|
||||
// `walk_ty` rather than `visit_ty`, skippping outer `impl Trait`
|
||||
// if it happened to occur at `ty`.
|
||||
if let TyKind::ImplTrait(..) = ty.node {
|
||||
if let TyKind::ImplTrait(..) = ty.kind {
|
||||
self.warning_period_57979_didnt_record_next_impl_trait = true;
|
||||
}
|
||||
self.visit_ty(ty);
|
||||
@ -149,7 +149,7 @@ fn outer_impl_trait(&mut self, span: Span) -> OuterImplTrait {
|
||||
|
||||
// Mirrors `visit::walk_ty`, but tracks relevant state.
|
||||
fn walk_ty(&mut self, t: &'a Ty) {
|
||||
match t.node {
|
||||
match t.kind {
|
||||
TyKind::ImplTrait(..) => {
|
||||
let outer_impl_trait = self.outer_impl_trait(t.span);
|
||||
self.with_impl_trait(Some(outer_impl_trait), |this| visit::walk_ty(this, t))
|
||||
@ -456,7 +456,7 @@ fn visit_expr(&mut self, expr: &'a Expr) {
|
||||
}
|
||||
|
||||
fn visit_ty(&mut self, ty: &'a Ty) {
|
||||
match ty.node {
|
||||
match ty.kind {
|
||||
TyKind::BareFn(ref bfty) => {
|
||||
self.check_fn_decl(&bfty.decl);
|
||||
self.check_decl_no_pat(&bfty.decl, |span, _| {
|
||||
@ -541,7 +541,7 @@ fn visit_item(&mut self, item: &'a Item) {
|
||||
match item.node {
|
||||
ItemKind::Impl(unsafety, polarity, _, _, Some(..), ref ty, ref impl_items) => {
|
||||
self.invalid_visibility(&item.vis, None);
|
||||
if let TyKind::Err = ty.node {
|
||||
if let TyKind::Err = ty.kind {
|
||||
self.err_handler()
|
||||
.struct_span_err(item.span, "`impl Trait for .. {}` is an obsolete syntax")
|
||||
.help("use `auto trait Trait {}` instead").emit();
|
||||
|
@ -1389,14 +1389,14 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'v> {
|
||||
}
|
||||
|
||||
fn visit_ty(&mut self, ty: &hir::Ty) {
|
||||
if let hir::TyKind::Path(hir::QPath::Resolved(_, ref path)) = ty.node {
|
||||
if let hir::TyKind::Path(hir::QPath::Resolved(_, ref path)) = ty.kind {
|
||||
if self.inner.path_is_private_type(path) {
|
||||
self.contains_private = true;
|
||||
// Found what we're looking for, so let's stop working.
|
||||
return
|
||||
}
|
||||
}
|
||||
if let hir::TyKind::Path(_) = ty.node {
|
||||
if let hir::TyKind::Path(_) = ty.kind {
|
||||
if self.at_outer_type {
|
||||
self.outer_type_is_public_path = true;
|
||||
}
|
||||
@ -1628,7 +1628,7 @@ fn visit_foreign_item(&mut self, item: &'tcx hir::ForeignItem) {
|
||||
}
|
||||
|
||||
fn visit_ty(&mut self, t: &'tcx hir::Ty) {
|
||||
if let hir::TyKind::Path(hir::QPath::Resolved(_, ref path)) = t.node {
|
||||
if let hir::TyKind::Path(hir::QPath::Resolved(_, ref path)) = t.kind {
|
||||
if self.path_is_private_type(path) {
|
||||
self.old_error_set.insert(t.hir_id);
|
||||
}
|
||||
|
@ -1120,9 +1120,9 @@ fn define_macro(&mut self, item: &ast::Item) -> LegacyScope<'a> {
|
||||
}
|
||||
|
||||
macro_rules! method {
|
||||
($visit:ident: $ty:ty, $invoc:path, $walk:ident, $kind:ident) => {
|
||||
($visit:ident: $ty:ty, $invoc:path, $walk:ident) => {
|
||||
fn $visit(&mut self, node: &'b $ty) {
|
||||
if let $invoc(..) = node.$kind {
|
||||
if let $invoc(..) = node.kind {
|
||||
self.visit_invoc(node.id);
|
||||
} else {
|
||||
visit::$walk(self, node);
|
||||
@ -1132,10 +1132,10 @@ fn $visit(&mut self, node: &'b $ty) {
|
||||
}
|
||||
|
||||
impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> {
|
||||
method!(visit_impl_item: ast::ImplItem, ast::ImplItemKind::Macro, walk_impl_item, kind);
|
||||
method!(visit_expr: ast::Expr, ast::ExprKind::Mac, walk_expr, kind);
|
||||
method!(visit_pat: ast::Pat, ast::PatKind::Mac, walk_pat, kind);
|
||||
method!(visit_ty: ast::Ty, ast::TyKind::Mac, walk_ty, node);
|
||||
method!(visit_impl_item: ast::ImplItem, ast::ImplItemKind::Macro, walk_impl_item);
|
||||
method!(visit_expr: ast::Expr, ast::ExprKind::Mac, walk_expr);
|
||||
method!(visit_pat: ast::Pat, ast::PatKind::Mac, walk_pat);
|
||||
method!(visit_ty: ast::Ty, ast::TyKind::Mac, walk_ty);
|
||||
|
||||
fn visit_item(&mut self, item: &'b Item) {
|
||||
let macro_use = match item.node {
|
||||
|
@ -384,7 +384,7 @@ fn visit_local(&mut self, local: &'tcx Local) {
|
||||
self.resolve_local(local);
|
||||
}
|
||||
fn visit_ty(&mut self, ty: &'tcx Ty) {
|
||||
match ty.node {
|
||||
match ty.kind {
|
||||
TyKind::Path(ref qself, ref path) => {
|
||||
self.smart_resolve_path(ty.id, qself.as_ref(), path, PathSource::Type);
|
||||
}
|
||||
|
@ -472,7 +472,7 @@ fn lookup_assoc_candidate<FilterFn>(&mut self,
|
||||
where FilterFn: Fn(Res) -> bool
|
||||
{
|
||||
fn extract_node_id(t: &Ty) -> Option<NodeId> {
|
||||
match t.node {
|
||||
match t.kind {
|
||||
TyKind::Path(None, _) => Some(t.id),
|
||||
TyKind::Rptr(_, ref mut_ty) => extract_node_id(&mut_ty.ty),
|
||||
// This doesn't handle the remaining `Ty` variants as they are not
|
||||
|
@ -385,7 +385,7 @@ fn process_fn(
|
||||
}
|
||||
|
||||
if let ast::FunctionRetTy::Ty(ref ret_ty) = decl.output {
|
||||
if let ast::TyKind::ImplTrait(..) = ret_ty.node {
|
||||
if let ast::TyKind::ImplTrait(..) = ret_ty.kind {
|
||||
// FIXME: Opaque type desugaring prevents us from easily
|
||||
// processing trait bounds. See `visit_ty` for more details.
|
||||
} else {
|
||||
@ -1421,7 +1421,7 @@ fn visit_generics(&mut self, generics: &'l ast::Generics) {
|
||||
|
||||
fn visit_ty(&mut self, t: &'l ast::Ty) {
|
||||
self.process_macro_use(t.span);
|
||||
match t.node {
|
||||
match t.kind {
|
||||
ast::TyKind::Path(_, ref path) => {
|
||||
if generated_code(t.span) {
|
||||
return;
|
||||
|
@ -301,7 +301,7 @@ pub fn get_item_data(&self, item: &ast::Item) -> Option<Data> {
|
||||
}))
|
||||
}
|
||||
ast::ItemKind::Impl(.., ref trait_ref, ref typ, ref impls) => {
|
||||
if let ast::TyKind::Path(None, ref path) = typ.node {
|
||||
if let ast::TyKind::Path(None, ref path) = typ.kind {
|
||||
// Common case impl for a struct or something basic.
|
||||
if generated_code(path.span) {
|
||||
return None;
|
||||
@ -652,7 +652,7 @@ pub fn get_path_res(&self, id: NodeId) -> Res {
|
||||
..
|
||||
}) |
|
||||
Node::Ty(&hir::Ty {
|
||||
node: hir::TyKind::Path(ref qpath),
|
||||
kind: hir::TyKind::Path(ref qpath),
|
||||
..
|
||||
}) => {
|
||||
self.tables.qpath_res(qpath, hir_id)
|
||||
|
@ -160,7 +160,7 @@ fn text_sig(text: String) -> Signature {
|
||||
impl Sig for ast::Ty {
|
||||
fn make(&self, offset: usize, _parent_id: Option<NodeId>, scx: &SaveContext<'_, '_>) -> Result {
|
||||
let id = Some(self.id);
|
||||
match self.node {
|
||||
match self.kind {
|
||||
ast::TyKind::Slice(ref ty) => {
|
||||
let nested = ty.make(offset + 1, id, scx)?;
|
||||
let text = format!("[{}]", nested.text);
|
||||
|
@ -2075,11 +2075,11 @@ pub fn res_to_ty(&self,
|
||||
/// internal notion of a type.
|
||||
pub fn ast_ty_to_ty(&self, ast_ty: &hir::Ty) -> Ty<'tcx> {
|
||||
debug!("ast_ty_to_ty(id={:?}, ast_ty={:?} ty_ty={:?})",
|
||||
ast_ty.hir_id, ast_ty, ast_ty.node);
|
||||
ast_ty.hir_id, ast_ty, ast_ty.kind);
|
||||
|
||||
let tcx = self.tcx();
|
||||
|
||||
let result_ty = match ast_ty.node {
|
||||
let result_ty = match ast_ty.kind {
|
||||
hir::TyKind::Slice(ref ty) => {
|
||||
tcx.mk_slice(self.ast_ty_to_ty(&ty))
|
||||
}
|
||||
@ -2123,7 +2123,7 @@ pub fn ast_ty_to_ty(&self, ast_ty: &hir::Ty) -> Ty<'tcx> {
|
||||
debug!("ast_ty_to_ty: qself={:?} segment={:?}", qself, segment);
|
||||
let ty = self.ast_ty_to_ty(qself);
|
||||
|
||||
let res = if let hir::TyKind::Path(hir::QPath::Resolved(_, ref path)) = qself.node {
|
||||
let res = if let hir::TyKind::Path(hir::QPath::Resolved(_, ref path)) = qself.kind {
|
||||
path.res
|
||||
} else {
|
||||
Res::Err
|
||||
@ -2270,7 +2270,7 @@ pub fn ty_of_arg(&self,
|
||||
expected_ty: Option<Ty<'tcx>>)
|
||||
-> Ty<'tcx>
|
||||
{
|
||||
match ty.node {
|
||||
match ty.kind {
|
||||
hir::TyKind::Infer if expected_ty.is_some() => {
|
||||
self.record_ty(ty.hir_id, expected_ty.unwrap(), ty.span);
|
||||
expected_ty.unwrap()
|
||||
|
@ -445,7 +445,7 @@ fn extract_spans_for_error_reporting<'a, 'tcx>(
|
||||
};
|
||||
|
||||
impl_m_iter.zip(trait_m_iter).find(|&(ref impl_arg, ref trait_arg)| {
|
||||
match (&impl_arg.node, &trait_arg.node) {
|
||||
match (&impl_arg.kind, &trait_arg.kind) {
|
||||
(&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
|
||||
@ -892,7 +892,7 @@ impl<'v> hir::intravisit::Visitor<'v> for Visitor {
|
||||
fn visit_ty(&mut self, ty: &'v hir::Ty) {
|
||||
hir::intravisit::walk_ty(self, ty);
|
||||
if let hir::TyKind::Path(
|
||||
hir::QPath::Resolved(None, ref path)) = ty.node
|
||||
hir::QPath::Resolved(None, ref path)) = ty.kind
|
||||
{
|
||||
if let Res::Def(DefKind::TyParam, def_id) = path.res {
|
||||
if def_id == self.1 {
|
||||
|
@ -596,7 +596,7 @@ pub fn check_for_cast(
|
||||
if let (
|
||||
hir::TyKind::Path(hir::QPath::Resolved(None, base_ty_path)),
|
||||
sym::from,
|
||||
) = (&base_ty.node, path_segment.ident.name) {
|
||||
) = (&base_ty.kind, path_segment.ident.name) {
|
||||
if let Some(ident) = &base_ty_path.segments.iter().map(|s| s.ident).next() {
|
||||
match ident.name {
|
||||
sym::i128 | sym::i64 | sym::i32 | sym::i16 | sym::i8 |
|
||||
|
@ -886,7 +886,7 @@ fn typeck_tables_of(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::TypeckTables<'_> {
|
||||
fcx
|
||||
} else {
|
||||
let fcx = FnCtxt::new(&inh, param_env, body.value.hir_id);
|
||||
let expected_type = body_ty.and_then(|ty| match ty.node {
|
||||
let expected_type = body_ty.and_then(|ty| match ty.kind {
|
||||
hir::TyKind::Infer => Some(AstConv::ast_ty_to_ty(&fcx, ty)),
|
||||
_ => None
|
||||
}).unwrap_or_else(|| tcx.type_of(def_id));
|
||||
@ -3509,7 +3509,7 @@ fn point_at_type_arg_instead_of_call_if_possible(
|
||||
if let hir::GenericArg::Type(hir_ty) = &arg {
|
||||
if let hir::TyKind::Path(
|
||||
hir::QPath::TypeRelative(..),
|
||||
) = &hir_ty.node {
|
||||
) = &hir_ty.kind {
|
||||
// Avoid ICE with associated types. As this is best
|
||||
// effort only, it's ok to ignore the case. It
|
||||
// would trigger in `is_send::<T::AssocType>();`
|
||||
@ -3722,7 +3722,7 @@ fn finish_resolving_struct_path(&self,
|
||||
QPath::TypeRelative(ref qself, ref segment) => {
|
||||
let ty = self.to_ty(qself);
|
||||
|
||||
let res = if let hir::TyKind::Path(QPath::Resolved(_, ref path)) = qself.node {
|
||||
let res = if let hir::TyKind::Path(QPath::Resolved(_, ref path)) = qself.kind {
|
||||
path.res
|
||||
} else {
|
||||
Res::Err
|
||||
@ -4450,7 +4450,7 @@ fn suggest_missing_return_type(
|
||||
(&hir::FunctionRetTy::Return(ref ty), _, _, _) => {
|
||||
// Only point to return type if the expected type is the return type, as if they
|
||||
// are not, the expectation must have been caused by something else.
|
||||
debug!("suggest_missing_return_type: return type {:?} node {:?}", ty, ty.node);
|
||||
debug!("suggest_missing_return_type: return type {:?} node {:?}", ty, ty.kind);
|
||||
let sp = ty.span;
|
||||
let ty = AstConv::ast_ty_to_ty(self, ty);
|
||||
debug!("suggest_missing_return_type: return type {:?}", ty);
|
||||
|
@ -387,7 +387,7 @@ fn type_parameter_bounds_in_generics(
|
||||
/// `ast_ty_to_ty`, because we want to avoid triggering an all-out
|
||||
/// conversion of the type to avoid inducing unnecessary cycles.
|
||||
fn is_param(tcx: TyCtxt<'_>, ast_ty: &hir::Ty, param_id: hir::HirId) -> bool {
|
||||
if let hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) = ast_ty.node {
|
||||
if let hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) = ast_ty.kind {
|
||||
match path.res {
|
||||
Res::SelfTy(Some(def_id), None) | Res::Def(DefKind::TyParam, def_id) => {
|
||||
def_id == tcx.hir().local_def_id(param_id)
|
||||
@ -796,7 +796,7 @@ fn visit_ty(&mut self, ty: &'tcx hir::Ty) {
|
||||
if self.has_late_bound_regions.is_some() {
|
||||
return;
|
||||
}
|
||||
match ty.node {
|
||||
match ty.kind {
|
||||
hir::TyKind::BareFn(..) => {
|
||||
self.outer_index.shift_in(1);
|
||||
intravisit::walk_ty(self, ty);
|
||||
@ -1214,7 +1214,7 @@ pub fn checked_type_of(tcx: TyCtxt<'_>, def_id: DefId, fail: bool) -> Option<Ty<
|
||||
}
|
||||
TraitItemKind::Const(ref ty, body_id) => {
|
||||
body_id.and_then(|body_id| {
|
||||
if let hir::TyKind::Infer = ty.node {
|
||||
if let hir::TyKind::Infer = ty.kind {
|
||||
Some(infer_placeholder_type(tcx, def_id, body_id, ty.span, item.ident))
|
||||
} else {
|
||||
None
|
||||
@ -1236,7 +1236,7 @@ pub fn checked_type_of(tcx: TyCtxt<'_>, def_id: DefId, fail: bool) -> Option<Ty<
|
||||
tcx.mk_fn_def(def_id, substs)
|
||||
}
|
||||
ImplItemKind::Const(ref ty, body_id) => {
|
||||
if let hir::TyKind::Infer = ty.node {
|
||||
if let hir::TyKind::Infer = ty.kind {
|
||||
infer_placeholder_type(tcx, def_id, body_id, ty.span, item.ident)
|
||||
} else {
|
||||
icx.to_ty(ty)
|
||||
@ -1268,7 +1268,7 @@ pub fn checked_type_of(tcx: TyCtxt<'_>, def_id: DefId, fail: bool) -> Option<Ty<
|
||||
match item.node {
|
||||
ItemKind::Static(ref ty, .., body_id)
|
||||
| ItemKind::Const(ref ty, body_id) => {
|
||||
if let hir::TyKind::Infer = ty.node {
|
||||
if let hir::TyKind::Infer = ty.kind {
|
||||
infer_placeholder_type(tcx, def_id, body_id, ty.span, item.ident)
|
||||
} else {
|
||||
icx.to_ty(ty)
|
||||
@ -1373,11 +1373,11 @@ pub fn checked_type_of(tcx: TyCtxt<'_>, def_id: DefId, fail: bool) -> Option<Ty<
|
||||
let parent_node = tcx.hir().get(tcx.hir().get_parent_node(hir_id));
|
||||
match parent_node {
|
||||
Node::Ty(&hir::Ty {
|
||||
node: hir::TyKind::Array(_, ref constant),
|
||||
kind: hir::TyKind::Array(_, ref constant),
|
||||
..
|
||||
})
|
||||
| Node::Ty(&hir::Ty {
|
||||
node: hir::TyKind::Typeof(ref constant),
|
||||
kind: hir::TyKind::Typeof(ref constant),
|
||||
..
|
||||
})
|
||||
| Node::Expr(&hir::Expr {
|
||||
@ -1399,13 +1399,13 @@ pub fn checked_type_of(tcx: TyCtxt<'_>, def_id: DefId, fail: bool) -> Option<Ty<
|
||||
.to_ty(tcx)
|
||||
}
|
||||
|
||||
Node::Ty(&hir::Ty { node: hir::TyKind::Path(_), .. }) |
|
||||
Node::Ty(&hir::Ty { kind: hir::TyKind::Path(_), .. }) |
|
||||
Node::Expr(&hir::Expr { kind: ExprKind::Struct(..), .. }) |
|
||||
Node::Expr(&hir::Expr { kind: ExprKind::Path(_), .. }) |
|
||||
Node::TraitRef(..) => {
|
||||
let path = match parent_node {
|
||||
Node::Ty(&hir::Ty {
|
||||
node: hir::TyKind::Path(QPath::Resolved(_, ref path)),
|
||||
kind: hir::TyKind::Path(QPath::Resolved(_, ref path)),
|
||||
..
|
||||
})
|
||||
| Node::Expr(&hir::Expr {
|
||||
@ -1769,7 +1769,7 @@ fn visit_trait_item(&mut self, it: &'tcx TraitItem) {
|
||||
|
||||
pub fn get_infer_ret_ty(output: &'_ hir::FunctionRetTy) -> Option<&hir::Ty> {
|
||||
if let hir::FunctionRetTy::Return(ref ty) = output {
|
||||
if let hir::TyKind::Infer = ty.node {
|
||||
if let hir::TyKind::Infer = ty.kind {
|
||||
return Some(&**ty)
|
||||
}
|
||||
}
|
||||
|
@ -2835,7 +2835,7 @@ impl Clean<Type> for hir::Ty {
|
||||
fn clean(&self, cx: &DocContext<'_>) -> Type {
|
||||
use rustc::hir::*;
|
||||
|
||||
match self.node {
|
||||
match self.kind {
|
||||
TyKind::Never => Never,
|
||||
TyKind::Ptr(ref m) => RawPointer(m.mutbl.clean(cx), box m.ty.clean(cx)),
|
||||
TyKind::Rptr(ref l, ref m) => {
|
||||
@ -3031,7 +3031,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Type {
|
||||
}
|
||||
TyKind::BareFn(ref barefn) => BareFunction(box barefn.clean(cx)),
|
||||
TyKind::Infer | TyKind::Err => Infer,
|
||||
TyKind::Typeof(..) => panic!("unimplemented type {:?}", self.node),
|
||||
TyKind::Typeof(..) => panic!("unimplemented type {:?}", self.kind),
|
||||
TyKind::CVarArgs(_) => CVarArgs,
|
||||
}
|
||||
}
|
||||
|
@ -525,7 +525,7 @@ impl Pat {
|
||||
/// Attempt reparsing the pattern as a type.
|
||||
/// This is intended for use by diagnostics.
|
||||
pub(super) fn to_ty(&self) -> Option<P<Ty>> {
|
||||
let node = match &self.kind {
|
||||
let kind = match &self.kind {
|
||||
// In a type expression `_` is an inference variable.
|
||||
PatKind::Wild => TyKind::Infer,
|
||||
// An IDENT pattern with no binding mode would be valid as path to a type. E.g. `u32`.
|
||||
@ -555,7 +555,7 @@ pub(super) fn to_ty(&self) -> Option<P<Ty>> {
|
||||
};
|
||||
|
||||
Some(P(Ty {
|
||||
node,
|
||||
kind,
|
||||
id: self.id,
|
||||
span: self.span,
|
||||
}))
|
||||
@ -1051,7 +1051,7 @@ pub(super) fn to_ty(&self) -> Option<P<Ty>> {
|
||||
};
|
||||
|
||||
Some(P(Ty {
|
||||
node: kind,
|
||||
kind,
|
||||
id: self.id,
|
||||
span: self.span,
|
||||
}))
|
||||
@ -1664,7 +1664,7 @@ pub enum AssocTyConstraintKind {
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable)]
|
||||
pub struct Ty {
|
||||
pub id: NodeId,
|
||||
pub node: TyKind,
|
||||
pub kind: TyKind,
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
@ -1823,9 +1823,9 @@ impl Param {
|
||||
pub fn to_self(&self) -> Option<ExplicitSelf> {
|
||||
if let PatKind::Ident(BindingMode::ByValue(mutbl), ident, _) = self.pat.kind {
|
||||
if ident.name == kw::SelfLower {
|
||||
return match self.ty.node {
|
||||
return match self.ty.kind {
|
||||
TyKind::ImplicitSelf => Some(respan(self.pat.span, SelfKind::Value(mutbl))),
|
||||
TyKind::Rptr(lt, MutTy { ref ty, mutbl }) if ty.node.is_implicit_self() => {
|
||||
TyKind::Rptr(lt, MutTy { ref ty, mutbl }) if ty.kind.is_implicit_self() => {
|
||||
Some(respan(self.pat.span, SelfKind::Region(lt, mutbl)))
|
||||
}
|
||||
_ => Some(respan(
|
||||
@ -1850,7 +1850,7 @@ pub fn from_self(attrs: ThinVec<Attribute>, eself: ExplicitSelf, eself_ident: Id
|
||||
let span = eself.span.to(eself_ident.span);
|
||||
let infer_ty = P(Ty {
|
||||
id: DUMMY_NODE_ID,
|
||||
node: TyKind::ImplicitSelf,
|
||||
kind: TyKind::ImplicitSelf,
|
||||
span,
|
||||
});
|
||||
let param = |mutbl, ty| Param {
|
||||
@ -1872,7 +1872,7 @@ pub fn from_self(attrs: ThinVec<Attribute>, eself: ExplicitSelf, eself_ident: Id
|
||||
Mutability::Immutable,
|
||||
P(Ty {
|
||||
id: DUMMY_NODE_ID,
|
||||
node: TyKind::Rptr(
|
||||
kind: TyKind::Rptr(
|
||||
lt,
|
||||
MutTy {
|
||||
ty: infer_ty,
|
||||
|
@ -568,7 +568,7 @@ pub fn raw_pat(sp: Span) -> ast::Pat {
|
||||
pub fn raw_ty(sp: Span, is_error: bool) -> P<ast::Ty> {
|
||||
P(ast::Ty {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
node: if is_error { ast::TyKind::Err } else { ast::TyKind::Tup(Vec::new()) },
|
||||
kind: if is_error { ast::TyKind::Err } else { ast::TyKind::Tup(Vec::new()) },
|
||||
span: sp
|
||||
})
|
||||
}
|
||||
|
@ -54,11 +54,11 @@ pub fn ty_mt(&self, ty: P<ast::Ty>, mutbl: ast::Mutability) -> ast::MutTy {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ty(&self, span: Span, ty: ast::TyKind) -> P<ast::Ty> {
|
||||
pub fn ty(&self, span: Span, kind: ast::TyKind) -> P<ast::Ty> {
|
||||
P(ast::Ty {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
span,
|
||||
node: ty
|
||||
kind,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -1348,13 +1348,13 @@ fn visit_block(&mut self, block: &mut P<Block>) {
|
||||
}
|
||||
|
||||
fn visit_ty(&mut self, ty: &mut P<ast::Ty>) {
|
||||
match ty.node {
|
||||
match ty.kind {
|
||||
ast::TyKind::Mac(_) => {}
|
||||
_ => return noop_visit_ty(ty, self),
|
||||
};
|
||||
|
||||
visit_clobber(ty, |mut ty| {
|
||||
match mem::replace(&mut ty.node, ast::TyKind::Err) {
|
||||
match mem::replace(&mut ty.kind, ast::TyKind::Err) {
|
||||
ast::TyKind::Mac(mac) =>
|
||||
self.collect_bang(mac, ty.span, AstFragmentKind::Ty).make_ty(),
|
||||
_ => unreachable!(),
|
||||
|
@ -34,7 +34,7 @@ fn mac_placeholder() -> ast::Mac {
|
||||
});
|
||||
let ty = P(ast::Ty {
|
||||
id,
|
||||
node: ast::TyKind::Mac(mac_placeholder()),
|
||||
kind: ast::TyKind::Mac(mac_placeholder()),
|
||||
span,
|
||||
});
|
||||
let pat = P(ast::Pat {
|
||||
@ -71,7 +71,7 @@ fn mac_placeholder() -> ast::Mac {
|
||||
id, span, kind: ast::PatKind::Mac(mac_placeholder()),
|
||||
})),
|
||||
AstFragmentKind::Ty => AstFragment::Ty(P(ast::Ty {
|
||||
id, span, node: ast::TyKind::Mac(mac_placeholder()),
|
||||
id, span, kind: ast::TyKind::Mac(mac_placeholder()),
|
||||
})),
|
||||
AstFragmentKind::Stmts => AstFragment::Stmts(smallvec![{
|
||||
let mac = P((mac_placeholder(), ast::MacStmtStyle::Braces, ThinVec::new()));
|
||||
@ -318,7 +318,7 @@ fn visit_pat(&mut self, pat: &mut P<ast::Pat>) {
|
||||
}
|
||||
|
||||
fn visit_ty(&mut self, ty: &mut P<ast::Ty>) {
|
||||
match ty.node {
|
||||
match ty.kind {
|
||||
ast::TyKind::Mac(_) => *ty = self.remove(ty.id).make_ty(),
|
||||
_ => noop_visit_ty(ty, self),
|
||||
}
|
||||
|
@ -432,7 +432,7 @@ fn visit_foreign_item(&mut self, i: &'a ast::ForeignItem) {
|
||||
}
|
||||
|
||||
fn visit_ty(&mut self, ty: &'a ast::Ty) {
|
||||
match ty.node {
|
||||
match ty.kind {
|
||||
ast::TyKind::BareFn(ref bare_fn_ty) => {
|
||||
self.check_abi(bare_fn_ty.abi, ty.span);
|
||||
}
|
||||
@ -447,7 +447,7 @@ fn visit_ty(&mut self, ty: &'a ast::Ty) {
|
||||
|
||||
fn visit_fn_ret_ty(&mut self, ret_ty: &'a ast::FunctionRetTy) {
|
||||
if let ast::FunctionRetTy::Ty(ref output_ty) = *ret_ty {
|
||||
if let ast::TyKind::Never = output_ty.node {
|
||||
if let ast::TyKind::Never = output_ty.kind {
|
||||
// Do nothing.
|
||||
} else {
|
||||
self.visit_ty(output_ty)
|
||||
|
@ -432,9 +432,9 @@ pub fn noop_visit_ty_constraint<T: MutVisitor>(
|
||||
}
|
||||
|
||||
pub fn noop_visit_ty<T: MutVisitor>(ty: &mut P<Ty>, vis: &mut T) {
|
||||
let Ty { id, node, span } = ty.deref_mut();
|
||||
let Ty { id, kind, span } = ty.deref_mut();
|
||||
vis.visit_id(id);
|
||||
match node {
|
||||
match kind {
|
||||
TyKind::Infer | TyKind::ImplicitSelf | TyKind::Err |
|
||||
TyKind::Never | TyKind::CVarArgs => {}
|
||||
TyKind::Slice(ty) => vis.visit_ty(ty),
|
||||
|
@ -25,7 +25,7 @@
|
||||
span: ident.span,
|
||||
});
|
||||
let ty = Ty {
|
||||
node: TyKind::Err,
|
||||
kind: TyKind::Err,
|
||||
span: ident.span,
|
||||
id: ast::DUMMY_NODE_ID
|
||||
};
|
||||
@ -135,7 +135,7 @@ fn to_ty(&self) -> Option<P<Ty>> {
|
||||
fn recovered(qself: Option<QSelf>, path: ast::Path) -> Self {
|
||||
Self {
|
||||
span: path.span,
|
||||
node: TyKind::Path(qself, path),
|
||||
kind: TyKind::Path(qself, path),
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
}
|
||||
}
|
||||
@ -663,7 +663,7 @@ pub fn maybe_annotate_with_ascription(
|
||||
pprust::ty_to_string(ty)
|
||||
);
|
||||
|
||||
match ty.node {
|
||||
match ty.kind {
|
||||
TyKind::Rptr(ref lifetime, ref mut_ty) => {
|
||||
let sum_with_parens = pprust::to_string(|s| {
|
||||
s.s.word("&");
|
||||
@ -1296,7 +1296,7 @@ fn error_on_incorrect_await(&self, lo: Span, hi: Span, expr: &Expr, is_question:
|
||||
is_trait_item: bool,
|
||||
) -> PResult<'a, ast::Param> {
|
||||
let sp = param.pat.span;
|
||||
param.ty.node = TyKind::Err;
|
||||
param.ty.kind = TyKind::Err;
|
||||
let mut err = self.struct_span_err(sp, "unexpected `self` parameter in function");
|
||||
if is_trait_item {
|
||||
err.span_label(sp, "must be the first associated function parameter");
|
||||
@ -1360,7 +1360,7 @@ fn error_on_incorrect_await(&self, lo: Span, hi: Span, expr: &Expr, is_question:
|
||||
let mut seen_inputs = FxHashSet::default();
|
||||
for input in fn_inputs.iter_mut() {
|
||||
let opt_ident = if let (PatKind::Ident(_, ident, _), TyKind::Err) = (
|
||||
&input.pat.kind, &input.ty.node,
|
||||
&input.pat.kind, &input.ty.kind,
|
||||
) {
|
||||
Some(*ident)
|
||||
} else {
|
||||
|
@ -1212,7 +1212,7 @@ fn parse_fn_params(&mut self, named_params: bool, allow_c_variadic: bool)
|
||||
do_not_enforce_named_arguments_for_c_variadic
|
||||
) {
|
||||
Ok(param) => {
|
||||
if let TyKind::CVarArgs = param.ty.node {
|
||||
if let TyKind::CVarArgs = param.ty.kind {
|
||||
c_variadic = true;
|
||||
if p.token != token::CloseDelim(token::Paren) {
|
||||
let span = p.token.span;
|
||||
|
@ -555,7 +555,7 @@ fn parse_assoc_op_cast(&mut self, lhs: P<Expr>, lhs_span: Span,
|
||||
let span_after_type = parser_snapshot_after_type.token.span;
|
||||
let expr = mk_expr(self, P(Ty {
|
||||
span: path.span,
|
||||
node: TyKind::Path(None, path),
|
||||
kind: TyKind::Path(None, path),
|
||||
id: DUMMY_NODE_ID,
|
||||
}));
|
||||
|
||||
@ -1190,7 +1190,7 @@ fn parse_fn_block_param(&mut self) -> PResult<'a, Param> {
|
||||
} else {
|
||||
P(Ty {
|
||||
id: DUMMY_NODE_ID,
|
||||
node: TyKind::Infer,
|
||||
kind: TyKind::Infer,
|
||||
span: self.prev_span,
|
||||
})
|
||||
};
|
||||
|
@ -678,7 +678,7 @@ fn parse_item_impl(&mut self, unsafety: Unsafety, defaultness: Defaultness)
|
||||
self.look_ahead(1, |t| t != &token::Lt) {
|
||||
let span = self.prev_span.between(self.token.span);
|
||||
self.struct_span_err(span, "missing trait in a trait impl").emit();
|
||||
P(Ty { node: TyKind::Path(None, err_path(span)), span, id: DUMMY_NODE_ID })
|
||||
P(Ty { kind: TyKind::Path(None, err_path(span)), span, id: DUMMY_NODE_ID })
|
||||
} else {
|
||||
self.parse_ty()?
|
||||
};
|
||||
@ -715,7 +715,7 @@ fn parse_item_impl(&mut self, unsafety: Unsafety, defaultness: Defaultness)
|
||||
}
|
||||
|
||||
let ty_first = ty_first.into_inner();
|
||||
let path = match ty_first.node {
|
||||
let path = match ty_first.kind {
|
||||
// This notably includes paths passed through `ty` macro fragments (#46438).
|
||||
TyKind::Path(None, path) => path,
|
||||
_ => {
|
||||
@ -1526,7 +1526,7 @@ fn recover_missing_const_type(&mut self, id: Ident, m: Option<Mutability>) -> P<
|
||||
// The user intended that the type be inferred,
|
||||
// so treat this as if the user wrote e.g. `const A: _ = expr;`.
|
||||
P(Ty {
|
||||
node: TyKind::Infer,
|
||||
kind: TyKind::Infer,
|
||||
span: id.span,
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
})
|
||||
|
@ -55,7 +55,7 @@ pub(super) fn parse_ty_common(&mut self, allow_plus: bool, allow_qpath_recovery:
|
||||
|
||||
let lo = self.token.span;
|
||||
let mut impl_dyn_multi = false;
|
||||
let node = if self.eat(&token::OpenDelim(token::Paren)) {
|
||||
let kind = if self.eat(&token::OpenDelim(token::Paren)) {
|
||||
// `(TYPE)` is a parenthesized type.
|
||||
// `(TYPE,)` is a tuple with a single field of type TYPE.
|
||||
let mut ts = vec![];
|
||||
@ -75,7 +75,7 @@ pub(super) fn parse_ty_common(&mut self, allow_plus: bool, allow_qpath_recovery:
|
||||
if ts.len() == 1 && !last_comma {
|
||||
let ty = ts.into_iter().nth(0).unwrap().into_inner();
|
||||
let maybe_bounds = allow_plus && self.token.is_like_plus();
|
||||
match ty.node {
|
||||
match ty.kind {
|
||||
// `(TY_BOUND_NOPAREN) + BOUND + ...`.
|
||||
TyKind::Path(None, ref path) if maybe_bounds => {
|
||||
self.parse_remaining_bounds(Vec::new(), path.clone(), lo, true)?
|
||||
@ -211,7 +211,7 @@ pub(super) fn parse_ty_common(&mut self, allow_plus: bool, allow_qpath_recovery:
|
||||
};
|
||||
|
||||
let span = lo.to(self.prev_span);
|
||||
let ty = P(Ty { node, span, id: ast::DUMMY_NODE_ID });
|
||||
let ty = P(Ty { kind, span, id: ast::DUMMY_NODE_ID });
|
||||
|
||||
// Try to recover from use of `+` with incorrect priority.
|
||||
self.maybe_report_ambiguous_plus(allow_plus, impl_dyn_multi, &ty);
|
||||
|
@ -966,7 +966,7 @@ pub fn synth_comment(&mut self, text: String) {
|
||||
crate fn print_type(&mut self, ty: &ast::Ty) {
|
||||
self.maybe_print_comment(ty.span.lo());
|
||||
self.ibox(0);
|
||||
match ty.node {
|
||||
match ty.kind {
|
||||
ast::TyKind::Slice(ref ty) => {
|
||||
self.s.word("[");
|
||||
self.print_type(ty);
|
||||
@ -2760,7 +2760,7 @@ fn print_explicit_self(&mut self, explicit_self: &ast::ExplicitSelf) {
|
||||
|
||||
self.print_outer_attributes_inline(&input.attrs);
|
||||
|
||||
match input.ty.node {
|
||||
match input.ty.kind {
|
||||
ast::TyKind::Infer if is_closure => self.print_pat(&input.pat),
|
||||
_ => {
|
||||
if let Some(eself) = input.to_self() {
|
||||
|
@ -333,7 +333,7 @@ pub fn walk_field_pattern<'a, V: Visitor<'a>>(visitor: &mut V, fp: &'a FieldPat)
|
||||
}
|
||||
|
||||
pub fn walk_ty<'a, V: Visitor<'a>>(visitor: &mut V, typ: &'a Ty) {
|
||||
match typ.node {
|
||||
match typ.kind {
|
||||
TyKind::Slice(ref ty) | TyKind::Paren(ref ty) => {
|
||||
visitor.visit_ty(ty)
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ fn make_expr(self: Box<Self>) -> Option<P<ast::Expr>> {
|
||||
fn make_ty(self: Box<Self>) -> Option<P<ast::Ty>> {
|
||||
Some(P(ast::Ty {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
node: ast::TyKind::Path(None, ast::Path::from_ident(self.ident)),
|
||||
kind: ast::TyKind::Path(None, ast::Path::from_ident(self.ident)),
|
||||
span: self.ident.span,
|
||||
}))
|
||||
}
|
||||
|
@ -355,7 +355,7 @@ struct Visitor<'a, 'b> {
|
||||
|
||||
impl<'a, 'b> visit::Visitor<'a> for Visitor<'a, 'b> {
|
||||
fn visit_ty(&mut self, ty: &'a ast::Ty) {
|
||||
if let ast::TyKind::Path(_, ref path) = ty.node {
|
||||
if let ast::TyKind::Path(_, ref path) = ty.kind {
|
||||
if let Some(segment) = path.segments.first() {
|
||||
if self.ty_param_names.contains(&segment.ident.name) {
|
||||
self.types.push(P(ty.clone()));
|
||||
@ -612,7 +612,7 @@ fn create_derived_impl(&self,
|
||||
|
||||
for ty in tys {
|
||||
// if we have already handled this type, skip it
|
||||
if let ast::TyKind::Path(_, ref p) = ty.node {
|
||||
if let ast::TyKind::Path(_, ref p) = ty.kind {
|
||||
if p.segments.len() == 1 &&
|
||||
ty_param_names.contains(&p.segments[0].ident.name) {
|
||||
continue;
|
||||
|
@ -285,7 +285,7 @@ fn has_test_signature(cx: &ExtCtxt<'_>, i: &ast::Item) -> bool {
|
||||
// type implements the `Termination` trait as `libtest` enforces that.
|
||||
let has_output = match decl.output {
|
||||
ast::FunctionRetTy::Default(..) => false,
|
||||
ast::FunctionRetTy::Ty(ref t) if t.node.is_unit() => false,
|
||||
ast::FunctionRetTy::Ty(ref t) if t.kind.is_unit() => false,
|
||||
_ => true
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user