Skip to content

Commit

Permalink
Auto merge of #53581 - varkor:tyvariants-rename, r=eddyb
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Aug 22, 2018
2 parents c24f27c + 71722b9 commit b75b047
Show file tree
Hide file tree
Showing 180 changed files with 2,238 additions and 2,237 deletions.
6 changes: 3 additions & 3 deletions src/librustc/hir/def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub enum Def {
Existential(DefId),
/// `type Foo = Bar;`
TyAlias(DefId),
TyForeign(DefId),
ForeignTy(DefId),
TraitAlias(DefId),
AssociatedTy(DefId),
/// `existential type Foo: Bar;`
Expand Down Expand Up @@ -272,7 +272,7 @@ impl Def {
Def::AssociatedTy(id) | Def::TyParam(id) | Def::Struct(id) | Def::StructCtor(id, ..) |
Def::Union(id) | Def::Trait(id) | Def::Method(id) | Def::Const(id) |
Def::AssociatedConst(id) | Def::Macro(id, ..) |
Def::Existential(id) | Def::AssociatedExistential(id) | Def::TyForeign(id) => {
Def::Existential(id) | Def::AssociatedExistential(id) | Def::ForeignTy(id) => {
id
}

Expand Down Expand Up @@ -311,7 +311,7 @@ impl Def {
Def::StructCtor(.., CtorKind::Fictive) => bug!("impossible struct constructor"),
Def::Union(..) => "union",
Def::Trait(..) => "trait",
Def::TyForeign(..) => "foreign type",
Def::ForeignTy(..) => "foreign type",
Def::Method(..) => "method",
Def::Const(..) => "constant",
Def::AssociatedConst(..) => "associated constant",
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,7 @@ impl<'a> LoweringContext<'a> {
}
ImplTraitContext::Universal(in_band_ty_params) => {
self.lower_node_id(def_node_id);
// Add a definition for the in-band TyParam
// Add a definition for the in-band Param
let def_index = self
.resolver
.definitions()
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ impl<'hir> Map<'hir> {
match item.node {
ForeignItemKind::Fn(..) => Some(Def::Fn(def_id)),
ForeignItemKind::Static(_, m) => Some(Def::Static(def_id, m)),
ForeignItemKind::Type => Some(Def::TyForeign(def_id)),
ForeignItemKind::Type => Some(Def::ForeignTy(def_id)),
}
}
NodeTraitItem(item) => {
Expand Down
12 changes: 6 additions & 6 deletions src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1672,12 +1672,12 @@ impl fmt::Debug for Ty {
/// Not represented directly in the AST, referred to by name through a ty_path.
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
pub enum PrimTy {
TyInt(IntTy),
TyUint(UintTy),
TyFloat(FloatTy),
TyStr,
TyBool,
TyChar,
Int(IntTy),
Uint(UintTy),
Float(FloatTy),
Str,
Bool,
Char,
}

#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
Expand Down
14 changes: 7 additions & 7 deletions src/librustc/ich/impls_hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,12 +308,12 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::Ty {
}

impl_stable_hash_for!(enum hir::PrimTy {
TyInt(int_ty),
TyUint(uint_ty),
TyFloat(float_ty),
TyStr,
TyBool,
TyChar
Int(int_ty),
Uint(uint_ty),
Float(float_ty),
Str,
Bool,
Char
});

impl_stable_hash_for!(struct hir::BareFnTy {
Expand Down Expand Up @@ -1012,7 +1012,7 @@ impl_stable_hash_for!(enum hir::def::Def {
PrimTy(prim_ty),
TyParam(def_id),
SelfTy(trait_def_id, impl_def_id),
TyForeign(def_id),
ForeignTy(def_id),
Fn(def_id),
Const(def_id),
Static(def_id, is_mutbl),
Expand Down
64 changes: 32 additions & 32 deletions src/librustc/ich/impls_ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use ty;
use mir;

impl<'a, 'gcx, T> HashStable<StableHashingContext<'a>>
for &'gcx ty::Slice<T>
for &'gcx ty::List<T>
where T: HashStable<StableHashingContext<'a>> {
fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut StableHashingContext<'a>,
Expand Down Expand Up @@ -53,7 +53,7 @@ for &'gcx ty::Slice<T>
}
}

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

impl<'a, 'gcx> HashStable<StableHashingContext<'a>>
for ty::TypeVariants<'gcx>
for ty::TyKind<'gcx>
{
fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut StableHashingContext<'a>,
hasher: &mut StableHasher<W>) {
use ty::TypeVariants::*;
use ty::TyKind::*;

mem::discriminant(self).hash_stable(hcx, hasher);
match *self {
TyBool |
TyChar |
TyStr |
TyError |
TyNever => {
Bool |
Char |
Str |
Error |
Never => {
// Nothing more to hash.
}
TyInt(int_ty) => {
Int(int_ty) => {
int_ty.hash_stable(hcx, hasher);
}
TyUint(uint_ty) => {
Uint(uint_ty) => {
uint_ty.hash_stable(hcx, hasher);
}
TyFloat(float_ty) => {
Float(float_ty) => {
float_ty.hash_stable(hcx, hasher);
}
TyAdt(adt_def, substs) => {
Adt(adt_def, substs) => {
adt_def.hash_stable(hcx, hasher);
substs.hash_stable(hcx, hasher);
}
TyArray(inner_ty, len) => {
Array(inner_ty, len) => {
inner_ty.hash_stable(hcx, hasher);
len.hash_stable(hcx, hasher);
}
TySlice(inner_ty) => {
Slice(inner_ty) => {
inner_ty.hash_stable(hcx, hasher);
}
TyRawPtr(pointee_ty) => {
RawPtr(pointee_ty) => {
pointee_ty.hash_stable(hcx, hasher);
}
TyRef(region, pointee_ty, mutbl) => {
Ref(region, pointee_ty, mutbl) => {
region.hash_stable(hcx, hasher);
pointee_ty.hash_stable(hcx, hasher);
mutbl.hash_stable(hcx, hasher);
}
TyFnDef(def_id, substs) => {
FnDef(def_id, substs) => {
def_id.hash_stable(hcx, hasher);
substs.hash_stable(hcx, hasher);
}
TyFnPtr(ref sig) => {
FnPtr(ref sig) => {
sig.hash_stable(hcx, hasher);
}
TyDynamic(ref existential_predicates, region) => {
Dynamic(ref existential_predicates, region) => {
existential_predicates.hash_stable(hcx, hasher);
region.hash_stable(hcx, hasher);
}
TyClosure(def_id, closure_substs) => {
Closure(def_id, closure_substs) => {
def_id.hash_stable(hcx, hasher);
closure_substs.hash_stable(hcx, hasher);
}
TyGenerator(def_id, generator_substs, movability) => {
Generator(def_id, generator_substs, movability) => {
def_id.hash_stable(hcx, hasher);
generator_substs.hash_stable(hcx, hasher);
movability.hash_stable(hcx, hasher);
}
TyGeneratorWitness(types) => {
GeneratorWitness(types) => {
types.hash_stable(hcx, hasher)
}
TyTuple(inner_tys) => {
Tuple(inner_tys) => {
inner_tys.hash_stable(hcx, hasher);
}
TyProjection(ref projection_ty) => {
Projection(ref projection_ty) => {
projection_ty.hash_stable(hcx, hasher);
}
TyAnon(def_id, substs) => {
Anon(def_id, substs) => {
def_id.hash_stable(hcx, hasher);
substs.hash_stable(hcx, hasher);
}
TyParam(param_ty) => {
Param(param_ty) => {
param_ty.hash_stable(hcx, hasher);
}
TyForeign(def_id) => {
Foreign(def_id) => {
def_id.hash_stable(hcx, hasher);
}
TyInfer(infer_ty) => {
Infer(infer_ty) => {
infer_ty.hash_stable(hcx, hasher);
}
}
Expand All @@ -905,7 +905,7 @@ for ty::TyVid
_hasher: &mut StableHasher<W>) {
// TyVid values are confined to an inference context and hence
// should not be hashed.
bug!("ty::TypeVariants::hash_stable() - can't hash a TyVid {:?}.", *self)
bug!("ty::TyKind::hash_stable() - can't hash a TyVid {:?}.", *self)
}
}

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

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

Expand Down
12 changes: 6 additions & 6 deletions src/librustc/infer/anon_types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for ReverseMapper<'cx, 'gcx, 'tcx>

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

debug!(
"instantiate_anon_types: TyAnon(def_id={:?}, substs={:?})",
"instantiate_anon_types: Anon(def_id={:?}, substs={:?})",
def_id, substs
);

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

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

Expand Down
Loading

0 comments on commit b75b047

Please sign in to comment.