Skip to content

Commit b75b047

Browse files
committed
Auto merge of #53581 - varkor:tyvariants-rename, r=eddyb
Rename TyVariants and variants - Rename `TypeVariants` to `TyKind`. - Remove the `Ty` prefix from each one of its variants (plus the identically-named variants of `PrimTy`). - Rename `ty::Slice` to `ty::List`. The new names look cleaner. r? @eddyb
2 parents c24f27c + 71722b9 commit b75b047

File tree

180 files changed

+2238
-2237
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

180 files changed

+2238
-2237
lines changed

src/librustc/hir/def.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub enum Def {
5353
Existential(DefId),
5454
/// `type Foo = Bar;`
5555
TyAlias(DefId),
56-
TyForeign(DefId),
56+
ForeignTy(DefId),
5757
TraitAlias(DefId),
5858
AssociatedTy(DefId),
5959
/// `existential type Foo: Bar;`
@@ -272,7 +272,7 @@ impl Def {
272272
Def::AssociatedTy(id) | Def::TyParam(id) | Def::Struct(id) | Def::StructCtor(id, ..) |
273273
Def::Union(id) | Def::Trait(id) | Def::Method(id) | Def::Const(id) |
274274
Def::AssociatedConst(id) | Def::Macro(id, ..) |
275-
Def::Existential(id) | Def::AssociatedExistential(id) | Def::TyForeign(id) => {
275+
Def::Existential(id) | Def::AssociatedExistential(id) | Def::ForeignTy(id) => {
276276
id
277277
}
278278

@@ -311,7 +311,7 @@ impl Def {
311311
Def::StructCtor(.., CtorKind::Fictive) => bug!("impossible struct constructor"),
312312
Def::Union(..) => "union",
313313
Def::Trait(..) => "trait",
314-
Def::TyForeign(..) => "foreign type",
314+
Def::ForeignTy(..) => "foreign type",
315315
Def::Method(..) => "method",
316316
Def::Const(..) => "constant",
317317
Def::AssociatedConst(..) => "associated constant",

src/librustc/hir/lowering.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1183,7 +1183,7 @@ impl<'a> LoweringContext<'a> {
11831183
}
11841184
ImplTraitContext::Universal(in_band_ty_params) => {
11851185
self.lower_node_id(def_node_id);
1186-
// Add a definition for the in-band TyParam
1186+
// Add a definition for the in-band Param
11871187
let def_index = self
11881188
.resolver
11891189
.definitions()

src/librustc/hir/map/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ impl<'hir> Map<'hir> {
453453
match item.node {
454454
ForeignItemKind::Fn(..) => Some(Def::Fn(def_id)),
455455
ForeignItemKind::Static(_, m) => Some(Def::Static(def_id, m)),
456-
ForeignItemKind::Type => Some(Def::TyForeign(def_id)),
456+
ForeignItemKind::Type => Some(Def::ForeignTy(def_id)),
457457
}
458458
}
459459
NodeTraitItem(item) => {

src/librustc/hir/mod.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1672,12 +1672,12 @@ impl fmt::Debug for Ty {
16721672
/// Not represented directly in the AST, referred to by name through a ty_path.
16731673
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
16741674
pub enum PrimTy {
1675-
TyInt(IntTy),
1676-
TyUint(UintTy),
1677-
TyFloat(FloatTy),
1678-
TyStr,
1679-
TyBool,
1680-
TyChar,
1675+
Int(IntTy),
1676+
Uint(UintTy),
1677+
Float(FloatTy),
1678+
Str,
1679+
Bool,
1680+
Char,
16811681
}
16821682

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

src/librustc/ich/impls_hir.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -308,12 +308,12 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::Ty {
308308
}
309309

310310
impl_stable_hash_for!(enum hir::PrimTy {
311-
TyInt(int_ty),
312-
TyUint(uint_ty),
313-
TyFloat(float_ty),
314-
TyStr,
315-
TyBool,
316-
TyChar
311+
Int(int_ty),
312+
Uint(uint_ty),
313+
Float(float_ty),
314+
Str,
315+
Bool,
316+
Char
317317
});
318318

319319
impl_stable_hash_for!(struct hir::BareFnTy {
@@ -1012,7 +1012,7 @@ impl_stable_hash_for!(enum hir::def::Def {
10121012
PrimTy(prim_ty),
10131013
TyParam(def_id),
10141014
SelfTy(trait_def_id, impl_def_id),
1015-
TyForeign(def_id),
1015+
ForeignTy(def_id),
10161016
Fn(def_id),
10171017
Const(def_id),
10181018
Static(def_id, is_mutbl),

src/librustc/ich/impls_ty.rs

+32-32
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use ty;
2525
use mir;
2626

2727
impl<'a, 'gcx, T> HashStable<StableHashingContext<'a>>
28-
for &'gcx ty::Slice<T>
28+
for &'gcx ty::List<T>
2929
where T: HashStable<StableHashingContext<'a>> {
3030
fn hash_stable<W: StableHasherResult>(&self,
3131
hcx: &mut StableHashingContext<'a>,
@@ -53,7 +53,7 @@ for &'gcx ty::Slice<T>
5353
}
5454
}
5555

56-
impl<'a, 'gcx, T> ToStableHashKey<StableHashingContext<'a>> for &'gcx ty::Slice<T>
56+
impl<'a, 'gcx, T> ToStableHashKey<StableHashingContext<'a>> for &'gcx ty::List<T>
5757
where T: HashStable<StableHashingContext<'a>>
5858
{
5959
type KeyType = Fingerprint;
@@ -797,90 +797,90 @@ impl_stable_hash_for!(enum ty::BoundRegion {
797797
});
798798

799799
impl<'a, 'gcx> HashStable<StableHashingContext<'a>>
800-
for ty::TypeVariants<'gcx>
800+
for ty::TyKind<'gcx>
801801
{
802802
fn hash_stable<W: StableHasherResult>(&self,
803803
hcx: &mut StableHashingContext<'a>,
804804
hasher: &mut StableHasher<W>) {
805-
use ty::TypeVariants::*;
805+
use ty::TyKind::*;
806806

807807
mem::discriminant(self).hash_stable(hcx, hasher);
808808
match *self {
809-
TyBool |
810-
TyChar |
811-
TyStr |
812-
TyError |
813-
TyNever => {
809+
Bool |
810+
Char |
811+
Str |
812+
Error |
813+
Never => {
814814
// Nothing more to hash.
815815
}
816-
TyInt(int_ty) => {
816+
Int(int_ty) => {
817817
int_ty.hash_stable(hcx, hasher);
818818
}
819-
TyUint(uint_ty) => {
819+
Uint(uint_ty) => {
820820
uint_ty.hash_stable(hcx, hasher);
821821
}
822-
TyFloat(float_ty) => {
822+
Float(float_ty) => {
823823
float_ty.hash_stable(hcx, hasher);
824824
}
825-
TyAdt(adt_def, substs) => {
825+
Adt(adt_def, substs) => {
826826
adt_def.hash_stable(hcx, hasher);
827827
substs.hash_stable(hcx, hasher);
828828
}
829-
TyArray(inner_ty, len) => {
829+
Array(inner_ty, len) => {
830830
inner_ty.hash_stable(hcx, hasher);
831831
len.hash_stable(hcx, hasher);
832832
}
833-
TySlice(inner_ty) => {
833+
Slice(inner_ty) => {
834834
inner_ty.hash_stable(hcx, hasher);
835835
}
836-
TyRawPtr(pointee_ty) => {
836+
RawPtr(pointee_ty) => {
837837
pointee_ty.hash_stable(hcx, hasher);
838838
}
839-
TyRef(region, pointee_ty, mutbl) => {
839+
Ref(region, pointee_ty, mutbl) => {
840840
region.hash_stable(hcx, hasher);
841841
pointee_ty.hash_stable(hcx, hasher);
842842
mutbl.hash_stable(hcx, hasher);
843843
}
844-
TyFnDef(def_id, substs) => {
844+
FnDef(def_id, substs) => {
845845
def_id.hash_stable(hcx, hasher);
846846
substs.hash_stable(hcx, hasher);
847847
}
848-
TyFnPtr(ref sig) => {
848+
FnPtr(ref sig) => {
849849
sig.hash_stable(hcx, hasher);
850850
}
851-
TyDynamic(ref existential_predicates, region) => {
851+
Dynamic(ref existential_predicates, region) => {
852852
existential_predicates.hash_stable(hcx, hasher);
853853
region.hash_stable(hcx, hasher);
854854
}
855-
TyClosure(def_id, closure_substs) => {
855+
Closure(def_id, closure_substs) => {
856856
def_id.hash_stable(hcx, hasher);
857857
closure_substs.hash_stable(hcx, hasher);
858858
}
859-
TyGenerator(def_id, generator_substs, movability) => {
859+
Generator(def_id, generator_substs, movability) => {
860860
def_id.hash_stable(hcx, hasher);
861861
generator_substs.hash_stable(hcx, hasher);
862862
movability.hash_stable(hcx, hasher);
863863
}
864-
TyGeneratorWitness(types) => {
864+
GeneratorWitness(types) => {
865865
types.hash_stable(hcx, hasher)
866866
}
867-
TyTuple(inner_tys) => {
867+
Tuple(inner_tys) => {
868868
inner_tys.hash_stable(hcx, hasher);
869869
}
870-
TyProjection(ref projection_ty) => {
870+
Projection(ref projection_ty) => {
871871
projection_ty.hash_stable(hcx, hasher);
872872
}
873-
TyAnon(def_id, substs) => {
873+
Anon(def_id, substs) => {
874874
def_id.hash_stable(hcx, hasher);
875875
substs.hash_stable(hcx, hasher);
876876
}
877-
TyParam(param_ty) => {
877+
Param(param_ty) => {
878878
param_ty.hash_stable(hcx, hasher);
879879
}
880-
TyForeign(def_id) => {
880+
Foreign(def_id) => {
881881
def_id.hash_stable(hcx, hasher);
882882
}
883-
TyInfer(infer_ty) => {
883+
Infer(infer_ty) => {
884884
infer_ty.hash_stable(hcx, hasher);
885885
}
886886
}
@@ -905,7 +905,7 @@ for ty::TyVid
905905
_hasher: &mut StableHasher<W>) {
906906
// TyVid values are confined to an inference context and hence
907907
// should not be hashed.
908-
bug!("ty::TypeVariants::hash_stable() - can't hash a TyVid {:?}.", *self)
908+
bug!("ty::TyKind::hash_stable() - can't hash a TyVid {:?}.", *self)
909909
}
910910
}
911911

@@ -917,7 +917,7 @@ for ty::IntVid
917917
_hasher: &mut StableHasher<W>) {
918918
// IntVid values are confined to an inference context and hence
919919
// should not be hashed.
920-
bug!("ty::TypeVariants::hash_stable() - can't hash an IntVid {:?}.", *self)
920+
bug!("ty::TyKind::hash_stable() - can't hash an IntVid {:?}.", *self)
921921
}
922922
}
923923

@@ -929,7 +929,7 @@ for ty::FloatVid
929929
_hasher: &mut StableHasher<W>) {
930930
// FloatVid values are confined to an inference context and hence
931931
// should not be hashed.
932-
bug!("ty::TypeVariants::hash_stable() - can't hash a FloatVid {:?}.", *self)
932+
bug!("ty::TyKind::hash_stable() - can't hash a FloatVid {:?}.", *self)
933933
}
934934
}
935935

src/librustc/infer/anon_types/mod.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for ReverseMapper<'cx, 'gcx, 'tcx>
592592

593593
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
594594
match ty.sty {
595-
ty::TyClosure(def_id, substs) => {
595+
ty::Closure(def_id, substs) => {
596596
// I am a horrible monster and I pray for death. When
597597
// we encounter a closure here, it is always a closure
598598
// from within the function that we are currently
@@ -655,7 +655,7 @@ impl<'a, 'gcx, 'tcx> Instantiator<'a, 'gcx, 'tcx> {
655655
tcx,
656656
reg_op: |reg| reg,
657657
fldop: |ty| {
658-
if let ty::TyAnon(def_id, substs) = ty.sty {
658+
if let ty::Anon(def_id, substs) = ty.sty {
659659
// Check that this is `impl Trait` type is
660660
// declared by `parent_def_id` -- i.e., one whose
661661
// value we are inferring. At present, this is
@@ -679,7 +679,7 @@ impl<'a, 'gcx, 'tcx> Instantiator<'a, 'gcx, 'tcx> {
679679
// ```
680680
//
681681
// Here, the return type of `foo` references a
682-
// `TyAnon` indeed, but not one whose value is
682+
// `Anon` indeed, but not one whose value is
683683
// presently being inferred. You can get into a
684684
// similar situation with closure return types
685685
// today:
@@ -755,11 +755,11 @@ impl<'a, 'gcx, 'tcx> Instantiator<'a, 'gcx, 'tcx> {
755755
let tcx = infcx.tcx;
756756

757757
debug!(
758-
"instantiate_anon_types: TyAnon(def_id={:?}, substs={:?})",
758+
"instantiate_anon_types: Anon(def_id={:?}, substs={:?})",
759759
def_id, substs
760760
);
761761

762-
// Use the same type variable if the exact same TyAnon appears more
762+
// Use the same type variable if the exact same Anon appears more
763763
// than once in the return type (e.g. if it's passed to a type alias).
764764
if let Some(anon_defn) = self.anon_types.get(&def_id) {
765765
return anon_defn.concrete_ty;
@@ -805,7 +805,7 @@ impl<'a, 'gcx, 'tcx> Instantiator<'a, 'gcx, 'tcx> {
805805

806806
for predicate in bounds.predicates {
807807
// Change the predicate to refer to the type variable,
808-
// which will be the concrete type, instead of the TyAnon.
808+
// which will be the concrete type, instead of the Anon.
809809
// This also instantiates nested `impl Trait`.
810810
let predicate = self.instantiate_anon_types_in_map(&predicate);
811811

0 commit comments

Comments
 (0)