Skip to content

Commit f12eca4

Browse files
csmoeoli-obk
authored andcommitted
TyKind
1 parent 6a16b38 commit f12eca4

File tree

21 files changed

+143
-142
lines changed

21 files changed

+143
-142
lines changed

src/librustc/hir/intravisit.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ use super::itemlikevisit::DeepVisitor;
5050

5151
use std::cmp;
5252
use std::u32;
53+
use std::result::Result::Err;
5354

5455
#[derive(Copy, Clone)]
5556
pub enum FnKind<'a> {
@@ -576,41 +577,41 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) {
576577
visitor.visit_id(typ.id);
577578

578579
match typ.node {
579-
TySlice(ref ty) => {
580+
TyKind::Slice(ref ty) => {
580581
visitor.visit_ty(ty)
581582
}
582-
TyPtr(ref mutable_type) => {
583+
TyKind::Ptr(ref mutable_type) => {
583584
visitor.visit_ty(&mutable_type.ty)
584585
}
585-
TyRptr(ref lifetime, ref mutable_type) => {
586+
TyKind::Rptr(ref lifetime, ref mutable_type) => {
586587
visitor.visit_lifetime(lifetime);
587588
visitor.visit_ty(&mutable_type.ty)
588589
}
589-
TyNever => {},
590-
TyTup(ref tuple_element_types) => {
590+
TyKind::Never => {},
591+
TyKind::Tup(ref tuple_element_types) => {
591592
walk_list!(visitor, visit_ty, tuple_element_types);
592593
}
593-
TyBareFn(ref function_declaration) => {
594+
TyKind::BareFn(ref function_declaration) => {
594595
walk_list!(visitor, visit_generic_param, &function_declaration.generic_params);
595596
visitor.visit_fn_decl(&function_declaration.decl);
596597
}
597-
TyPath(ref qpath) => {
598+
TyKind::Path(ref qpath) => {
598599
visitor.visit_qpath(qpath, typ.id, typ.span);
599600
}
600-
TyArray(ref ty, ref length) => {
601+
TyKind::Array(ref ty, ref length) => {
601602
visitor.visit_ty(ty);
602603
visitor.visit_anon_const(length)
603604
}
604-
TyTraitObject(ref bounds, ref lifetime) => {
605+
TyKind::TraitObject(ref bounds, ref lifetime) => {
605606
for bound in bounds {
606607
visitor.visit_poly_trait_ref(bound, TraitBoundModifier::None);
607608
}
608609
visitor.visit_lifetime(lifetime);
609610
}
610-
TyTypeof(ref expression) => {
611+
TyKind::Typeof(ref expression) => {
611612
visitor.visit_anon_const(expression)
612613
}
613-
TyInfer | TyErr => {}
614+
TyKind::Infer | TyKind::Err => {}
614615
}
615616
}
616617

src/librustc/hir/lowering.rs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,25 +1080,25 @@ impl<'a> LoweringContext<'a> {
10801080

10811081
fn lower_ty_direct(&mut self, t: &Ty, mut itctx: ImplTraitContext) -> hir::Ty {
10821082
let kind = match t.node {
1083-
TyKind::Infer => hir::TyInfer,
1084-
TyKind::Err => hir::TyErr,
1085-
TyKind::Slice(ref ty) => hir::TySlice(self.lower_ty(ty, itctx)),
1086-
TyKind::Ptr(ref mt) => hir::TyPtr(self.lower_mt(mt, itctx)),
1083+
TyKind::Infer => hir::TyKind::Infer,
1084+
TyKind::Err => hir::TyKind::Err,
1085+
TyKind::Slice(ref ty) => hir::TyKind::Slice(self.lower_ty(ty, itctx)),
1086+
TyKind::Ptr(ref mt) => hir::TyKind::Ptr(self.lower_mt(mt, itctx)),
10871087
TyKind::Rptr(ref region, ref mt) => {
10881088
let span = t.span.shrink_to_lo();
10891089
let lifetime = match *region {
10901090
Some(ref lt) => self.lower_lifetime(lt),
10911091
None => self.elided_ref_lifetime(span),
10921092
};
1093-
hir::TyRptr(lifetime, self.lower_mt(mt, itctx))
1093+
hir::TyKind::Rptr(lifetime, self.lower_mt(mt, itctx))
10941094
}
10951095
TyKind::BareFn(ref f) => self.with_in_scope_lifetime_defs(
10961096
&f.generic_params,
10971097
|this| {
10981098
this.with_anonymous_lifetime_mode(
10991099
AnonymousLifetimeMode::PassThrough,
11001100
|this| {
1101-
hir::TyBareFn(P(hir::BareFnTy {
1101+
hir::TyKind::BareFn(P(hir::BareFnTy {
11021102
generic_params: this.lower_generic_params(
11031103
&f.generic_params,
11041104
&NodeMap(),
@@ -1113,9 +1113,9 @@ impl<'a> LoweringContext<'a> {
11131113
)
11141114
},
11151115
),
1116-
TyKind::Never => hir::TyNever,
1116+
TyKind::Never => hir::TyKind::Never,
11171117
TyKind::Tup(ref tys) => {
1118-
hir::TyTup(tys.iter().map(|ty| {
1118+
hir::TyKind::Tup(tys.iter().map(|ty| {
11191119
self.lower_ty_direct(ty, itctx.reborrow())
11201120
}).collect())
11211121
}
@@ -1126,12 +1126,12 @@ impl<'a> LoweringContext<'a> {
11261126
let id = self.lower_node_id(t.id);
11271127
let qpath = self.lower_qpath(t.id, qself, path, ParamMode::Explicit, itctx);
11281128
let ty = self.ty_path(id, t.span, qpath);
1129-
if let hir::TyTraitObject(..) = ty.node {
1129+
if let hir::TyKind::TraitObject(..) = ty.node {
11301130
self.maybe_lint_bare_trait(t.span, t.id, qself.is_none() && path.is_global());
11311131
}
11321132
return ty;
11331133
}
1134-
TyKind::ImplicitSelf => hir::TyPath(hir::QPath::Resolved(
1134+
TyKind::ImplicitSelf => hir::TyKind::Path(hir::QPath::Resolved(
11351135
None,
11361136
P(hir::Path {
11371137
def: self.expect_full_def(t.id),
@@ -1140,10 +1140,10 @@ impl<'a> LoweringContext<'a> {
11401140
}),
11411141
)),
11421142
TyKind::Array(ref ty, ref length) => {
1143-
hir::TyArray(self.lower_ty(ty, itctx), self.lower_anon_const(length))
1143+
hir::TyKind::Array(self.lower_ty(ty, itctx), self.lower_anon_const(length))
11441144
}
11451145
TyKind::Typeof(ref expr) => {
1146-
hir::TyTypeof(self.lower_anon_const(expr))
1146+
hir::TyKind::Typeof(self.lower_anon_const(expr))
11471147
}
11481148
TyKind::TraitObject(ref bounds, kind) => {
11491149
let mut lifetime_bound = None;
@@ -1167,7 +1167,7 @@ impl<'a> LoweringContext<'a> {
11671167
if kind != TraitObjectSyntax::Dyn {
11681168
self.maybe_lint_bare_trait(t.span, t.id, false);
11691169
}
1170-
hir::TyTraitObject(bounds, lifetime_bound)
1170+
hir::TyKind::TraitObject(bounds, lifetime_bound)
11711171
}
11721172
TyKind::ImplTrait(def_node_id, ref bounds) => {
11731173
let span = t.span;
@@ -1206,7 +1206,7 @@ impl<'a> LoweringContext<'a> {
12061206
}
12071207
});
12081208

1209-
hir::TyPath(hir::QPath::Resolved(
1209+
hir::TyKind::Path(hir::QPath::Resolved(
12101210
None,
12111211
P(hir::Path {
12121212
span,
@@ -1223,7 +1223,7 @@ impl<'a> LoweringContext<'a> {
12231223
"`impl Trait` not allowed outside of function \
12241224
and inherent method return types"
12251225
);
1226-
hir::TyErr
1226+
hir::TyKind::Err
12271227
}
12281228
}
12291229
}
@@ -1245,7 +1245,7 @@ impl<'a> LoweringContext<'a> {
12451245
fn_def_id: DefId,
12461246
exist_ty_node_id: NodeId,
12471247
lower_bounds: impl FnOnce(&mut LoweringContext) -> hir::GenericBounds,
1248-
) -> hir::Ty_ {
1248+
) -> hir::TyKind {
12491249
// Make sure we know that some funky desugaring has been going on here.
12501250
// This is a first: there is code in other places like for loop
12511251
// desugaring that explicitly states that we don't want to track that.
@@ -1320,7 +1320,7 @@ impl<'a> LoweringContext<'a> {
13201320
}))
13211321
}],
13221322
});
1323-
hir::TyPath(hir::QPath::Resolved(None, path))
1323+
hir::TyKind::Path(hir::QPath::Resolved(None, path))
13241324
})
13251325
}
13261326

@@ -1365,7 +1365,7 @@ impl<'a> LoweringContext<'a> {
13651365

13661366
fn visit_ty(&mut self, t: &'v hir::Ty) {
13671367
// Don't collect elided lifetimes used inside of `fn()` syntax
1368-
if let hir::Ty_::TyBareFn(_) = t.node {
1368+
if let hir::TyKind::BareFn(_) = t.node {
13691369
let old_collect_elided_lifetimes = self.collect_elided_lifetimes;
13701370
self.collect_elided_lifetimes = false;
13711371

@@ -1805,7 +1805,7 @@ impl<'a> LoweringContext<'a> {
18051805
let inputs = inputs.iter().map(|ty| this.lower_ty_direct(ty, DISALLOWED)).collect();
18061806
let mk_tup = |this: &mut Self, tys, span| {
18071807
let LoweredNodeId { node_id, hir_id } = this.next_id();
1808-
hir::Ty { node: hir::TyTup(tys), id: node_id, hir_id, span }
1808+
hir::Ty { node: hir::TyKind::Tup(tys), id: node_id, hir_id, span }
18091809
};
18101810

18111811
(
@@ -1985,7 +1985,7 @@ impl<'a> LoweringContext<'a> {
19851985

19861986
fn visit_ty(&mut self, t: &'v hir::Ty) {
19871987
// Don't collect elided lifetimes used inside of `fn()` syntax
1988-
if let &hir::Ty_::TyBareFn(_) = &t.node {
1988+
if let &hir::TyKind::BareFn(_) = &t.node {
19891989
let old_collect_elided_lifetimes = self.collect_elided_lifetimes;
19901990
self.collect_elided_lifetimes = false;
19911991

@@ -2105,7 +2105,7 @@ impl<'a> LoweringContext<'a> {
21052105
P(hir::Ty {
21062106
id: node_id,
21072107
hir_id: hir_id,
2108-
node: hir::TyTup(hir_vec![]),
2108+
node: hir::TyKind::Tup(hir_vec![]),
21092109
span: *span,
21102110
})
21112111
}
@@ -4624,7 +4624,7 @@ impl<'a> LoweringContext<'a> {
46244624
let mut id = id;
46254625
let node = match qpath {
46264626
hir::QPath::Resolved(None, path) => {
4627-
// Turn trait object paths into `TyTraitObject` instead.
4627+
// Turn trait object paths into `TyKind::TraitObject` instead.
46284628
if let Def::Trait(_) = path.def {
46294629
let principal = hir::PolyTraitRef {
46304630
bound_generic_params: hir::HirVec::new(),
@@ -4638,12 +4638,12 @@ impl<'a> LoweringContext<'a> {
46384638
// The original ID is taken by the `PolyTraitRef`,
46394639
// so the `Ty` itself needs a different one.
46404640
id = self.next_id();
4641-
hir::TyTraitObject(hir_vec![principal], self.elided_dyn_bound(span))
4641+
hir::TyKind::TraitObject(hir_vec![principal], self.elided_dyn_bound(span))
46424642
} else {
4643-
hir::TyPath(hir::QPath::Resolved(None, path))
4643+
hir::TyKind::Path(hir::QPath::Resolved(None, path))
46444644
}
46454645
}
4646-
_ => hir::TyPath(qpath),
4646+
_ => hir::TyKind::Path(qpath),
46474647
};
46484648
hir::Ty {
46494649
id: id.node_id,

src/librustc/hir/map/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ use hir::svh::Svh;
3333
use util::nodemap::FxHashMap;
3434

3535
use std::io;
36+
use std::result::Result::Err;
3637
use ty::TyCtxt;
3738

3839
pub mod blocks;

src/librustc/hir/mod.rs

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ pub use self::ForeignItem_::*;
1717
pub use self::Item_::*;
1818
pub use self::Mutability::*;
1919
pub use self::PrimTy::*;
20-
pub use self::Ty_::*;
2120
pub use self::UnOp::*;
2221
pub use self::UnsafeSource::*;
2322

@@ -439,7 +438,7 @@ impl GenericArgs {
439438
match arg {
440439
GenericArg::Lifetime(_) => {}
441440
GenericArg::Type(ref ty) => {
442-
if let TyTup(ref tys) = ty.node {
441+
if let TyKind::Tup(ref tys) = ty.node {
443442
return tys;
444443
}
445444
break;
@@ -1448,7 +1447,7 @@ pub enum QPath {
14481447
///
14491448
/// UFCS source paths can desugar into this, with `Vec::new` turning into
14501449
/// `<Vec>::new`, and `T::X::Y::method` into `<<<T>::X>::Y>::method`,
1451-
/// the `X` and `Y` nodes each being a `TyPath(QPath::TypeRelative(..))`.
1450+
/// the `X` and `Y` nodes each being a `TyKind::Path(QPath::TypeRelative(..))`.
14521451
TypeRelative(P<Ty>, P<PathSegment>)
14531452
}
14541453

@@ -1638,7 +1637,7 @@ pub struct TypeBinding {
16381637
#[derive(Clone, RustcEncodable, RustcDecodable)]
16391638
pub struct Ty {
16401639
pub id: NodeId,
1641-
pub node: Ty_,
1640+
pub node: TyKind,
16421641
pub span: Span,
16431642
pub hir_id: HirId,
16441643
}
@@ -1679,36 +1678,36 @@ pub struct ExistTy {
16791678

16801679
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
16811680
/// The different kinds of types recognized by the compiler
1682-
pub enum Ty_ {
1681+
pub enum TyKind {
16831682
/// A variable length slice (`[T]`)
1684-
TySlice(P<Ty>),
1683+
Slice(P<Ty>),
16851684
/// A fixed length array (`[T; n]`)
1686-
TyArray(P<Ty>, AnonConst),
1685+
Array(P<Ty>, AnonConst),
16871686
/// A raw pointer (`*const T` or `*mut T`)
1688-
TyPtr(MutTy),
1687+
Ptr(MutTy),
16891688
/// A reference (`&'a T` or `&'a mut T`)
1690-
TyRptr(Lifetime, MutTy),
1689+
Rptr(Lifetime, MutTy),
16911690
/// A bare function (e.g. `fn(usize) -> bool`)
1692-
TyBareFn(P<BareFnTy>),
1691+
BareFn(P<BareFnTy>),
16931692
/// The never type (`!`)
1694-
TyNever,
1693+
Never,
16951694
/// A tuple (`(A, B, C, D,...)`)
1696-
TyTup(HirVec<Ty>),
1695+
Tup(HirVec<Ty>),
16971696
/// A path to a type definition (`module::module::...::Type`), or an
16981697
/// associated type, e.g. `<Vec<T> as Trait>::Type` or `<T>::Target`.
16991698
///
17001699
/// Type parameters may be stored in each `PathSegment`.
1701-
TyPath(QPath),
1700+
Path(QPath),
17021701
/// A trait object type `Bound1 + Bound2 + Bound3`
17031702
/// where `Bound` is a trait or a lifetime.
1704-
TyTraitObject(HirVec<PolyTraitRef>, Lifetime),
1703+
TraitObject(HirVec<PolyTraitRef>, Lifetime),
17051704
/// Unused for now
1706-
TyTypeof(AnonConst),
1707-
/// TyInfer means the type should be inferred instead of it having been
1705+
Typeof(AnonConst),
1706+
/// TyKind::Infer means the type should be inferred instead of it having been
17081707
/// specified. This can appear anywhere in a type.
1709-
TyInfer,
1708+
Infer,
17101709
/// Placeholder for a type that has failed to be defined.
1711-
TyErr,
1710+
Err,
17121711
}
17131712

17141713
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]

0 commit comments

Comments
 (0)