Skip to content

Commit

Permalink
Rename ty::TyVariants to ty::TyKind
Browse files Browse the repository at this point in the history
  • Loading branch information
varkor committed Aug 22, 2018
1 parent 87c7e57 commit d37cee3
Show file tree
Hide file tree
Showing 27 changed files with 77 additions and 77 deletions.
10 changes: 5 additions & 5 deletions src/librustc/ich/impls_ty.rs
Expand Up @@ -797,12 +797,12 @@ 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 {
Expand Down Expand Up @@ -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
6 changes: 3 additions & 3 deletions src/librustc/infer/error_reporting/mod.rs
Expand Up @@ -66,7 +66,7 @@ use hir::map as hir_map;
use hir::def_id::DefId;
use middle::region;
use traits::{ObligationCause, ObligationCauseCode};
use ty::{self, subst::Subst, Region, Ty, TyCtxt, TypeFoldable, TypeVariants};
use ty::{self, subst::Subst, Region, Ty, TyCtxt, TypeFoldable, TyKind};
use ty::error::TypeError;
use syntax::ast::DUMMY_NODE_ID;
use syntax_pos::{Pos, Span};
Expand Down Expand Up @@ -979,14 +979,14 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
(_, false, _) => {
if let Some(exp_found) = exp_found {
let (def_id, ret_ty) = match exp_found.found.sty {
TypeVariants::TyFnDef(def, _) => {
TyKind::TyFnDef(def, _) => {
(Some(def), Some(self.tcx.fn_sig(def).output()))
}
_ => (None, None),
};

let exp_is_struct = match exp_found.expected.sty {
TypeVariants::TyAdt(def, _) => def.is_struct(),
TyKind::TyAdt(def, _) => def.is_struct(),
_ => false,
};

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/dead.rs
Expand Up @@ -236,7 +236,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> {
self.handle_field_access(&lhs, expr.id);
}
hir::ExprKind::Struct(_, ref fields, _) => {
if let ty::TypeVariants::TyAdt(ref adt, _) = self.tables.expr_ty(expr).sty {
if let ty::TyKind::TyAdt(ref adt, _) = self.tables.expr_ty(expr).sty {
self.mark_as_used_if_union(adt, fields);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/mir/mod.rs
Expand Up @@ -2221,7 +2221,7 @@ impl<'tcx> Debug for Constant<'tcx> {

/// Write a `ConstValue` in a way closer to the original source code than the `Debug` output.
pub fn fmt_const_val(f: &mut impl Write, const_val: &ty::Const) -> fmt::Result {
use ty::TypeVariants::*;
use ty::TyKind::*;
let value = const_val.val;
let ty = const_val.ty;
// print some primitives
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/traits/error_reporting.rs
Expand Up @@ -802,7 +802,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
let expected = match expected_trait_ref.skip_binder().substs.type_at(1).sty {
ty::TyTuple(ref tys) => tys.iter()
.map(|t| match t.sty {
ty::TypeVariants::TyTuple(ref tys) => ArgKind::Tuple(
ty::TyKind::TyTuple(ref tys) => ArgKind::Tuple(
Some(span),
tys.iter()
.map(|ty| ("_".to_owned(), ty.sty.to_string()))
Expand Down Expand Up @@ -899,7 +899,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
let mut trait_type = trait_ref.self_ty();

for refs_remaining in 0..refs_number {
if let ty::TypeVariants::TyRef(_, t_type, _) = trait_type.sty {
if let ty::TyKind::TyRef(_, t_type, _) = trait_type.sty {
trait_type = t_type;

let substs = self.tcx.mk_substs_trait(trait_type, &[]);
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/ty/codec.rs
Expand Up @@ -37,7 +37,7 @@ pub trait EncodableWithShorthand: Clone + Eq + Hash {
}

impl<'tcx> EncodableWithShorthand for Ty<'tcx> {
type Variant = ty::TypeVariants<'tcx>;
type Variant = ty::TyKind<'tcx>;
fn variant(&self) -> &Self::Variant {
&self.sty
}
Expand Down Expand Up @@ -164,7 +164,7 @@ pub fn decode_ty<'a, 'tcx, D>(decoder: &mut D) -> Result<Ty<'tcx>, D::Error>
})
} else {
let tcx = decoder.tcx();
Ok(tcx.mk_ty(ty::TypeVariants::decode(decoder)?))
Ok(tcx.mk_ty(ty::TyKind::decode(decoder)?))
}
}

Expand Down
16 changes: 8 additions & 8 deletions src/librustc/ty/context.rs
Expand Up @@ -38,12 +38,12 @@ use ty::ReprOptions;
use traits;
use traits::{Clause, Clauses, Goal, Goals};
use ty::{self, Ty, TypeAndMut};
use ty::{TyS, TypeVariants, List};
use ty::{TyS, TyKind, List};
use ty::{AdtKind, AdtDef, ClosureSubsts, GeneratorSubsts, Region, Const};
use ty::{PolyFnSig, InferTy, ParamTy, ProjectionTy, ExistentialPredicate, Predicate};
use ty::RegionKind;
use ty::{TyVar, TyVid, IntVar, IntVid, FloatVar, FloatVid};
use ty::TypeVariants::*;
use ty::TyKind::*;
use ty::GenericParamDefKind;
use ty::layout::{LayoutDetails, TargetDataLayout};
use ty::query;
Expand Down Expand Up @@ -167,7 +167,7 @@ impl<'gcx: 'tcx, 'tcx> CtxtInterners<'tcx> {
fn intern_ty(
local: &CtxtInterners<'tcx>,
global: &CtxtInterners<'gcx>,
st: TypeVariants<'tcx>
st: TyKind<'tcx>
) -> Ty<'tcx> {
let flags = super::flags::FlagComputation::for_sty(&st);

Expand Down Expand Up @@ -803,7 +803,7 @@ impl<'tcx> CommonTypes<'tcx> {
fn new(interners: &CtxtInterners<'tcx>) -> CommonTypes<'tcx> {
// Ensure our type representation does not grow
#[cfg(target_pointer_width = "64")]
assert!(mem::size_of::<ty::TypeVariants>() <= 24);
assert!(mem::size_of::<ty::TyKind>() <= 24);
#[cfg(target_pointer_width = "64")]
assert!(mem::size_of::<ty::TyS>() <= 32);

Expand Down Expand Up @@ -1540,7 +1540,7 @@ impl<'gcx: 'tcx, 'tcx> GlobalCtxt<'gcx> {
/// None is returned if the value or one of the components is not part
/// of the provided context.
/// For Ty, None can be returned if either the type interner doesn't
/// contain the TypeVariants key or if the address of the interned
/// contain the TyKind key or if the address of the interned
/// pointer differs. The latter case is possible if a primitive type,
/// e.g. `()` or `u8`, was interned in a different context.
pub trait Lift<'tcx>: fmt::Debug {
Expand Down Expand Up @@ -2107,8 +2107,8 @@ impl<'tcx> Hash for Interned<'tcx, TyS<'tcx>> {
}
}

impl<'tcx: 'lcx, 'lcx> Borrow<TypeVariants<'lcx>> for Interned<'tcx, TyS<'tcx>> {
fn borrow<'a>(&'a self) -> &'a TypeVariants<'lcx> {
impl<'tcx: 'lcx, 'lcx> Borrow<TyKind<'lcx>> for Interned<'tcx, TyS<'tcx>> {
fn borrow<'a>(&'a self) -> &'a TyKind<'lcx> {
&self.0.sty
}
}
Expand Down Expand Up @@ -2340,7 +2340,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
self.mk_fn_ptr(converted_sig)
}

pub fn mk_ty(&self, st: TypeVariants<'tcx>) -> Ty<'tcx> {
pub fn mk_ty(&self, st: TyKind<'tcx>) -> Ty<'tcx> {
CtxtInterners::intern_ty(&self.interners, &self.global_interners, st)
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc/ty/flags.rs
Expand Up @@ -28,7 +28,7 @@ impl FlagComputation {
}
}

pub fn for_sty(st: &ty::TypeVariants) -> FlagComputation {
pub fn for_sty(st: &ty::TyKind) -> FlagComputation {
let mut result = FlagComputation::new();
result.add_sty(st);
result
Expand Down Expand Up @@ -67,7 +67,7 @@ impl FlagComputation {
}
}

fn add_sty(&mut self, st: &ty::TypeVariants) {
fn add_sty(&mut self, st: &ty::TyKind) {
match st {
&ty::TyBool |
&ty::TyChar |
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/inhabitedness/mod.rs
Expand Up @@ -13,7 +13,7 @@ use ty::context::TyCtxt;
use ty::{AdtDef, VariantDef, FieldDef, Ty, TyS};
use ty::{DefId, Substs};
use ty::{AdtKind, Visibility};
use ty::TypeVariants::*;
use ty::TyKind::*;

pub use self::def_id_forest::DefIdForest;

Expand Down
40 changes: 20 additions & 20 deletions src/librustc/ty/mod.rs
Expand Up @@ -65,7 +65,7 @@ pub use self::sty::{Binder, CanonicalVar, DebruijnIndex, INNERMOST};
pub use self::sty::{FnSig, GenSig, PolyFnSig, PolyGenSig};
pub use self::sty::{InferTy, ParamTy, ProjectionTy, ExistentialPredicate};
pub use self::sty::{ClosureSubsts, GeneratorSubsts, UpvarSubsts, TypeAndMut};
pub use self::sty::{TraitRef, TypeVariants, PolyTraitRef};
pub use self::sty::{TraitRef, TyKind, PolyTraitRef};
pub use self::sty::{ExistentialTraitRef, PolyExistentialTraitRef};
pub use self::sty::{ExistentialProjection, PolyExistentialProjection, Const};
pub use self::sty::{BoundRegion, EarlyBoundRegion, FreeRegion, Region};
Expand All @@ -74,7 +74,7 @@ pub use self::sty::{TyVid, IntVid, FloatVid, RegionVid};
pub use self::sty::BoundRegion::*;
pub use self::sty::InferTy::*;
pub use self::sty::RegionKind::*;
pub use self::sty::TypeVariants::*;
pub use self::sty::TyKind::*;

pub use self::binding::BindingMode;
pub use self::binding::BindingMode::*;
Expand Down Expand Up @@ -490,7 +490,7 @@ bitflags! {
}

pub struct TyS<'tcx> {
pub sty: TypeVariants<'tcx>,
pub sty: TyKind<'tcx>,
pub flags: TypeFlags,

/// This is a kind of confusing thing: it stores the smallest
Expand Down Expand Up @@ -542,29 +542,29 @@ impl<'tcx> Hash for TyS<'tcx> {
impl<'tcx> TyS<'tcx> {
pub fn is_primitive_ty(&self) -> bool {
match self.sty {
TypeVariants::TyBool |
TypeVariants::TyChar |
TypeVariants::TyInt(_) |
TypeVariants::TyUint(_) |
TypeVariants::TyFloat(_) |
TypeVariants::TyInfer(InferTy::IntVar(_)) |
TypeVariants::TyInfer(InferTy::FloatVar(_)) |
TypeVariants::TyInfer(InferTy::FreshIntTy(_)) |
TypeVariants::TyInfer(InferTy::FreshFloatTy(_)) => true,
TypeVariants::TyRef(_, x, _) => x.is_primitive_ty(),
TyKind::TyBool |
TyKind::TyChar |
TyKind::TyInt(_) |
TyKind::TyUint(_) |
TyKind::TyFloat(_) |
TyKind::TyInfer(InferTy::IntVar(_)) |
TyKind::TyInfer(InferTy::FloatVar(_)) |
TyKind::TyInfer(InferTy::FreshIntTy(_)) |
TyKind::TyInfer(InferTy::FreshFloatTy(_)) => true,
TyKind::TyRef(_, x, _) => x.is_primitive_ty(),
_ => false,
}
}

pub fn is_suggestable(&self) -> bool {
match self.sty {
TypeVariants::TyAnon(..) |
TypeVariants::TyFnDef(..) |
TypeVariants::TyFnPtr(..) |
TypeVariants::TyDynamic(..) |
TypeVariants::TyClosure(..) |
TypeVariants::TyInfer(..) |
TypeVariants::TyProjection(..) => false,
TyKind::TyAnon(..) |
TyKind::TyFnDef(..) |
TyKind::TyFnPtr(..) |
TyKind::TyDynamic(..) |
TyKind::TyClosure(..) |
TyKind::TyInfer(..) |
TyKind::TyProjection(..) => false,
_ => true,
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/ty/sty.rs
Expand Up @@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! This module contains TypeVariants and its major components
//! This module contains TyKind and its major components

use hir::def_id::DefId;

Expand All @@ -33,7 +33,7 @@ use serialize;
use hir;

use self::InferTy::*;
use self::TypeVariants::*;
use self::TyKind::*;

#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, RustcEncodable, RustcDecodable)]
pub struct TypeAndMut<'tcx> {
Expand Down Expand Up @@ -82,7 +82,7 @@ impl BoundRegion {
/// NB: If you change this, you'll probably want to change the corresponding
/// AST structure in libsyntax/ast.rs as well.
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, RustcEncodable, RustcDecodable)]
pub enum TypeVariants<'tcx> {
pub enum TyKind<'tcx> {
/// The primitive boolean type. Written as `bool`.
TyBool,

Expand Down
4 changes: 2 additions & 2 deletions src/librustc/ty/util.rs
Expand Up @@ -19,7 +19,7 @@ use traits::{self, ObligationCause};
use ty::{self, Ty, TyCtxt, GenericParamDefKind, TypeFoldable};
use ty::subst::{Substs, UnpackedKind};
use ty::query::TyCtxtAt;
use ty::TypeVariants::*;
use ty::TyKind::*;
use ty::layout::{Integer, IntegerExt};
use util::common::ErrorReported;
use middle::lang_items;
Expand Down Expand Up @@ -503,7 +503,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
!impl_generics.region_param(ebr, self).pure_wrt_drop
}
UnpackedKind::Type(&ty::TyS {
sty: ty::TypeVariants::TyParam(ref pt), ..
sty: ty::TyKind::TyParam(ref pt), ..
}) => {
!impl_generics.type_param(pt, self).pure_wrt_drop
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/util/ppaux.rs
Expand Up @@ -1029,7 +1029,7 @@ define_print! {
}

define_print! {
('tcx) ty::TypeVariants<'tcx>, (self, f, cx) {
('tcx) ty::TyKind<'tcx>, (self, f, cx) {
display {
match *self {
TyBool => write!(f, "bool"),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_borrowck/borrowck/mod.rs
Expand Up @@ -697,7 +697,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
Some(nl.to_string()),
Origin::Ast);
let need_note = match lp.ty.sty {
ty::TypeVariants::TyClosure(id, _) => {
ty::TyKind::TyClosure(id, _) => {
let node_id = self.tcx.hir.as_local_node_id(id).unwrap();
let hir_id = self.tcx.hir.node_to_hir_id(node_id);
if let Some((span, name)) = self.tables.closure_kind_origins().get(hir_id) {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/intrinsic.rs
Expand Up @@ -1801,7 +1801,7 @@ fn int_type_width_signed(ty: Ty, cx: &CodegenCx) -> Option<(u64, bool)> {

// Returns the width of a float TypeVariant
// Returns None if the type is not a float
fn float_type_width<'tcx>(sty: &ty::TypeVariants<'tcx>) -> Option<u64> {
fn float_type_width<'tcx>(sty: &ty::TyKind<'tcx>) -> Option<u64> {
match *sty {
ty::TyFloat(t) => Some(t.bit_width() as u64),
_ => None,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_lint/builtin.rs
Expand Up @@ -1332,7 +1332,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutableTransmutes {
fn get_transmute_from_to<'a, 'tcx>
(cx: &LateContext<'a, 'tcx>,
expr: &hir::Expr)
-> Option<(&'tcx ty::TypeVariants<'tcx>, &'tcx ty::TypeVariants<'tcx>)> {
-> Option<(&'tcx ty::TyKind<'tcx>, &'tcx ty::TyKind<'tcx>)> {
let def = if let hir::ExprKind::Path(ref qpath) = expr.node {
cx.tables.qpath_def(qpath, expr.hir_id)
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_lint/types.rs
Expand Up @@ -321,7 +321,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
//
// No suggestion for: `isize`, `usize`.
fn get_type_suggestion<'a>(
t: &ty::TypeVariants,
t: &ty::TyKind,
val: u128,
negative: bool,
) -> Option<String> {
Expand Down Expand Up @@ -367,7 +367,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
fn report_bin_hex_error(
cx: &LateContext,
expr: &hir::Expr,
ty: ty::TypeVariants,
ty: ty::TyKind,
repr_str: String,
val: u128,
negative: bool,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/borrow_check/error_reporting.rs
Expand Up @@ -134,7 +134,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {

if let Some(ty) = self.retrieve_type_for_place(place) {
let needs_note = match ty.sty {
ty::TypeVariants::TyClosure(id, _) => {
ty::TyKind::TyClosure(id, _) => {
let tables = self.tcx.typeck_tables_of(id);
let node_id = self.tcx.hir.as_local_node_id(id).unwrap();
let hir_id = self.tcx.hir.node_to_hir_id(node_id);
Expand Down

0 comments on commit d37cee3

Please sign in to comment.