diff --git a/src/librustc/hir/def.rs b/src/librustc/hir/def.rs index 4a14223eb88f7..65146f2de8441 100644 --- a/src/librustc/hir/def.rs +++ b/src/librustc/hir/def.rs @@ -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;` @@ -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 } @@ -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", diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index b5f5f4d5c1179..a43afa9e34a73 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -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() diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index ebda91cb7b077..c3112da4f8c3a 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -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) => { diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 43cc33f422f53..6bdfbd40e8d36 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -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)] diff --git a/src/librustc/ich/impls_hir.rs b/src/librustc/ich/impls_hir.rs index 76e57558bfe07..e82ef8bbdae55 100644 --- a/src/librustc/ich/impls_hir.rs +++ b/src/librustc/ich/impls_hir.rs @@ -308,12 +308,12 @@ impl<'a> HashStable> 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 { @@ -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), diff --git a/src/librustc/ich/impls_ty.rs b/src/librustc/ich/impls_ty.rs index 46f4ed4ec478b..709b53f248dd1 100644 --- a/src/librustc/ich/impls_ty.rs +++ b/src/librustc/ich/impls_ty.rs @@ -25,7 +25,7 @@ use ty; use mir; impl<'a, 'gcx, T> HashStable> -for &'gcx ty::Slice +for &'gcx ty::List where T: HashStable> { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, @@ -53,7 +53,7 @@ for &'gcx ty::Slice } } -impl<'a, 'gcx, T> ToStableHashKey> for &'gcx ty::Slice +impl<'a, 'gcx, T> ToStableHashKey> for &'gcx ty::List where T: HashStable> { type KeyType = Fingerprint; @@ -797,90 +797,90 @@ impl_stable_hash_for!(enum ty::BoundRegion { }); impl<'a, 'gcx> HashStable> -for ty::TypeVariants<'gcx> +for ty::TyKind<'gcx> { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { - 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); } } @@ -905,7 +905,7 @@ for ty::TyVid _hasher: &mut StableHasher) { // 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) } } @@ -917,7 +917,7 @@ for ty::IntVid _hasher: &mut StableHasher) { // 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) } } @@ -929,7 +929,7 @@ for ty::FloatVid _hasher: &mut StableHasher) { // 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) } } diff --git a/src/librustc/infer/anon_types/mod.rs b/src/librustc/infer/anon_types/mod.rs index 205f8c5ad068c..96c64c05ccfbd 100644 --- a/src/librustc/infer/anon_types/mod.rs +++ b/src/librustc/infer/anon_types/mod.rs @@ -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 @@ -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 @@ -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: @@ -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; @@ -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); diff --git a/src/librustc/infer/canonical/canonicalizer.rs b/src/librustc/infer/canonical/canonicalizer.rs index c4de95c60bff5..16c33e9adf890 100644 --- a/src/librustc/infer/canonical/canonicalizer.rs +++ b/src/librustc/infer/canonical/canonicalizer.rs @@ -23,7 +23,7 @@ use infer::InferCtxt; use std::sync::atomic::Ordering; use ty::fold::{TypeFoldable, TypeFolder}; use ty::subst::Kind; -use ty::{self, CanonicalVar, Lift, Slice, Ty, TyCtxt, TypeFlags}; +use ty::{self, CanonicalVar, Lift, List, Ty, TyCtxt, TypeFlags}; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::indexed_vec::Idx; @@ -246,46 +246,46 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for Canonicalizer<'cx, 'gcx, 'tcx> fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> { match t.sty { - ty::TyInfer(ty::TyVar(_)) => self.canonicalize_ty_var(CanonicalTyVarKind::General, t), + ty::Infer(ty::TyVar(_)) => self.canonicalize_ty_var(CanonicalTyVarKind::General, t), - ty::TyInfer(ty::IntVar(_)) => self.canonicalize_ty_var(CanonicalTyVarKind::Int, t), + ty::Infer(ty::IntVar(_)) => self.canonicalize_ty_var(CanonicalTyVarKind::Int, t), - ty::TyInfer(ty::FloatVar(_)) => self.canonicalize_ty_var(CanonicalTyVarKind::Float, t), + ty::Infer(ty::FloatVar(_)) => self.canonicalize_ty_var(CanonicalTyVarKind::Float, t), - ty::TyInfer(ty::FreshTy(_)) - | ty::TyInfer(ty::FreshIntTy(_)) - | ty::TyInfer(ty::FreshFloatTy(_)) => { + ty::Infer(ty::FreshTy(_)) + | ty::Infer(ty::FreshIntTy(_)) + | ty::Infer(ty::FreshFloatTy(_)) => { bug!("encountered a fresh type during canonicalization") } - ty::TyInfer(ty::CanonicalTy(_)) => { + ty::Infer(ty::CanonicalTy(_)) => { bug!("encountered a canonical type during canonicalization") } - ty::TyClosure(..) - | ty::TyGenerator(..) - | ty::TyGeneratorWitness(..) - | ty::TyBool - | ty::TyChar - | ty::TyInt(..) - | ty::TyUint(..) - | ty::TyFloat(..) - | ty::TyAdt(..) - | ty::TyStr - | ty::TyError - | ty::TyArray(..) - | ty::TySlice(..) - | ty::TyRawPtr(..) - | ty::TyRef(..) - | ty::TyFnDef(..) - | ty::TyFnPtr(_) - | ty::TyDynamic(..) - | ty::TyNever - | ty::TyTuple(..) - | ty::TyProjection(..) - | ty::TyForeign(..) - | ty::TyParam(..) - | ty::TyAnon(..) => { + ty::Closure(..) + | ty::Generator(..) + | ty::GeneratorWitness(..) + | ty::Bool + | ty::Char + | ty::Int(..) + | ty::Uint(..) + | ty::Float(..) + | ty::Adt(..) + | ty::Str + | ty::Error + | ty::Array(..) + | ty::Slice(..) + | ty::RawPtr(..) + | ty::Ref(..) + | ty::FnDef(..) + | ty::FnPtr(_) + | ty::Dynamic(..) + | ty::Never + | ty::Tuple(..) + | ty::Projection(..) + | ty::Foreign(..) + | ty::Param(..) + | ty::Anon(..) => { if t.flags.intersects(self.needs_canonical_flags) { t.super_fold_with(self) } else { @@ -327,7 +327,7 @@ impl<'cx, 'gcx, 'tcx> Canonicalizer<'cx, 'gcx, 'tcx> { if !value.has_type_flags(needs_canonical_flags) { let out_value = gcx.lift(value).unwrap(); let canon_value = Canonical { - variables: Slice::empty(), + variables: List::empty(), value: out_value, }; return canon_value; diff --git a/src/librustc/infer/canonical/mod.rs b/src/librustc/infer/canonical/mod.rs index b56da8f630424..cb1e39bb9f742 100644 --- a/src/librustc/infer/canonical/mod.rs +++ b/src/librustc/infer/canonical/mod.rs @@ -40,7 +40,7 @@ use std::ops::Index; use syntax::source_map::Span; use ty::fold::TypeFoldable; use ty::subst::Kind; -use ty::{self, CanonicalVar, Lift, Region, Slice, TyCtxt}; +use ty::{self, CanonicalVar, Lift, Region, List, TyCtxt}; mod canonicalizer; @@ -57,7 +57,7 @@ pub struct Canonical<'gcx, V> { pub value: V, } -pub type CanonicalVarInfos<'gcx> = &'gcx Slice; +pub type CanonicalVarInfos<'gcx> = &'gcx List; impl<'gcx> UseSpecializedDecodable for CanonicalVarInfos<'gcx> {} @@ -221,7 +221,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { fn fresh_inference_vars_for_canonical_vars( &self, span: Span, - variables: &Slice, + variables: &List, ) -> CanonicalVarValues<'tcx> { let var_values: IndexVec> = variables .iter() diff --git a/src/librustc/infer/canonical/query_result.rs b/src/librustc/infer/canonical/query_result.rs index f0b6d25e9dae8..341089d8a815f 100644 --- a/src/librustc/infer/canonical/query_result.rs +++ b/src/librustc/infer/canonical/query_result.rs @@ -421,7 +421,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { match result_value.unpack() { UnpackedKind::Type(result_value) => { // e.g., here `result_value` might be `?0` in the example above... - if let ty::TyInfer(ty::InferTy::CanonicalTy(index)) = result_value.sty { + if let ty::Infer(ty::InferTy::CanonicalTy(index)) = result_value.sty { // in which case we would set `canonical_vars[0]` to `Some(?U)`. opt_values[index] = Some(*original_value); } diff --git a/src/librustc/infer/canonical/substitute.rs b/src/librustc/infer/canonical/substitute.rs index 679829f43c529..f3fe01d5fd121 100644 --- a/src/librustc/infer/canonical/substitute.rs +++ b/src/librustc/infer/canonical/substitute.rs @@ -85,7 +85,7 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for CanonicalVarValuesSubst<'cx, 'g fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> { match t.sty { - ty::TyInfer(ty::InferTy::CanonicalTy(c)) => { + ty::Infer(ty::InferTy::CanonicalTy(c)) => { match self.var_values.var_values[c].unpack() { UnpackedKind::Type(ty) => ty, r => bug!("{:?} is a type but value is {:?}", c, r), diff --git a/src/librustc/infer/combine.rs b/src/librustc/infer/combine.rs index ccba5a09cf6cc..4738a03cbd3ec 100644 --- a/src/librustc/infer/combine.rs +++ b/src/librustc/infer/combine.rs @@ -76,44 +76,44 @@ impl<'infcx, 'gcx, 'tcx> InferCtxt<'infcx, 'gcx, 'tcx> { match (&a.sty, &b.sty) { // Relate integral variables to other types - (&ty::TyInfer(ty::IntVar(a_id)), &ty::TyInfer(ty::IntVar(b_id))) => { + (&ty::Infer(ty::IntVar(a_id)), &ty::Infer(ty::IntVar(b_id))) => { self.int_unification_table .borrow_mut() .unify_var_var(a_id, b_id) .map_err(|e| int_unification_error(a_is_expected, e))?; Ok(a) } - (&ty::TyInfer(ty::IntVar(v_id)), &ty::TyInt(v)) => { + (&ty::Infer(ty::IntVar(v_id)), &ty::Int(v)) => { self.unify_integral_variable(a_is_expected, v_id, IntType(v)) } - (&ty::TyInt(v), &ty::TyInfer(ty::IntVar(v_id))) => { + (&ty::Int(v), &ty::Infer(ty::IntVar(v_id))) => { self.unify_integral_variable(!a_is_expected, v_id, IntType(v)) } - (&ty::TyInfer(ty::IntVar(v_id)), &ty::TyUint(v)) => { + (&ty::Infer(ty::IntVar(v_id)), &ty::Uint(v)) => { self.unify_integral_variable(a_is_expected, v_id, UintType(v)) } - (&ty::TyUint(v), &ty::TyInfer(ty::IntVar(v_id))) => { + (&ty::Uint(v), &ty::Infer(ty::IntVar(v_id))) => { self.unify_integral_variable(!a_is_expected, v_id, UintType(v)) } // Relate floating-point variables to other types - (&ty::TyInfer(ty::FloatVar(a_id)), &ty::TyInfer(ty::FloatVar(b_id))) => { + (&ty::Infer(ty::FloatVar(a_id)), &ty::Infer(ty::FloatVar(b_id))) => { self.float_unification_table .borrow_mut() .unify_var_var(a_id, b_id) .map_err(|e| float_unification_error(relation.a_is_expected(), e))?; Ok(a) } - (&ty::TyInfer(ty::FloatVar(v_id)), &ty::TyFloat(v)) => { + (&ty::Infer(ty::FloatVar(v_id)), &ty::Float(v)) => { self.unify_float_variable(a_is_expected, v_id, v) } - (&ty::TyFloat(v), &ty::TyInfer(ty::FloatVar(v_id))) => { + (&ty::Float(v), &ty::Infer(ty::FloatVar(v_id))) => { self.unify_float_variable(!a_is_expected, v_id, v) } // All other cases of inference are errors - (&ty::TyInfer(_), _) | - (_, &ty::TyInfer(_)) => { + (&ty::Infer(_), _) | + (_, &ty::Infer(_)) => { Err(TypeError::Sorts(ty::relate::expected_found(relation, &a, &b))) } @@ -393,7 +393,7 @@ impl<'cx, 'gcx, 'tcx> TypeRelation<'cx, 'gcx, 'tcx> for Generalizer<'cx, 'gcx, ' // subtyping. This is basically our "occurs check", preventing // us from creating infinitely sized types. match t.sty { - ty::TyInfer(ty::TyVar(vid)) => { + ty::Infer(ty::TyVar(vid)) => { let mut variables = self.infcx.type_variables.borrow_mut(); let vid = variables.root_var(vid); let sub_vid = variables.sub_root_var(vid); @@ -433,8 +433,8 @@ impl<'cx, 'gcx, 'tcx> TypeRelation<'cx, 'gcx, 'tcx> for Generalizer<'cx, 'gcx, ' } } } - ty::TyInfer(ty::IntVar(_)) | - ty::TyInfer(ty::FloatVar(_)) => { + ty::Infer(ty::IntVar(_)) | + ty::Infer(ty::FloatVar(_)) => { // No matter what mode we are in, // integer/floating-point types must be equal to be // relatable. diff --git a/src/librustc/infer/equate.rs b/src/librustc/infer/equate.rs index 2ae8f8ae93357..26eb2ffbf6aba 100644 --- a/src/librustc/infer/equate.rs +++ b/src/librustc/infer/equate.rs @@ -75,17 +75,17 @@ impl<'combine, 'infcx, 'gcx, 'tcx> TypeRelation<'infcx, 'gcx, 'tcx> let a = infcx.type_variables.borrow_mut().replace_if_possible(a); let b = infcx.type_variables.borrow_mut().replace_if_possible(b); match (&a.sty, &b.sty) { - (&ty::TyInfer(TyVar(a_id)), &ty::TyInfer(TyVar(b_id))) => { + (&ty::Infer(TyVar(a_id)), &ty::Infer(TyVar(b_id))) => { infcx.type_variables.borrow_mut().equate(a_id, b_id); Ok(a) } - (&ty::TyInfer(TyVar(a_id)), _) => { + (&ty::Infer(TyVar(a_id)), _) => { self.fields.instantiate(b, RelationDir::EqTo, a_id, self.a_is_expected)?; Ok(a) } - (_, &ty::TyInfer(TyVar(b_id))) => { + (_, &ty::Infer(TyVar(b_id))) => { self.fields.instantiate(a, RelationDir::EqTo, b_id, self.a_is_expected)?; Ok(a) } diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs index d458d62e738c3..02da3701db297 100644 --- a/src/librustc/infer/error_reporting/mod.rs +++ b/src/librustc/infer/error_reporting/mod.rs @@ -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}; @@ -484,7 +484,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { // if they are both "path types", there's a chance of ambiguity // due to different versions of the same crate match (&exp_found.expected.sty, &exp_found.found.sty) { - (&ty::TyAdt(exp_adt, _), &ty::TyAdt(found_adt, _)) => { + (&ty::Adt(exp_adt, _), &ty::Adt(found_adt, _)) => { report_path_match(err, exp_adt.did, found_adt.did); } _ => (), @@ -636,7 +636,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { self.highlight_outer(&mut t1_out, &mut t2_out, path, sub, i, &other_ty); return Some(()); } - if let &ty::TyAdt(def, _) = &ta.sty { + if let &ty::Adt(def, _) = &ta.sty { let path_ = self.tcx.item_path_str(def.did.clone()); if path_ == other_path { self.highlight_outer(&mut t1_out, &mut t2_out, path, sub, i, &other_ty); @@ -704,14 +704,14 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { fn equals<'tcx>(a: &Ty<'tcx>, b: &Ty<'tcx>) -> bool { match (&a.sty, &b.sty) { (a, b) if *a == *b => true, - (&ty::TyInt(_), &ty::TyInfer(ty::InferTy::IntVar(_))) - | (&ty::TyInfer(ty::InferTy::IntVar(_)), &ty::TyInt(_)) - | (&ty::TyInfer(ty::InferTy::IntVar(_)), &ty::TyInfer(ty::InferTy::IntVar(_))) - | (&ty::TyFloat(_), &ty::TyInfer(ty::InferTy::FloatVar(_))) - | (&ty::TyInfer(ty::InferTy::FloatVar(_)), &ty::TyFloat(_)) + (&ty::Int(_), &ty::Infer(ty::InferTy::IntVar(_))) + | (&ty::Infer(ty::InferTy::IntVar(_)), &ty::Int(_)) + | (&ty::Infer(ty::InferTy::IntVar(_)), &ty::Infer(ty::InferTy::IntVar(_))) + | (&ty::Float(_), &ty::Infer(ty::InferTy::FloatVar(_))) + | (&ty::Infer(ty::InferTy::FloatVar(_)), &ty::Float(_)) | ( - &ty::TyInfer(ty::InferTy::FloatVar(_)), - &ty::TyInfer(ty::InferTy::FloatVar(_)), + &ty::Infer(ty::InferTy::FloatVar(_)), + &ty::Infer(ty::InferTy::FloatVar(_)), ) => true, _ => false, } @@ -738,7 +738,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } match (&t1.sty, &t2.sty) { - (&ty::TyAdt(def1, sub1), &ty::TyAdt(def2, sub2)) => { + (&ty::Adt(def1, sub1), &ty::Adt(def2, sub2)) => { let sub_no_defaults_1 = self.strip_generic_default_params(def1.did, sub1); let sub_no_defaults_2 = self.strip_generic_default_params(def2.did, sub2); let mut values = (DiagnosticStyledString::new(), DiagnosticStyledString::new()); @@ -877,13 +877,13 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } // When finding T != &T, highlight only the borrow - (&ty::TyRef(r1, ref_ty1, mutbl1), _) if equals(&ref_ty1, &t2) => { + (&ty::Ref(r1, ref_ty1, mutbl1), _) if equals(&ref_ty1, &t2) => { let mut values = (DiagnosticStyledString::new(), DiagnosticStyledString::new()); push_ty_ref(&r1, ref_ty1, mutbl1, &mut values.0); values.1.push_normal(t2.to_string()); values } - (_, &ty::TyRef(r2, ref_ty2, mutbl2)) if equals(&t1, &ref_ty2) => { + (_, &ty::Ref(r2, ref_ty2, mutbl2)) if equals(&t1, &ref_ty2) => { let mut values = (DiagnosticStyledString::new(), DiagnosticStyledString::new()); values.0.push_normal(t1.to_string()); push_ty_ref(&r2, ref_ty2, mutbl2, &mut values.1); @@ -891,8 +891,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } // When encountering &T != &mut T, highlight only the borrow - (&ty::TyRef(r1, ref_ty1, mutbl1), - &ty::TyRef(r2, ref_ty2, mutbl2)) if equals(&ref_ty1, &ref_ty2) => { + (&ty::Ref(r1, ref_ty1, mutbl1), + &ty::Ref(r2, ref_ty2, mutbl2)) if equals(&ref_ty1, &ref_ty2) => { let mut values = (DiagnosticStyledString::new(), DiagnosticStyledString::new()); push_ty_ref(&r1, ref_ty1, mutbl1, &mut values.0); push_ty_ref(&r2, ref_ty2, mutbl2, &mut values.1); @@ -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::FnDef(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::Adt(def, _) => def.is_struct(), _ => false, }; @@ -1123,7 +1123,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { let type_param = generics.type_param(param, self.tcx); let hir = &self.tcx.hir; hir.as_local_node_id(type_param.def_id).map(|id| { - // Get the `hir::TyParam` to verify whether it already has any bounds. + // Get the `hir::Param` to verify whether it already has any bounds. // We do this to avoid suggesting code that ends up as `T: 'a'b`, // instead we suggest `T: 'a + 'b` in that case. let mut has_bounds = false; diff --git a/src/librustc/infer/error_reporting/need_type_info.rs b/src/librustc/infer/error_reporting/need_type_info.rs index bd2c81c7fb64f..505b1bc032d20 100644 --- a/src/librustc/infer/error_reporting/need_type_info.rs +++ b/src/librustc/infer/error_reporting/need_type_info.rs @@ -12,7 +12,7 @@ use hir::{self, Local, Pat, Body, HirId}; use hir::intravisit::{self, Visitor, NestedVisitorMap}; use infer::InferCtxt; use infer::type_variable::TypeVariableOrigin; -use ty::{self, Ty, TyInfer, TyVar}; +use ty::{self, Ty, Infer, TyVar}; use syntax::source_map::CompilerDesugaringKind; use syntax_pos::Span; use errors::DiagnosticBuilder; @@ -35,7 +35,7 @@ impl<'a, 'gcx, 'tcx> FindLocalByTypeVisitor<'a, 'gcx, 'tcx> { let ty = self.infcx.resolve_type_vars_if_possible(&ty); ty.walk().any(|inner_ty| { inner_ty == *self.target_ty || match (&inner_ty.sty, &self.target_ty.sty) { - (&TyInfer(TyVar(a_vid)), &TyInfer(TyVar(b_vid))) => { + (&Infer(TyVar(a_vid)), &Infer(TyVar(b_vid))) => { self.infcx .type_variables .borrow_mut() @@ -75,7 +75,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindLocalByTypeVisitor<'a, 'gcx, 'tcx> { impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { pub fn extract_type_name(&self, ty: &'a Ty<'tcx>) -> String { - if let ty::TyInfer(ty::TyVar(ty_vid)) = (*ty).sty { + if let ty::Infer(ty::TyVar(ty_vid)) = (*ty).sty { let ty_vars = self.type_variables.borrow(); if let TypeVariableOrigin::TypeParameterDefinition(_, name) = *ty_vars.var_origin(ty_vid) { diff --git a/src/librustc/infer/error_reporting/nice_region_error/util.rs b/src/librustc/infer/error_reporting/nice_region_error/util.rs index 28320ce3ad1ba..8cb0df18bc8ff 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/util.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/util.rs @@ -162,7 +162,7 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { ) -> Option { let ret_ty = self.tcx.type_of(scope_def_id); match ret_ty.sty { - ty::TyFnDef(_, _) => { + ty::FnDef(_, _) => { let sig = ret_ty.fn_sig(self.tcx); let late_bound_regions = self.tcx .collect_referenced_late_bound_regions(&sig.output()); @@ -181,7 +181,7 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { ) -> bool { let ret_ty = self.tcx.type_of(scope_def_id); match ret_ty.sty { - ty::TyFnDef(_, _) => { + ty::FnDef(_, _) => { let sig = ret_ty.fn_sig(self.tcx); let output = self.tcx.erase_late_bound_regions(&sig.output()); return output.is_impl_trait(); diff --git a/src/librustc/infer/freshen.rs b/src/librustc/infer/freshen.rs index 6074bfd083d46..4673aac1872ff 100644 --- a/src/librustc/infer/freshen.rs +++ b/src/librustc/infer/freshen.rs @@ -133,7 +133,7 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for TypeFreshener<'a, 'gcx, 'tcx> { let tcx = self.infcx.tcx; match t.sty { - ty::TyInfer(ty::TyVar(v)) => { + ty::Infer(ty::TyVar(v)) => { let opt_ty = self.infcx.type_variables.borrow_mut().probe(v).known(); self.freshen( opt_ty, @@ -141,7 +141,7 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for TypeFreshener<'a, 'gcx, 'tcx> { ty::FreshTy) } - ty::TyInfer(ty::IntVar(v)) => { + ty::Infer(ty::IntVar(v)) => { self.freshen( self.infcx.int_unification_table.borrow_mut() .probe_value(v) @@ -150,7 +150,7 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for TypeFreshener<'a, 'gcx, 'tcx> { ty::FreshIntTy) } - ty::TyInfer(ty::FloatVar(v)) => { + ty::Infer(ty::FloatVar(v)) => { self.freshen( self.infcx.float_unification_table.borrow_mut() .probe_value(v) @@ -159,9 +159,9 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for TypeFreshener<'a, 'gcx, 'tcx> { ty::FreshFloatTy) } - ty::TyInfer(ty::FreshTy(c)) | - ty::TyInfer(ty::FreshIntTy(c)) | - ty::TyInfer(ty::FreshFloatTy(c)) => { + ty::Infer(ty::FreshTy(c)) | + ty::Infer(ty::FreshIntTy(c)) | + ty::Infer(ty::FreshFloatTy(c)) => { if c >= self.freshen_count { bug!("Encountered a freshend type with id {} \ but our counter is only at {}", @@ -171,33 +171,33 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for TypeFreshener<'a, 'gcx, 'tcx> { t } - ty::TyInfer(ty::CanonicalTy(..)) => + ty::Infer(ty::CanonicalTy(..)) => bug!("encountered canonical ty during freshening"), - ty::TyGenerator(..) | - ty::TyBool | - ty::TyChar | - ty::TyInt(..) | - ty::TyUint(..) | - ty::TyFloat(..) | - ty::TyAdt(..) | - ty::TyStr | - ty::TyError | - ty::TyArray(..) | - ty::TySlice(..) | - ty::TyRawPtr(..) | - ty::TyRef(..) | - ty::TyFnDef(..) | - ty::TyFnPtr(_) | - ty::TyDynamic(..) | - ty::TyNever | - ty::TyTuple(..) | - ty::TyProjection(..) | - ty::TyForeign(..) | - ty::TyParam(..) | - ty::TyClosure(..) | - ty::TyGeneratorWitness(..) | - ty::TyAnon(..) => { + ty::Generator(..) | + ty::Bool | + ty::Char | + ty::Int(..) | + ty::Uint(..) | + ty::Float(..) | + ty::Adt(..) | + ty::Str | + ty::Error | + ty::Array(..) | + ty::Slice(..) | + ty::RawPtr(..) | + ty::Ref(..) | + ty::FnDef(..) | + ty::FnPtr(_) | + ty::Dynamic(..) | + ty::Never | + ty::Tuple(..) | + ty::Projection(..) | + ty::Foreign(..) | + ty::Param(..) | + ty::Closure(..) | + ty::GeneratorWitness(..) | + ty::Anon(..) => { t.super_fold_with(self) } } diff --git a/src/librustc/infer/fudge.rs b/src/librustc/infer/fudge.rs index 961dd70a46852..39dc24b86e72a 100644 --- a/src/librustc/infer/fudge.rs +++ b/src/librustc/infer/fudge.rs @@ -123,7 +123,7 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for RegionFudger<'a, 'gcx, 'tcx> { fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { match ty.sty { - ty::TyInfer(ty::InferTy::TyVar(vid)) => { + ty::Infer(ty::InferTy::TyVar(vid)) => { match self.type_variables.get(&vid) { None => { // This variable was created before the diff --git a/src/librustc/infer/lattice.rs b/src/librustc/infer/lattice.rs index 28aba51ab3724..6848c625b5a1f 100644 --- a/src/librustc/infer/lattice.rs +++ b/src/librustc/infer/lattice.rs @@ -88,12 +88,12 @@ pub fn super_lattice_tys<'a, 'gcx, 'tcx, L>(this: &mut L, // is (e.g.) `Box`. A more obvious solution might be to // iterate on the subtype obligations that are returned, but I // think this suffices. -nmatsakis - (&ty::TyInfer(TyVar(..)), _) => { + (&ty::Infer(TyVar(..)), _) => { let v = infcx.next_ty_var(TypeVariableOrigin::LatticeVariable(this.cause().span)); this.relate_bound(v, b, a)?; Ok(v) } - (_, &ty::TyInfer(TyVar(..))) => { + (_, &ty::Infer(TyVar(..))) => { let v = infcx.next_ty_var(TypeVariableOrigin::LatticeVariable(this.cause().span)); this.relate_bound(v, a, b)?; Ok(v) diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs index eed6215150fdb..a3c9d14eef295 100644 --- a/src/librustc/infer/mod.rs +++ b/src/librustc/infer/mod.rs @@ -546,7 +546,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { pub fn type_var_diverges(&'a self, ty: Ty) -> bool { match ty.sty { - ty::TyInfer(ty::TyVar(vid)) => self.type_variables.borrow().var_diverges(vid), + ty::Infer(ty::TyVar(vid)) => self.type_variables.borrow().var_diverges(vid), _ => false } } @@ -559,14 +559,14 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { use ty::error::UnconstrainedNumeric::Neither; use ty::error::UnconstrainedNumeric::{UnconstrainedInt, UnconstrainedFloat}; match ty.sty { - ty::TyInfer(ty::IntVar(vid)) => { + ty::Infer(ty::IntVar(vid)) => { if self.int_unification_table.borrow_mut().probe_value(vid).is_some() { Neither } else { UnconstrainedInt } }, - ty::TyInfer(ty::FloatVar(vid)) => { + ty::Infer(ty::FloatVar(vid)) => { if self.float_unification_table.borrow_mut().probe_value(vid).is_some() { Neither } else { @@ -1118,7 +1118,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { pub fn shallow_resolve(&self, typ: Ty<'tcx>) -> Ty<'tcx> { match typ.sty { - ty::TyInfer(ty::TyVar(v)) => { + ty::Infer(ty::TyVar(v)) => { // Not entirely obvious: if `typ` is a type variable, // it can be resolved to an int/float variable, which // can then be recursively resolved, hence the @@ -1135,7 +1135,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { .unwrap_or(typ) } - ty::TyInfer(ty::IntVar(v)) => { + ty::Infer(ty::IntVar(v)) => { self.int_unification_table .borrow_mut() .probe_value(v) @@ -1143,7 +1143,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { .unwrap_or(typ) } - ty::TyInfer(ty::FloatVar(v)) => { + ty::Infer(ty::FloatVar(v)) => { self.float_unification_table .borrow_mut() .probe_value(v) @@ -1210,12 +1210,12 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } // [Note-Type-error-reporting] - // An invariant is that anytime the expected or actual type is TyError (the special + // An invariant is that anytime the expected or actual type is Error (the special // error type, meaning that an error occurred when typechecking this expression), // this is a derived error. The error cascaded from another error (that was already // reported), so it's not useful to display it to the user. // The following methods implement this logic. - // They check if either the actual or expected type is TyError, and don't print the error + // They check if either the actual or expected type is Error, and don't print the error // in this case. The typechecker should only ever report type errors involving mismatched // types using one of these methods, and should not call span_err directly for such // errors. @@ -1230,7 +1230,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { let actual_ty = self.resolve_type_vars_if_possible(&actual_ty); debug!("type_error_struct_with_diag({:?}, {:?})", sp, actual_ty); - // Don't report an error if actual type is TyError. + // Don't report an error if actual type is Error. if actual_ty.references_error() { return self.tcx.sess.diagnostic().struct_dummy(); } diff --git a/src/librustc/infer/outlives/obligations.rs b/src/librustc/infer/outlives/obligations.rs index 3598d66060bf2..817280b97e031 100644 --- a/src/librustc/infer/outlives/obligations.rs +++ b/src/librustc/infer/outlives/obligations.rs @@ -450,8 +450,8 @@ where fn type_bound(&self, ty: Ty<'tcx>) -> VerifyBound<'tcx> { match ty.sty { - ty::TyParam(p) => self.param_bound(p), - ty::TyProjection(data) => { + ty::Param(p) => self.param_bound(p), + ty::Projection(data) => { let declared_bounds = self.projection_declared_bounds(data); self.projection_bound(declared_bounds, data) } diff --git a/src/librustc/infer/resolve.rs b/src/librustc/infer/resolve.rs index 77b722c5695f8..be13fb9a2a5eb 100644 --- a/src/librustc/infer/resolve.rs +++ b/src/librustc/infer/resolve.rs @@ -104,7 +104,7 @@ impl<'a, 'gcx, 'tcx> TypeVisitor<'tcx> for UnresolvedTypeFinder<'a, 'gcx, 'tcx> fn visit_ty(&mut self, t: Ty<'tcx>) -> bool { let t = self.infcx.shallow_resolve(t); if t.has_infer_types() { - if let ty::TyInfer(_) = t.sty { + if let ty::Infer(_) = t.sty { // Since we called `shallow_resolve` above, this must // be an (as yet...) unresolved inference variable. true @@ -158,19 +158,19 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for FullTypeResolver<'a, 'gcx, 'tcx> } else { let t = self.infcx.shallow_resolve(t); match t.sty { - ty::TyInfer(ty::TyVar(vid)) => { + ty::Infer(ty::TyVar(vid)) => { self.err = Some(FixupError::UnresolvedTy(vid)); self.tcx().types.err } - ty::TyInfer(ty::IntVar(vid)) => { + ty::Infer(ty::IntVar(vid)) => { self.err = Some(FixupError::UnresolvedIntTy(vid)); self.tcx().types.err } - ty::TyInfer(ty::FloatVar(vid)) => { + ty::Infer(ty::FloatVar(vid)) => { self.err = Some(FixupError::UnresolvedFloatTy(vid)); self.tcx().types.err } - ty::TyInfer(_) => { + ty::Infer(_) => { bug!("Unexpected type in full type resolver: {:?}", t); } _ => { diff --git a/src/librustc/infer/sub.rs b/src/librustc/infer/sub.rs index 58eae5e6a5b94..048810c042722 100644 --- a/src/librustc/infer/sub.rs +++ b/src/librustc/infer/sub.rs @@ -80,7 +80,7 @@ impl<'combine, 'infcx, 'gcx, 'tcx> TypeRelation<'infcx, 'gcx, 'tcx> let a = infcx.type_variables.borrow_mut().replace_if_possible(a); let b = infcx.type_variables.borrow_mut().replace_if_possible(b); match (&a.sty, &b.sty) { - (&ty::TyInfer(TyVar(a_vid)), &ty::TyInfer(TyVar(b_vid))) => { + (&ty::Infer(TyVar(a_vid)), &ty::Infer(TyVar(b_vid))) => { // Shouldn't have any LBR here, so we can safely put // this under a binder below without fear of accidental // capture. @@ -106,17 +106,17 @@ impl<'combine, 'infcx, 'gcx, 'tcx> TypeRelation<'infcx, 'gcx, 'tcx> Ok(a) } - (&ty::TyInfer(TyVar(a_id)), _) => { + (&ty::Infer(TyVar(a_id)), _) => { self.fields .instantiate(b, RelationDir::SupertypeOf, a_id, !self.a_is_expected)?; Ok(a) } - (_, &ty::TyInfer(TyVar(b_id))) => { + (_, &ty::Infer(TyVar(b_id))) => { self.fields.instantiate(a, RelationDir::SubtypeOf, b_id, self.a_is_expected)?; Ok(a) } - (&ty::TyError, _) | (_, &ty::TyError) => { + (&ty::Error, _) | (_, &ty::Error) => { infcx.set_tainted_by_errors(); Ok(self.tcx().types.err) } diff --git a/src/librustc/infer/type_variable.rs b/src/librustc/infer/type_variable.rs index d40e1b3760f03..b1e4fc7c7fc7b 100644 --- a/src/librustc/infer/type_variable.rs +++ b/src/librustc/infer/type_variable.rs @@ -245,7 +245,7 @@ impl<'tcx> TypeVariableTable<'tcx> { /// instantiated. Otherwise, returns `t`. pub fn replace_if_possible(&mut self, t: Ty<'tcx>) -> Ty<'tcx> { match t.sty { - ty::TyInfer(ty::TyVar(v)) => { + ty::Infer(ty::TyVar(v)) => { match self.probe(v) { TypeVariableValue::Unknown { .. } => t, TypeVariableValue::Known { value } => value, diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index 8c4c54ec954d0..ba04842ac7c0a 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -105,11 +105,11 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> { fn handle_field_access(&mut self, lhs: &hir::Expr, node_id: ast::NodeId) { match self.tables.expr_ty_adjusted(lhs).sty { - ty::TyAdt(def, _) => { + ty::Adt(def, _) => { let index = self.tcx.field_index(node_id, self.tables); self.insert_def_id(def.non_enum_variant().fields[index].did); } - ty::TyTuple(..) => {} + ty::Tuple(..) => {} _ => span_bug!(lhs.span, "named field access on non-ADT"), } } @@ -117,7 +117,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> { fn handle_field_pattern_match(&mut self, lhs: &hir::Pat, def: Def, pats: &[source_map::Spanned]) { let variant = match self.tables.node_id_to_type(lhs.hir_id).sty { - ty::TyAdt(adt, _) => adt.variant_of_def(def), + ty::Adt(adt, _) => adt.variant_of_def(def), _ => span_bug!(lhs.span, "non-ADT in struct pattern") }; for pat in pats { @@ -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::Adt(ref adt, _) = self.tables.expr_ty(expr).sty { self.mark_as_used_if_union(adt, fields); } } diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index 5beafe2b601bf..90692bcd30103 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -457,7 +457,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> { // make sure that the thing we are pointing out stays valid // for the lifetime `scope_r` of the resulting ptr: let expr_ty = return_if_err!(self.mc.expr_ty(expr)); - if let ty::TyRef(r, _, _) = expr_ty.sty { + if let ty::Ref(r, _, _) = expr_ty.sty { let bk = ty::BorrowKind::from_mutbl(m); self.borrow_expr(&base, r, bk, AddrOf); } @@ -551,10 +551,10 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> { debug!("walk_callee: callee={:?} callee_ty={:?}", callee, callee_ty); match callee_ty.sty { - ty::TyFnDef(..) | ty::TyFnPtr(_) => { + ty::FnDef(..) | ty::FnPtr(_) => { self.consume_expr(callee); } - ty::TyError => { } + ty::Error => { } _ => { if let Some(def) = self.mc.tables.type_dependent_defs().get(call.hir_id) { let def_id = def.def_id(); @@ -659,7 +659,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> { // Select just those fields of the `with` // expression that will actually be used match with_cmt.ty.sty { - ty::TyAdt(adt, substs) if adt.is_struct() => { + ty::Adt(adt, substs) if adt.is_struct() => { // Consume those fields of the with expression that are needed. for (f_index, with_field) in adt.non_enum_variant().fields.iter().enumerate() { let is_mentioned = fields.iter().any(|f| { @@ -867,7 +867,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> { // It is also a borrow or copy/move of the value being matched. match bm { ty::BindByReference(m) => { - if let ty::TyRef(r, _, _) = pat_ty.sty { + if let ty::Ref(r, _, _) = pat_ty.sty { let bk = ty::BorrowKind::from_mutbl(m); delegate.borrow(pat.id, pat.span, &cmt_pat, r, bk, RefBinding); } diff --git a/src/librustc/middle/intrinsicck.rs b/src/librustc/middle/intrinsicck.rs index 8e4fb547d4164..8058f3dde668d 100644 --- a/src/librustc/middle/intrinsicck.rs +++ b/src/librustc/middle/intrinsicck.rs @@ -41,7 +41,7 @@ fn unpack_option_like<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> { let (def, substs) = match ty.sty { - ty::TyAdt(def, substs) => (def, substs), + ty::Adt(def, substs) => (def, substs), _ => return ty }; @@ -83,7 +83,7 @@ impl<'a, 'tcx> ExprVisitor<'a, 'tcx> { // Special-case transmutting from `typeof(function)` and // `Option` to present a clearer error. let from = unpack_option_like(self.tcx.global_tcx(), from); - if let (&ty::TyFnDef(..), SizeSkeleton::Known(size_to)) = (&from.sty, sk_to) { + if let (&ty::FnDef(..), SizeSkeleton::Known(size_to)) = (&from.sty, sk_to) { if size_to == Pointer.size(self.tcx) { struct_span_err!(self.tcx.sess, span, E0591, "can't transmute zero-sized type") diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 8feefdf5a1ddb..e0ed0f1da509e 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -214,8 +214,8 @@ impl<'tcx> cmt_<'tcx> { fn resolve_field(&self, field_index: usize) -> Option<(&'tcx ty::AdtDef, &'tcx ty::FieldDef)> { let adt_def = match self.ty.sty { - ty::TyAdt(def, _) => def, - ty::TyTuple(..) => return None, + ty::Adt(def, _) => def, + ty::Tuple(..) => return None, // closures get `Categorization::Upvar` rather than `Categorization::Interior` _ => bug!("interior cmt {:?} is not an ADT", self) }; @@ -783,8 +783,8 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { // FnOnce | copied | upvar -> &'up bk let kind = match self.node_ty(fn_hir_id)?.sty { - ty::TyGenerator(..) => ty::ClosureKind::FnOnce, - ty::TyClosure(closure_def_id, closure_substs) => { + ty::Generator(..) => ty::ClosureKind::FnOnce, + ty::Closure(closure_def_id, closure_substs) => { match self.infcx { // During upvar inference we may not know the // closure kind, just use the LATTICE_BOTTOM value. @@ -893,7 +893,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { // that the above is actually immutable and // has a ref type. However, nothing should // actually look at the type, so we can get - // away with stuffing a `TyError` in there + // away with stuffing a `Error` in there // instead of bothering to construct a proper // one. let cmt_result = cmt_ { @@ -956,7 +956,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { // Always promote `[T; 0]` (even when e.g. borrowed mutably). let promotable = match expr_ty.sty { - ty::TyArray(_, len) if len.assert_usize(self.tcx) == Some(0) => true, + ty::Array(_, len) if len.assert_usize(self.tcx) == Some(0) => true, _ => promotable, }; @@ -1035,7 +1035,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { let base_ty = self.expr_ty_adjusted(base)?; let (region, mutbl) = match base_ty.sty { - ty::TyRef(region, _, mutbl) => (region, mutbl), + ty::Ref(region, _, mutbl) => (region, mutbl), _ => { span_bug!(expr.span, "cat_overloaded_place: base is not a reference") } @@ -1068,9 +1068,9 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { }; let ptr = match base_cmt.ty.sty { - ty::TyAdt(def, ..) if def.is_box() => Unique, - ty::TyRawPtr(ref mt) => UnsafePtr(mt.mutbl), - ty::TyRef(r, _, mutbl) => { + ty::Adt(def, ..) if def.is_box() => Unique, + ty::RawPtr(ref mt) => UnsafePtr(mt.mutbl), + ty::Ref(r, _, mutbl) => { let bk = ty::BorrowKind::from_mutbl(mutbl); BorrowedPtr(bk, r) } @@ -1290,7 +1290,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { } Def::StructCtor(_, CtorKind::Fn) => { match self.pat_ty_unadjusted(&pat)?.sty { - ty::TyAdt(adt_def, _) => { + ty::Adt(adt_def, _) => { (cmt, adt_def.non_enum_variant().fields.len()) } ref ty => { @@ -1343,7 +1343,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { PatKind::Tuple(ref subpats, ddpos) => { // (p1, ..., pN) let expected_len = match self.pat_ty_unadjusted(&pat)?.sty { - ty::TyTuple(ref tys) => tys.len(), + ty::Tuple(ref tys) => tys.len(), ref ty => span_bug!(pat.span, "tuple pattern unexpected type {:?}", ty), }; for (i, subpat) in subpats.iter().enumerate_and_adjust(expected_len, ddpos) { diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index e958ca9b9bb02..66a42cfb11a74 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -2221,18 +2221,18 @@ 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 if let ConstValue::Scalar(Scalar::Bits { bits, .. }) = value { match ty.sty { - TyBool if bits == 0 => return write!(f, "false"), - TyBool if bits == 1 => return write!(f, "true"), - TyFloat(ast::FloatTy::F32) => return write!(f, "{}f32", Single::from_bits(bits)), - TyFloat(ast::FloatTy::F64) => return write!(f, "{}f64", Double::from_bits(bits)), - TyUint(ui) => return write!(f, "{:?}{}", bits, ui), - TyInt(i) => { + Bool if bits == 0 => return write!(f, "false"), + Bool if bits == 1 => return write!(f, "true"), + Float(ast::FloatTy::F32) => return write!(f, "{}f32", Single::from_bits(bits)), + Float(ast::FloatTy::F64) => return write!(f, "{}f64", Double::from_bits(bits)), + Uint(ui) => return write!(f, "{:?}{}", bits, ui), + Int(i) => { let bit_width = ty::tls::with(|tcx| { let ty = tcx.lift_to_global(&ty).unwrap(); tcx.layout_of(ty::ParamEnv::empty().and(ty)) @@ -2243,19 +2243,19 @@ pub fn fmt_const_val(f: &mut impl Write, const_val: &ty::Const) -> fmt::Result { let shift = 128 - bit_width; return write!(f, "{:?}{}", ((bits as i128) << shift) >> shift, i); } - TyChar => return write!(f, "{:?}", ::std::char::from_u32(bits as u32).unwrap()), + Char => return write!(f, "{:?}", ::std::char::from_u32(bits as u32).unwrap()), _ => {}, } } // print function definitons - if let TyFnDef(did, _) = ty.sty { + if let FnDef(did, _) = ty.sty { return write!(f, "{}", item_path_str(did)); } // print string literals if let ConstValue::ScalarPair(ptr, len) = value { if let Scalar::Ptr(ptr) = ptr { if let ScalarMaybeUndef::Scalar(Scalar::Bits { bits: len, .. }) = len { - if let TyRef(_, &ty::TyS { sty: TyStr, .. }, _) = ty.sty { + if let Ref(_, &ty::TyS { sty: Str, .. }, _) = ty.sty { return ty::tls::with(|tcx| { let alloc = tcx.alloc_map.lock().get(ptr.alloc_id); if let Some(interpret::AllocType::Memory(alloc)) = alloc { diff --git a/src/librustc/mir/tcx.rs b/src/librustc/mir/tcx.rs index 5991845d265b2..ec395478ec6b5 100644 --- a/src/librustc/mir/tcx.rs +++ b/src/librustc/mir/tcx.rs @@ -68,12 +68,12 @@ impl<'a, 'gcx, 'tcx> PlaceTy<'tcx> { let ty = self.to_ty(tcx); PlaceTy::Ty { ty: match ty.sty { - ty::TyArray(inner, size) => { + ty::Array(inner, size) => { let size = size.unwrap_usize(tcx); let len = size - (from as u64) - (to as u64); tcx.mk_array(inner, len) } - ty::TySlice(..) => ty, + ty::Slice(..) => ty, _ => { bug!("cannot subslice non-array type: `{:?}`", self) } @@ -82,7 +82,7 @@ impl<'a, 'gcx, 'tcx> PlaceTy<'tcx> { } ProjectionElem::Downcast(adt_def1, index) => match self.to_ty(tcx).sty { - ty::TyAdt(adt_def, substs) => { + ty::Adt(adt_def, substs) => { assert!(adt_def.is_enum()); assert!(index < adt_def.variants.len()); assert_eq!(adt_def, adt_def1); @@ -199,7 +199,7 @@ impl<'tcx> Rvalue<'tcx> { } Rvalue::Discriminant(ref place) => { let ty = place.ty(local_decls, tcx).to_ty(tcx); - if let ty::TyAdt(adt_def, _) = ty.sty { + if let ty::Adt(adt_def, _) = ty.sty { adt_def.repr.discr_type().to_ty(tcx) } else { // This can only be `0`, for now, so `u8` will suffice. diff --git a/src/librustc/traits/auto_trait.rs b/src/librustc/traits/auto_trait.rs index a0882f8f92b46..ed95aa73078a9 100644 --- a/src/librustc/traits/auto_trait.rs +++ b/src/librustc/traits/auto_trait.rs @@ -606,8 +606,8 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { } return match substs.type_at(0).sty { - ty::TyParam(_) => true, - ty::TyProjection(p) => self.is_of_param(p.substs), + ty::Param(_) => true, + ty::Projection(p) => self.is_of_param(p.substs), _ => false, }; } diff --git a/src/librustc/traits/coherence.rs b/src/librustc/traits/coherence.rs index 02bfab033efc8..c283c4d3caba3 100644 --- a/src/librustc/traits/coherence.rs +++ b/src/librustc/traits/coherence.rs @@ -407,7 +407,7 @@ fn uncovered_tys<'tcx>(tcx: TyCtxt, ty: Ty<'tcx>, in_crate: InCrate) fn is_possibly_remote_type(ty: Ty, _in_crate: InCrate) -> bool { match ty.sty { - ty::TyProjection(..) | ty::TyParam(..) => true, + ty::Projection(..) | ty::Param(..) => true, _ => false, } } @@ -419,9 +419,9 @@ fn ty_is_local(tcx: TyCtxt, ty: Ty, in_crate: InCrate) -> bool { fn fundamental_ty(tcx: TyCtxt, ty: Ty) -> bool { match ty.sty { - ty::TyRef(..) => true, - ty::TyAdt(def, _) => def.is_fundamental(), - ty::TyDynamic(ref data, ..) => { + ty::Ref(..) => true, + ty::Adt(def, _) => def.is_fundamental(), + ty::Dynamic(ref data, ..) => { data.principal().map_or(false, |p| tcx.has_attr(p.def_id(), "fundamental")) } _ => false @@ -441,49 +441,49 @@ fn ty_is_local_constructor(ty: Ty, in_crate: InCrate) -> bool { debug!("ty_is_local_constructor({:?})", ty); match ty.sty { - ty::TyBool | - ty::TyChar | - ty::TyInt(..) | - ty::TyUint(..) | - ty::TyFloat(..) | - ty::TyStr | - ty::TyFnDef(..) | - ty::TyFnPtr(_) | - ty::TyArray(..) | - ty::TySlice(..) | - ty::TyRawPtr(..) | - ty::TyRef(..) | - ty::TyNever | - ty::TyTuple(..) | - ty::TyParam(..) | - ty::TyProjection(..) => { + ty::Bool | + ty::Char | + ty::Int(..) | + ty::Uint(..) | + ty::Float(..) | + ty::Str | + ty::FnDef(..) | + ty::FnPtr(_) | + ty::Array(..) | + ty::Slice(..) | + ty::RawPtr(..) | + ty::Ref(..) | + ty::Never | + ty::Tuple(..) | + ty::Param(..) | + ty::Projection(..) => { false } - ty::TyInfer(..) => match in_crate { + ty::Infer(..) => match in_crate { InCrate::Local => false, // The inference variable might be unified with a local // type in that remote crate. InCrate::Remote => true, }, - ty::TyAdt(def, _) => def_id_is_local(def.did, in_crate), - ty::TyForeign(did) => def_id_is_local(did, in_crate), + ty::Adt(def, _) => def_id_is_local(def.did, in_crate), + ty::Foreign(did) => def_id_is_local(did, in_crate), - ty::TyDynamic(ref tt, ..) => { + ty::Dynamic(ref tt, ..) => { tt.principal().map_or(false, |p| { def_id_is_local(p.def_id(), in_crate) }) } - ty::TyError => { + ty::Error => { true } - ty::TyClosure(..) | - ty::TyGenerator(..) | - ty::TyGeneratorWitness(..) | - ty::TyAnon(..) => { + ty::Closure(..) | + ty::Generator(..) | + ty::GeneratorWitness(..) | + ty::Anon(..) => { bug!("ty_is_local invoked on unexpected type: {:?}", ty) } } diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index fb09551704018..0aa15a4ae0c25 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -244,36 +244,36 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { /// if the type can be equated to any type. fn type_category<'tcx>(t: Ty<'tcx>) -> Option { match t.sty { - ty::TyBool => Some(0), - ty::TyChar => Some(1), - ty::TyStr => Some(2), - ty::TyInt(..) | ty::TyUint(..) | ty::TyInfer(ty::IntVar(..)) => Some(3), - ty::TyFloat(..) | ty::TyInfer(ty::FloatVar(..)) => Some(4), - ty::TyRef(..) | ty::TyRawPtr(..) => Some(5), - ty::TyArray(..) | ty::TySlice(..) => Some(6), - ty::TyFnDef(..) | ty::TyFnPtr(..) => Some(7), - ty::TyDynamic(..) => Some(8), - ty::TyClosure(..) => Some(9), - ty::TyTuple(..) => Some(10), - ty::TyProjection(..) => Some(11), - ty::TyParam(..) => Some(12), - ty::TyAnon(..) => Some(13), - ty::TyNever => Some(14), - ty::TyAdt(adt, ..) => match adt.adt_kind() { + ty::Bool => Some(0), + ty::Char => Some(1), + ty::Str => Some(2), + ty::Int(..) | ty::Uint(..) | ty::Infer(ty::IntVar(..)) => Some(3), + ty::Float(..) | ty::Infer(ty::FloatVar(..)) => Some(4), + ty::Ref(..) | ty::RawPtr(..) => Some(5), + ty::Array(..) | ty::Slice(..) => Some(6), + ty::FnDef(..) | ty::FnPtr(..) => Some(7), + ty::Dynamic(..) => Some(8), + ty::Closure(..) => Some(9), + ty::Tuple(..) => Some(10), + ty::Projection(..) => Some(11), + ty::Param(..) => Some(12), + ty::Anon(..) => Some(13), + ty::Never => Some(14), + ty::Adt(adt, ..) => match adt.adt_kind() { AdtKind::Struct => Some(15), AdtKind::Union => Some(16), AdtKind::Enum => Some(17), }, - ty::TyGenerator(..) => Some(18), - ty::TyForeign(..) => Some(19), - ty::TyGeneratorWitness(..) => Some(20), - ty::TyInfer(..) | ty::TyError => None + ty::Generator(..) => Some(18), + ty::Foreign(..) => Some(19), + ty::GeneratorWitness(..) => Some(20), + ty::Infer(..) | ty::Error => None } } match (type_category(a), type_category(b)) { (Some(cat_a), Some(cat_b)) => match (&a.sty, &b.sty) { - (&ty::TyAdt(def_a, _), &ty::TyAdt(def_b, _)) => def_a == def_b, + (&ty::Adt(def_a, _), &ty::Adt(def_b, _)) => def_a == def_b, _ => cat_a == cat_b }, // infer and error can be equated to all types @@ -784,10 +784,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { let found_trait_ty = found_trait_ref.self_ty(); let found_did = match found_trait_ty.sty { - ty::TyClosure(did, _) | - ty::TyForeign(did) | - ty::TyFnDef(did, _) => Some(did), - ty::TyAdt(def, _) => Some(def.did), + ty::Closure(did, _) | + ty::Foreign(did) | + ty::FnDef(did, _) => Some(did), + ty::Adt(def, _) => Some(def.did), _ => None, }; let found_span = found_did.and_then(|did| { @@ -795,14 +795,14 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { }).map(|sp| self.tcx.sess.source_map().def_span(sp)); // the sp could be an fn def let found = match found_trait_ref.skip_binder().substs.type_at(1).sty { - ty::TyTuple(ref tys) => tys.iter() + ty::Tuple(ref tys) => tys.iter() .map(|_| ArgKind::empty()).collect::>(), _ => vec![ArgKind::empty()], }; let expected = match expected_trait_ref.skip_binder().substs.type_at(1).sty { - ty::TyTuple(ref tys) => tys.iter() + ty::Tuple(ref tys) => tys.iter() .map(|t| match t.sty { - ty::TypeVariants::TyTuple(ref tys) => ArgKind::Tuple( + ty::Tuple(ref tys) => ArgKind::Tuple( Some(span), tys.iter() .map(|ty| ("_".to_owned(), ty.sty.to_string())) @@ -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::Ref(_, t_type, _) = trait_type.sty { trait_type = t_type; let substs = self.tcx.mk_substs_trait(trait_type, &[]); @@ -1143,7 +1143,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { fn build_fn_sig_string<'a, 'gcx, 'tcx>(tcx: ty::TyCtxt<'a, 'gcx, 'tcx>, trait_ref: &ty::TraitRef<'tcx>) -> String { let inputs = trait_ref.substs.type_at(1); - let sig = if let ty::TyTuple(inputs) = inputs.sty { + let sig = if let ty::Tuple(inputs) = inputs.sty { tcx.mk_fn_sig( inputs.iter().map(|&x| x), tcx.mk_infer(ty::TyVar(ty::TyVid { index: 0 })), @@ -1348,7 +1348,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'tcx> { self.infcx.tcx } fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { - if let ty::TyParam(ty::ParamTy {name, ..}) = ty.sty { + if let ty::Param(ty::ParamTy {name, ..}) = ty.sty { let infcx = self.infcx; self.var_map.entry(ty).or_insert_with(|| infcx.next_ty_var( @@ -1594,7 +1594,7 @@ impl ArgKind { /// argument. This has no name (`_`) and no source spans.. pub fn from_expected_ty(t: Ty<'_>) -> ArgKind { match t.sty { - ty::TyTuple(ref tys) => ArgKind::Tuple( + ty::Tuple(ref tys) => ArgKind::Tuple( None, tys.iter() .map(|ty| ("_".to_owned(), ty.sty.to_string())) diff --git a/src/librustc/traits/fulfill.rs b/src/librustc/traits/fulfill.rs index 5113f3cde3284..5c977e1bf624b 100644 --- a/src/librustc/traits/fulfill.rs +++ b/src/librustc/traits/fulfill.rs @@ -540,7 +540,7 @@ fn trait_ref_type_vars<'a, 'gcx, 'tcx>(selcx: &mut SelectionContext<'a, 'gcx, 't .map(|t| selcx.infcx().resolve_type_vars_if_possible(&t)) .filter(|t| t.has_infer_types()) .flat_map(|t| t.walk()) - .filter(|t| match t.sty { ty::TyInfer(_) => true, _ => false }) + .filter(|t| match t.sty { ty::Infer(_) => true, _ => false }) .collect() } diff --git a/src/librustc/traits/mod.rs b/src/librustc/traits/mod.rs index 0ba94b5275cb2..e2dbe88354060 100644 --- a/src/librustc/traits/mod.rs +++ b/src/librustc/traits/mod.rs @@ -24,7 +24,7 @@ use infer::outlives::env::OutlivesEnvironment; use middle::region; use mir::interpret::ConstEvalErr; use ty::subst::Substs; -use ty::{self, AdtKind, Slice, Ty, TyCtxt, GenericParamDefKind, ToPredicate}; +use ty::{self, AdtKind, List, Ty, TyCtxt, GenericParamDefKind, ToPredicate}; use ty::error::{ExpectedFound, TypeError}; use ty::fold::{TypeFolder, TypeFoldable, TypeVisitor}; use infer::{InferCtxt}; @@ -325,7 +325,7 @@ pub enum Goal<'tcx> { CannotProve, } -pub type Goals<'tcx> = &'tcx Slice>; +pub type Goals<'tcx> = &'tcx List>; impl<'tcx> DomainGoal<'tcx> { pub fn into_goal(self) -> Goal<'tcx> { @@ -357,7 +357,7 @@ pub enum Clause<'tcx> { } /// Multiple clauses. -pub type Clauses<'tcx> = &'tcx Slice>; +pub type Clauses<'tcx> = &'tcx List>; /// A "program clause" has the form `D :- G1, ..., Gn`. It is saying /// that the domain goal `D` is true if `G1...Gn` are provable. This diff --git a/src/librustc/traits/object_safety.rs b/src/librustc/traits/object_safety.rs index aa4f63675d734..17d55b77625b2 100644 --- a/src/librustc/traits/object_safety.rs +++ b/src/librustc/traits/object_safety.rs @@ -371,7 +371,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { let mut error = false; ty.maybe_walk(|ty| { match ty.sty { - ty::TyParam(ref param_ty) => { + ty::Param(ref param_ty) => { if param_ty.is_self() { error = true; } @@ -379,7 +379,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { false // no contained types to walk } - ty::TyProjection(ref data) => { + ty::Projection(ref data) => { // This is a projected type `::X`. // Compute supertraits of current trait lazily. diff --git a/src/librustc/traits/project.rs b/src/librustc/traits/project.rs index 1224cdd76d85b..939ba92c7badf 100644 --- a/src/librustc/traits/project.rs +++ b/src/librustc/traits/project.rs @@ -366,7 +366,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for AssociatedTypeNormalizer<'a, let ty = ty.super_fold_with(self); match ty.sty { - ty::TyAnon(def_id, substs) if !substs.has_escaping_regions() => { // (*) + ty::Anon(def_id, substs) if !substs.has_escaping_regions() => { // (*) // Only normalize `impl Trait` after type-checking, usually in codegen. match self.param_env.reveal { Reveal::UserFacing => ty, @@ -393,7 +393,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for AssociatedTypeNormalizer<'a, } } - ty::TyProjection(ref data) if !data.has_escaping_regions() => { // (*) + ty::Projection(ref data) if !data.has_escaping_regions() => { // (*) // (*) This is kind of hacky -- we need to be able to // handle normalization within binders because @@ -812,10 +812,10 @@ fn get_paranoid_cache_value_obligation<'a, 'gcx, 'tcx>( /// return an associated obligation that, when fulfilled, will lead to /// an error. /// -/// Note that we used to return `TyError` here, but that was quite +/// Note that we used to return `Error` here, but that was quite /// dubious -- the premise was that an error would *eventually* be /// reported, when the obligation was processed. But in general once -/// you see a `TyError` you are supposed to be able to assume that an +/// you see a `Error` you are supposed to be able to assume that an /// error *has been* reported, so that you can take whatever heuristic /// paths you want to take. To make things worse, it was possible for /// cycles to arise, where you basically had a setup like ` @@ -983,11 +983,11 @@ fn assemble_candidates_from_trait_def<'cx, 'gcx, 'tcx>( let tcx = selcx.tcx(); // Check whether the self-type is itself a projection. let (def_id, substs) = match obligation_trait_ref.self_ty().sty { - ty::TyProjection(ref data) => { + ty::Projection(ref data) => { (data.trait_ref(tcx).def_id, data.substs) } - ty::TyAnon(def_id, substs) => (def_id, substs), - ty::TyInfer(ty::TyVar(_)) => { + ty::Anon(def_id, substs) => (def_id, substs), + ty::Infer(ty::TyVar(_)) => { // If the self-type is an inference variable, then it MAY wind up // being a projected type, so induce an ambiguity. candidate_set.mark_ambiguous(); @@ -1265,7 +1265,7 @@ fn confirm_object_candidate<'cx, 'gcx, 'tcx>( debug!("confirm_object_candidate(object_ty={:?})", object_ty); let data = match object_ty.sty { - ty::TyDynamic(ref data, ..) => data, + ty::Dynamic(ref data, ..) => data, _ => { span_bug!( obligation.cause.span, @@ -1506,7 +1506,7 @@ fn confirm_impl_candidate<'cx, 'gcx, 'tcx>( // This means that the impl is missing a definition for the // associated type. This error will be reported by the type // checker method `check_impl_items_against_trait`, so here we - // just return TyError. + // just return Error. debug!("confirm_impl_candidate: no associated type {:?} for {:?}", assoc_ty.item.ident, obligation.predicate); diff --git a/src/librustc/traits/query/dropck_outlives.rs b/src/librustc/traits/query/dropck_outlives.rs index 3a1d50a6584ef..b479cafd1cea1 100644 --- a/src/librustc/traits/query/dropck_outlives.rs +++ b/src/librustc/traits/query/dropck_outlives.rs @@ -214,34 +214,34 @@ pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'_, '_, 'tcx>, ty: Ty<'tcx>) -> // None of these types have a destructor and hence they do not // require anything in particular to outlive the dtor's // execution. - ty::TyInfer(ty::FreshIntTy(_)) - | ty::TyInfer(ty::FreshFloatTy(_)) - | ty::TyBool - | ty::TyInt(_) - | ty::TyUint(_) - | ty::TyFloat(_) - | ty::TyNever - | ty::TyFnDef(..) - | ty::TyFnPtr(_) - | ty::TyChar - | ty::TyGeneratorWitness(..) - | ty::TyRawPtr(_) - | ty::TyRef(..) - | ty::TyStr - | ty::TyForeign(..) - | ty::TyError => true, + ty::Infer(ty::FreshIntTy(_)) + | ty::Infer(ty::FreshFloatTy(_)) + | ty::Bool + | ty::Int(_) + | ty::Uint(_) + | ty::Float(_) + | ty::Never + | ty::FnDef(..) + | ty::FnPtr(_) + | ty::Char + | ty::GeneratorWitness(..) + | ty::RawPtr(_) + | ty::Ref(..) + | ty::Str + | ty::Foreign(..) + | ty::Error => true, // [T; N] and [T] have same properties as T. - ty::TyArray(ty, _) | ty::TySlice(ty) => trivial_dropck_outlives(tcx, ty), + ty::Array(ty, _) | ty::Slice(ty) => trivial_dropck_outlives(tcx, ty), // (T1..Tn) and closures have same properties as T1..Tn -- // check if *any* of those are trivial. - ty::TyTuple(ref tys) => tys.iter().cloned().all(|t| trivial_dropck_outlives(tcx, t)), - ty::TyClosure(def_id, ref substs) => substs + ty::Tuple(ref tys) => tys.iter().cloned().all(|t| trivial_dropck_outlives(tcx, t)), + ty::Closure(def_id, ref substs) => substs .upvar_tys(def_id, tcx) .all(|t| trivial_dropck_outlives(tcx, t)), - ty::TyAdt(def, _) => { + ty::Adt(def, _) => { if Some(def.did) == tcx.lang_items().manually_drop() { // `ManuallyDrop` never has a dtor. true @@ -255,11 +255,11 @@ pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'_, '_, 'tcx>, ty: Ty<'tcx>) -> } // The following *might* require a destructor: it would deeper inspection to tell. - ty::TyDynamic(..) - | ty::TyProjection(..) - | ty::TyParam(_) - | ty::TyAnon(..) - | ty::TyInfer(_) - | ty::TyGenerator(..) => false, + ty::Dynamic(..) + | ty::Projection(..) + | ty::Param(_) + | ty::Anon(..) + | ty::Infer(_) + | ty::Generator(..) => false, } } diff --git a/src/librustc/traits/query/normalize.rs b/src/librustc/traits/query/normalize.rs index fab7289409c4f..7b81989c6415b 100644 --- a/src/librustc/traits/query/normalize.rs +++ b/src/librustc/traits/query/normalize.rs @@ -99,7 +99,7 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for QueryNormalizer<'cx, 'gcx, 'tcx fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { let ty = ty.super_fold_with(self); match ty.sty { - ty::TyAnon(def_id, substs) if !substs.has_escaping_regions() => { + ty::Anon(def_id, substs) if !substs.has_escaping_regions() => { // (*) // Only normalize `impl Trait` after type-checking, usually in codegen. match self.param_env.reveal { @@ -159,7 +159,7 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for QueryNormalizer<'cx, 'gcx, 'tcx } } - ty::TyProjection(ref data) if !data.has_escaping_regions() => { + ty::Projection(ref data) if !data.has_escaping_regions() => { // (*) // (*) This is kind of hacky -- we need to be able to // handle normalization within binders because diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs index ea96c30502680..dd383732bf827 100644 --- a/src/librustc/traits/select.rs +++ b/src/librustc/traits/select.rs @@ -1128,7 +1128,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { -> SelectionResult<'tcx, SelectionCandidate<'tcx>> { if stack.obligation.predicate.references_error() { - // If we encounter a `TyError`, we generally prefer the + // If we encounter a `Error`, we generally prefer the // most "optimistic" result in response -- that is, the // one least likely to report downstream errors. But // because this routine is shared by coherence and by @@ -1492,8 +1492,8 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { // before we go into the whole skolemization thing, just // quickly check if the self-type is a projection at all. match obligation.predicate.skip_binder().trait_ref.self_ty().sty { - ty::TyProjection(_) | ty::TyAnon(..) => {} - ty::TyInfer(ty::TyVar(_)) => { + ty::Projection(_) | ty::Anon(..) => {} + ty::Infer(ty::TyVar(_)) => { span_bug!(obligation.cause.span, "Self=_ should have been handled by assemble_candidates"); } @@ -1526,9 +1526,9 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { skol_map); let (def_id, substs) = match skol_trait_predicate.trait_ref.self_ty().sty { - ty::TyProjection(ref data) => + ty::Projection(ref data) => (data.trait_ref(self.tcx()).def_id, data.substs), - ty::TyAnon(def_id, substs) => (def_id, substs), + ty::Anon(def_id, substs) => (def_id, substs), _ => { span_bug!( obligation.cause.span, @@ -1661,7 +1661,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { // type/region parameters let self_ty = *obligation.self_ty().skip_binder(); match self_ty.sty { - ty::TyGenerator(..) => { + ty::Generator(..) => { debug!("assemble_generator_candidates: self_ty={:?} obligation={:?}", self_ty, obligation); @@ -1669,7 +1669,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { candidates.vec.push(GeneratorCandidate); Ok(()) } - ty::TyInfer(ty::TyVar(_)) => { + ty::Infer(ty::TyVar(_)) => { debug!("assemble_generator_candidates: ambiguous self-type"); candidates.ambiguous = true; return Ok(()); @@ -1698,7 +1698,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { // touch bound regions, they just capture the in-scope // type/region parameters match obligation.self_ty().skip_binder().sty { - ty::TyClosure(closure_def_id, closure_substs) => { + ty::Closure(closure_def_id, closure_substs) => { debug!("assemble_unboxed_candidates: kind={:?} obligation={:?}", kind, obligation); match self.infcx.closure_kind(closure_def_id, closure_substs) { @@ -1715,7 +1715,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { }; Ok(()) } - ty::TyInfer(ty::TyVar(_)) => { + ty::Infer(ty::TyVar(_)) => { debug!("assemble_unboxed_closure_candidates: ambiguous self-type"); candidates.ambiguous = true; return Ok(()); @@ -1738,13 +1738,13 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { // ok to skip binder because what we are inspecting doesn't involve bound regions let self_ty = *obligation.self_ty().skip_binder(); match self_ty.sty { - ty::TyInfer(ty::TyVar(_)) => { + ty::Infer(ty::TyVar(_)) => { debug!("assemble_fn_pointer_candidates: ambiguous self-type"); candidates.ambiguous = true; // could wind up being a fn() type } // provide an impl, but only for suitable `fn` pointers - ty::TyFnDef(..) | ty::TyFnPtr(_) => { + ty::FnDef(..) | ty::FnPtr(_) => { if let ty::FnSig { unsafety: hir::Unsafety::Normal, abi: Abi::Rust, @@ -1804,20 +1804,20 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { if self.tcx().trait_is_auto(def_id) { match self_ty.sty { - ty::TyDynamic(..) => { + ty::Dynamic(..) => { // For object types, we don't know what the closed // over types are. This means we conservatively // say nothing; a candidate may be added by // `assemble_candidates_from_object_ty`. } - ty::TyForeign(..) => { + ty::Foreign(..) => { // Since the contents of foreign types is unknown, // we don't add any `..` impl. Default traits could // still be provided by a manual implementation for // this trait and type. } - ty::TyParam(..) | - ty::TyProjection(..) => { + ty::Param(..) | + ty::Projection(..) => { // In these cases, we don't know what the actual // type is. Therefore, we cannot break it down // into its constituent types. So we don't @@ -1832,7 +1832,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { // for an example of a test case that exercises // this path. } - ty::TyInfer(ty::TyVar(_)) => { + ty::Infer(ty::TyVar(_)) => { // the auto impl might apply, we don't know candidates.ambiguous = true; } @@ -1871,7 +1871,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { // any LBR. let self_ty = this.tcx().erase_late_bound_regions(&obligation.self_ty()); let poly_trait_ref = match self_ty.sty { - ty::TyDynamic(ref data, ..) => { + ty::Dynamic(ref data, ..) => { if data.auto_traits().any(|did| did == obligation.predicate.def_id()) { debug!("assemble_candidates_from_object_ty: matched builtin bound, \ pushing candidate"); @@ -1884,7 +1884,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { None => return, } } - ty::TyInfer(ty::TyVar(_)) => { + ty::Infer(ty::TyVar(_)) => { debug!("assemble_candidates_from_object_ty: ambiguous"); candidates.ambiguous = true; // could wind up being an object type return; @@ -1953,7 +1953,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { let may_apply = match (&source.sty, &target.sty) { // Trait+Kx+'a -> Trait+Ky+'b (upcasts). - (&ty::TyDynamic(ref data_a, ..), &ty::TyDynamic(ref data_b, ..)) => { + (&ty::Dynamic(ref data_a, ..), &ty::Dynamic(ref data_b, ..)) => { // Upcasts permit two things: // // 1. Dropping builtin bounds, e.g. `Foo+Send` to `Foo` @@ -1975,28 +1975,28 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { } // T -> Trait. - (_, &ty::TyDynamic(..)) => true, + (_, &ty::Dynamic(..)) => true, // Ambiguous handling is below T -> Trait, because inference // variables can still implement Unsize and nested // obligations will have the final say (likely deferred). - (&ty::TyInfer(ty::TyVar(_)), _) | - (_, &ty::TyInfer(ty::TyVar(_))) => { + (&ty::Infer(ty::TyVar(_)), _) | + (_, &ty::Infer(ty::TyVar(_))) => { debug!("assemble_candidates_for_unsizing: ambiguous"); candidates.ambiguous = true; false } // [T; n] -> [T]. - (&ty::TyArray(..), &ty::TySlice(_)) => true, + (&ty::Array(..), &ty::Slice(_)) => true, // Struct -> Struct. - (&ty::TyAdt(def_id_a, _), &ty::TyAdt(def_id_b, _)) if def_id_a.is_struct() => { + (&ty::Adt(def_id_a, _), &ty::Adt(def_id_b, _)) if def_id_a.is_struct() => { def_id_a == def_id_b } // (.., T) -> (.., U). - (&ty::TyTuple(tys_a), &ty::TyTuple(tys_b)) => { + (&ty::Tuple(tys_a), &ty::Tuple(tys_b)) => { tys_a.len() == tys_b.len() } @@ -2179,23 +2179,23 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { obligation.predicate.skip_binder().self_ty()); match self_ty.sty { - ty::TyInfer(ty::IntVar(_)) | ty::TyInfer(ty::FloatVar(_)) | - ty::TyUint(_) | ty::TyInt(_) | ty::TyBool | ty::TyFloat(_) | - ty::TyFnDef(..) | ty::TyFnPtr(_) | ty::TyRawPtr(..) | - ty::TyChar | ty::TyRef(..) | ty::TyGenerator(..) | - ty::TyGeneratorWitness(..) | ty::TyArray(..) | ty::TyClosure(..) | - ty::TyNever | ty::TyError => { + ty::Infer(ty::IntVar(_)) | ty::Infer(ty::FloatVar(_)) | + ty::Uint(_) | ty::Int(_) | ty::Bool | ty::Float(_) | + ty::FnDef(..) | ty::FnPtr(_) | ty::RawPtr(..) | + ty::Char | ty::Ref(..) | ty::Generator(..) | + ty::GeneratorWitness(..) | ty::Array(..) | ty::Closure(..) | + ty::Never | ty::Error => { // safe for everything Where(ty::Binder::dummy(Vec::new())) } - ty::TyStr | ty::TySlice(_) | ty::TyDynamic(..) | ty::TyForeign(..) => None, + ty::Str | ty::Slice(_) | ty::Dynamic(..) | ty::Foreign(..) => None, - ty::TyTuple(tys) => { + ty::Tuple(tys) => { Where(ty::Binder::bind(tys.last().into_iter().cloned().collect())) } - ty::TyAdt(def, substs) => { + ty::Adt(def, substs) => { let sized_crit = def.sized_constraint(self.tcx()); // (*) binder moved here Where(ty::Binder::bind( @@ -2203,13 +2203,13 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { )) } - ty::TyProjection(_) | ty::TyParam(_) | ty::TyAnon(..) => None, - ty::TyInfer(ty::TyVar(_)) => Ambiguous, + ty::Projection(_) | ty::Param(_) | ty::Anon(..) => None, + ty::Infer(ty::TyVar(_)) => Ambiguous, - ty::TyInfer(ty::CanonicalTy(_)) | - ty::TyInfer(ty::FreshTy(_)) | - ty::TyInfer(ty::FreshIntTy(_)) | - ty::TyInfer(ty::FreshFloatTy(_)) => { + ty::Infer(ty::CanonicalTy(_)) | + ty::Infer(ty::FreshTy(_)) | + ty::Infer(ty::FreshIntTy(_)) | + ty::Infer(ty::FreshFloatTy(_)) => { bug!("asked to assemble builtin bounds of unexpected type: {:?}", self_ty); } @@ -2226,35 +2226,35 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { use self::BuiltinImplConditions::{Ambiguous, None, Where}; match self_ty.sty { - ty::TyInfer(ty::IntVar(_)) | ty::TyInfer(ty::FloatVar(_)) | - ty::TyFnDef(..) | ty::TyFnPtr(_) | ty::TyError => { + ty::Infer(ty::IntVar(_)) | ty::Infer(ty::FloatVar(_)) | + ty::FnDef(..) | ty::FnPtr(_) | ty::Error => { Where(ty::Binder::dummy(Vec::new())) } - ty::TyUint(_) | ty::TyInt(_) | ty::TyBool | ty::TyFloat(_) | - ty::TyChar | ty::TyRawPtr(..) | ty::TyNever | - ty::TyRef(_, _, hir::MutImmutable) => { + ty::Uint(_) | ty::Int(_) | ty::Bool | ty::Float(_) | + ty::Char | ty::RawPtr(..) | ty::Never | + ty::Ref(_, _, hir::MutImmutable) => { // Implementations provided in libcore None } - ty::TyDynamic(..) | ty::TyStr | ty::TySlice(..) | - ty::TyGenerator(..) | ty::TyGeneratorWitness(..) | ty::TyForeign(..) | - ty::TyRef(_, _, hir::MutMutable) => { + ty::Dynamic(..) | ty::Str | ty::Slice(..) | + ty::Generator(..) | ty::GeneratorWitness(..) | ty::Foreign(..) | + ty::Ref(_, _, hir::MutMutable) => { None } - ty::TyArray(element_ty, _) => { + ty::Array(element_ty, _) => { // (*) binder moved here Where(ty::Binder::bind(vec![element_ty])) } - ty::TyTuple(tys) => { + ty::Tuple(tys) => { // (*) binder moved here Where(ty::Binder::bind(tys.to_vec())) } - ty::TyClosure(def_id, substs) => { + ty::Closure(def_id, substs) => { let trait_id = obligation.predicate.def_id(); let is_copy_trait = Some(trait_id) == self.tcx().lang_items().copy_trait(); let is_clone_trait = Some(trait_id) == self.tcx().lang_items().clone_trait(); @@ -2265,22 +2265,22 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { } } - ty::TyAdt(..) | ty::TyProjection(..) | ty::TyParam(..) | ty::TyAnon(..) => { + ty::Adt(..) | ty::Projection(..) | ty::Param(..) | ty::Anon(..) => { // Fallback to whatever user-defined impls exist in this case. None } - ty::TyInfer(ty::TyVar(_)) => { + ty::Infer(ty::TyVar(_)) => { // Unbound type variable. Might or might not have // applicable impls and so forth, depending on what // those type variables wind up being bound to. Ambiguous } - ty::TyInfer(ty::CanonicalTy(_)) | - ty::TyInfer(ty::FreshTy(_)) | - ty::TyInfer(ty::FreshIntTy(_)) | - ty::TyInfer(ty::FreshFloatTy(_)) => { + ty::Infer(ty::CanonicalTy(_)) | + ty::Infer(ty::FreshTy(_)) | + ty::Infer(ty::FreshIntTy(_)) | + ty::Infer(ty::FreshFloatTy(_)) => { bug!("asked to assemble builtin bounds of unexpected type: {:?}", self_ty); } @@ -2300,58 +2300,58 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { /// ``` fn constituent_types_for_ty(&self, t: Ty<'tcx>) -> Vec> { match t.sty { - ty::TyUint(_) | - ty::TyInt(_) | - ty::TyBool | - ty::TyFloat(_) | - ty::TyFnDef(..) | - ty::TyFnPtr(_) | - ty::TyStr | - ty::TyError | - ty::TyInfer(ty::IntVar(_)) | - ty::TyInfer(ty::FloatVar(_)) | - ty::TyNever | - ty::TyChar => { + ty::Uint(_) | + ty::Int(_) | + ty::Bool | + ty::Float(_) | + ty::FnDef(..) | + ty::FnPtr(_) | + ty::Str | + ty::Error | + ty::Infer(ty::IntVar(_)) | + ty::Infer(ty::FloatVar(_)) | + ty::Never | + ty::Char => { Vec::new() } - ty::TyDynamic(..) | - ty::TyParam(..) | - ty::TyForeign(..) | - ty::TyProjection(..) | - ty::TyInfer(ty::CanonicalTy(_)) | - ty::TyInfer(ty::TyVar(_)) | - ty::TyInfer(ty::FreshTy(_)) | - ty::TyInfer(ty::FreshIntTy(_)) | - ty::TyInfer(ty::FreshFloatTy(_)) => { + ty::Dynamic(..) | + ty::Param(..) | + ty::Foreign(..) | + ty::Projection(..) | + ty::Infer(ty::CanonicalTy(_)) | + ty::Infer(ty::TyVar(_)) | + ty::Infer(ty::FreshTy(_)) | + ty::Infer(ty::FreshIntTy(_)) | + ty::Infer(ty::FreshFloatTy(_)) => { bug!("asked to assemble constituent types of unexpected type: {:?}", t); } - ty::TyRawPtr(ty::TypeAndMut { ty: element_ty, ..}) | - ty::TyRef(_, element_ty, _) => { + ty::RawPtr(ty::TypeAndMut { ty: element_ty, ..}) | + ty::Ref(_, element_ty, _) => { vec![element_ty] }, - ty::TyArray(element_ty, _) | ty::TySlice(element_ty) => { + ty::Array(element_ty, _) | ty::Slice(element_ty) => { vec![element_ty] } - ty::TyTuple(ref tys) => { + ty::Tuple(ref tys) => { // (T1, ..., Tn) -- meets any bound that all of T1...Tn meet tys.to_vec() } - ty::TyClosure(def_id, ref substs) => { + ty::Closure(def_id, ref substs) => { substs.upvar_tys(def_id, self.tcx()).collect() } - ty::TyGenerator(def_id, ref substs, _) => { + ty::Generator(def_id, ref substs, _) => { let witness = substs.witness(def_id, self.tcx()); substs.upvar_tys(def_id, self.tcx()).chain(iter::once(witness)).collect() } - ty::TyGeneratorWitness(types) => { + ty::GeneratorWitness(types) => { // This is sound because no regions in the witness can refer to // the binder outside the witness. So we'll effectivly reuse // the implicit binder around the witness. @@ -2359,17 +2359,17 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { } // for `PhantomData`, we pass `T` - ty::TyAdt(def, substs) if def.is_phantom_data() => { + ty::Adt(def, substs) if def.is_phantom_data() => { substs.types().collect() } - ty::TyAdt(def, substs) => { + ty::Adt(def, substs) => { def.all_fields() .map(|f| f.ty(self.tcx(), substs)) .collect() } - ty::TyAnon(def_id, substs) => { + ty::Anon(def_id, substs) => { // We can resolve the `impl Trait` to its concrete type, // which enforces a DAG between the functions requiring // the auto trait bounds in question. @@ -2728,7 +2728,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { // case that results. -nmatsakis let self_ty = self.infcx.shallow_resolve(*obligation.self_ty().skip_binder()); let poly_trait_ref = match self_ty.sty { - ty::TyDynamic(ref data, ..) => { + ty::Dynamic(ref data, ..) => { data.principal().unwrap().with_self_ty(self.tcx(), self_ty) } _ => { @@ -2823,7 +2823,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { // type/region parameters let self_ty = self.infcx.shallow_resolve(obligation.self_ty().skip_binder()); let (generator_def_id, substs) = match self_ty.sty { - ty::TyGenerator(id, substs, _) => (id, substs), + ty::Generator(id, substs, _) => (id, substs), _ => bug!("closure candidate for non-closure {:?}", obligation) }; @@ -2879,7 +2879,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { // type/region parameters let self_ty = self.infcx.shallow_resolve(obligation.self_ty().skip_binder()); let (closure_def_id, substs) = match self_ty.sty { - ty::TyClosure(id, substs) => (id, substs), + ty::Closure(id, substs) => (id, substs), _ => bug!("closure candidate for non-closure {:?}", obligation) }; @@ -2976,7 +2976,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { let mut nested = vec![]; match (&source.sty, &target.sty) { // Trait+Kx+'a -> Trait+Ky+'b (upcasts). - (&ty::TyDynamic(ref data_a, r_a), &ty::TyDynamic(ref data_b, r_b)) => { + (&ty::Dynamic(ref data_a, r_a), &ty::Dynamic(ref data_b, r_b)) => { // See assemble_candidates_for_unsizing for more info. let existential_predicates = data_a.map_bound(|data_a| { let principal = data_a.principal(); @@ -3005,7 +3005,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { } // T -> Trait. - (_, &ty::TyDynamic(ref data, r)) => { + (_, &ty::Dynamic(ref data, r)) => { let mut object_dids = data.auto_traits().chain(data.principal().map(|p| p.def_id())); if let Some(did) = object_dids.find(|did| { @@ -3048,7 +3048,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { } // [T; n] -> [T]. - (&ty::TyArray(a, _), &ty::TySlice(b)) => { + (&ty::Array(a, _), &ty::Slice(b)) => { let InferOk { obligations, .. } = self.infcx.at(&obligation.cause, obligation.param_env) .eq(b, a) @@ -3057,7 +3057,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { } // Struct -> Struct. - (&ty::TyAdt(def, substs_a), &ty::TyAdt(_, substs_b)) => { + (&ty::Adt(def, substs_a), &ty::Adt(_, substs_b)) => { let fields = def .all_fields() .map(|f| tcx.type_of(f.did)) @@ -3072,7 +3072,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { let mut ty_params = BitArray::new(substs_a.types().count()); let mut found = false; for ty in field.walk() { - if let ty::TyParam(p) = ty.sty { + if let ty::Param(p) = ty.sty { ty_params.insert(p.idx as usize); found = true; } @@ -3082,7 +3082,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { } // Replace type parameters used in unsizing with - // TyError and ensure they do not affect any other fields. + // Error and ensure they do not affect any other fields. // This could be checked after type collection for any struct // with a potentially unsized trailing field. let params = substs_a.iter().enumerate().map(|(i, &k)| { @@ -3130,7 +3130,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { } // (.., T) -> (.., U). - (&ty::TyTuple(tys_a), &ty::TyTuple(tys_b)) => { + (&ty::Tuple(tys_a), &ty::Tuple(tys_b)) => { assert_eq!(tys_a.len(), tys_b.len()); // The last field of the tuple has to exist. diff --git a/src/librustc/traits/specialize/mod.rs b/src/librustc/traits/specialize/mod.rs index caebcbec3903e..9343eff9e79b4 100644 --- a/src/librustc/traits/specialize/mod.rs +++ b/src/librustc/traits/specialize/mod.rs @@ -90,7 +90,7 @@ pub fn translate_substs<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>, .unwrap() .subst(infcx.tcx, &source_substs); - // translate the Self and TyParam parts of the substitution, since those + // translate the Self and Param parts of the substitution, since those // vary across impls let target_substs = match target_node { specialization_graph::Node::Impl(target_impl) => { diff --git a/src/librustc/traits/structural_impls.rs b/src/librustc/traits/structural_impls.rs index 9292b42eb525e..87535a6ae8d14 100644 --- a/src/librustc/traits/structural_impls.rs +++ b/src/librustc/traits/structural_impls.rs @@ -620,7 +620,7 @@ EnumLiftImpl! { } } -impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::Slice> { +impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List> { fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { let v = self.iter() .map(|t| t.fold_with(folder)) @@ -658,7 +658,7 @@ EnumTypeFoldableImpl! { } } -impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::Slice> { +impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List> { fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { let v = self.iter() .map(|t| t.fold_with(folder)) diff --git a/src/librustc/ty/_match.rs b/src/librustc/ty/_match.rs index 047bfcc8c6f59..c9b0e97c9b05c 100644 --- a/src/librustc/ty/_match.rs +++ b/src/librustc/ty/_match.rs @@ -67,18 +67,18 @@ impl<'a, 'gcx, 'tcx> TypeRelation<'a, 'gcx, 'tcx> for Match<'a, 'gcx, 'tcx> { if a == b { return Ok(a); } match (&a.sty, &b.sty) { - (_, &ty::TyInfer(ty::FreshTy(_))) | - (_, &ty::TyInfer(ty::FreshIntTy(_))) | - (_, &ty::TyInfer(ty::FreshFloatTy(_))) => { + (_, &ty::Infer(ty::FreshTy(_))) | + (_, &ty::Infer(ty::FreshIntTy(_))) | + (_, &ty::Infer(ty::FreshFloatTy(_))) => { Ok(a) } - (&ty::TyInfer(_), _) | - (_, &ty::TyInfer(_)) => { + (&ty::Infer(_), _) | + (_, &ty::Infer(_)) => { Err(TypeError::Sorts(relate::expected_found(self, &a, &b))) } - (&ty::TyError, _) | (_, &ty::TyError) => { + (&ty::Error, _) | (_, &ty::Error) => { Ok(self.tcx().types.err) } diff --git a/src/librustc/ty/cast.rs b/src/librustc/ty/cast.rs index 7593d4ed24e76..c0861abb774de 100644 --- a/src/librustc/ty/cast.rs +++ b/src/librustc/ty/cast.rs @@ -60,18 +60,18 @@ pub enum CastKind { impl<'tcx> CastTy<'tcx> { pub fn from_ty(t: Ty<'tcx>) -> Option> { match t.sty { - ty::TyBool => Some(CastTy::Int(IntTy::Bool)), - ty::TyChar => Some(CastTy::Int(IntTy::Char)), - ty::TyInt(_) => Some(CastTy::Int(IntTy::I)), - ty::TyInfer(ty::InferTy::IntVar(_)) => Some(CastTy::Int(IntTy::I)), - ty::TyInfer(ty::InferTy::FloatVar(_)) => Some(CastTy::Float), - ty::TyUint(u) => Some(CastTy::Int(IntTy::U(u))), - ty::TyFloat(_) => Some(CastTy::Float), - ty::TyAdt(d,_) if d.is_enum() && d.is_payloadfree() => + ty::Bool => Some(CastTy::Int(IntTy::Bool)), + ty::Char => Some(CastTy::Int(IntTy::Char)), + ty::Int(_) => Some(CastTy::Int(IntTy::I)), + ty::Infer(ty::InferTy::IntVar(_)) => Some(CastTy::Int(IntTy::I)), + ty::Infer(ty::InferTy::FloatVar(_)) => Some(CastTy::Float), + ty::Uint(u) => Some(CastTy::Int(IntTy::U(u))), + ty::Float(_) => Some(CastTy::Float), + ty::Adt(d,_) if d.is_enum() && d.is_payloadfree() => Some(CastTy::Int(IntTy::CEnum)), - ty::TyRawPtr(mt) => Some(CastTy::Ptr(mt)), - ty::TyRef(_, ty, mutbl) => Some(CastTy::RPtr(ty::TypeAndMut { ty, mutbl })), - ty::TyFnPtr(..) => Some(CastTy::FnPtr), + ty::RawPtr(mt) => Some(CastTy::Ptr(mt)), + ty::Ref(_, ty, mutbl) => Some(CastTy::RPtr(ty::TypeAndMut { ty, mutbl })), + ty::FnPtr(..) => Some(CastTy::FnPtr), _ => None, } } diff --git a/src/librustc/ty/codec.rs b/src/librustc/ty/codec.rs index 967a3324cfb2a..cc3e8a458a01f 100644 --- a/src/librustc/ty/codec.rs +++ b/src/librustc/ty/codec.rs @@ -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 } @@ -164,7 +164,7 @@ pub fn decode_ty<'a, 'tcx, D>(decoder: &mut D) -> Result, D::Error> }) } else { let tcx = decoder.tcx(); - Ok(tcx.mk_ty(ty::TypeVariants::decode(decoder)?)) + Ok(tcx.mk_ty(ty::TyKind::decode(decoder)?)) } } @@ -212,7 +212,7 @@ pub fn decode_region<'a, 'tcx, D>(decoder: &mut D) -> Result, D #[inline] pub fn decode_ty_slice<'a, 'tcx, D>(decoder: &mut D) - -> Result<&'tcx ty::Slice>, D::Error> + -> Result<&'tcx ty::List>, D::Error> where D: TyDecoder<'a, 'tcx>, 'tcx: 'a, { @@ -232,7 +232,7 @@ pub fn decode_adt_def<'a, 'tcx, D>(decoder: &mut D) #[inline] pub fn decode_existential_predicate_slice<'a, 'tcx, D>(decoder: &mut D) - -> Result<&'tcx ty::Slice>, D::Error> + -> Result<&'tcx ty::List>, D::Error> where D: TyDecoder<'a, 'tcx>, 'tcx: 'a, { @@ -366,10 +366,10 @@ macro_rules! implement_ty_decoder { } } - impl<$($typaram),*> SpecializedDecoder<&'tcx ty::Slice>> + impl<$($typaram),*> SpecializedDecoder<&'tcx ty::List>> for $DecoderName<$($typaram),*> { fn specialized_decode(&mut self) - -> Result<&'tcx ty::Slice>, Self::Error> { + -> Result<&'tcx ty::List>, Self::Error> { decode_ty_slice(self) } } @@ -381,10 +381,10 @@ macro_rules! implement_ty_decoder { } } - impl<$($typaram),*> SpecializedDecoder<&'tcx ty::Slice>> + impl<$($typaram),*> SpecializedDecoder<&'tcx ty::List>> for $DecoderName<$($typaram),*> { fn specialized_decode(&mut self) - -> Result<&'tcx ty::Slice>, Self::Error> { + -> Result<&'tcx ty::List>, Self::Error> { decode_existential_predicate_slice(self) } } diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index ee0543f53ba69..0545a88f36bdc 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -38,12 +38,12 @@ use ty::ReprOptions; use traits; use traits::{Clause, Clauses, Goal, Goals}; use ty::{self, Ty, TypeAndMut}; -use ty::{TyS, TypeVariants, Slice}; +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; @@ -135,15 +135,15 @@ pub struct CtxtInterners<'tcx> { /// Specifically use a speedy hash algorithm for these hash sets, /// they're accessed quite often. type_: InternedSet<'tcx, TyS<'tcx>>, - type_list: InternedSet<'tcx, Slice>>, + type_list: InternedSet<'tcx, List>>, substs: InternedSet<'tcx, Substs<'tcx>>, - canonical_var_infos: InternedSet<'tcx, Slice>, + canonical_var_infos: InternedSet<'tcx, List>, region: InternedSet<'tcx, RegionKind>, - existential_predicates: InternedSet<'tcx, Slice>>, - predicates: InternedSet<'tcx, Slice>>, + existential_predicates: InternedSet<'tcx, List>>, + predicates: InternedSet<'tcx, List>>, const_: InternedSet<'tcx, Const<'tcx>>, - clauses: InternedSet<'tcx, Slice>>, - goals: InternedSet<'tcx, Slice>>, + clauses: InternedSet<'tcx, List>>, + goals: InternedSet<'tcx, List>>, } impl<'gcx: 'tcx, 'tcx> CtxtInterners<'tcx> { @@ -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); @@ -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::() <= 24); + assert!(mem::size_of::() <= 24); #[cfg(target_pointer_width = "64")] assert!(mem::size_of::() <= 32); @@ -817,24 +817,24 @@ impl<'tcx> CommonTypes<'tcx> { &*r }; CommonTypes { - bool: mk(TyBool), - char: mk(TyChar), - never: mk(TyNever), - err: mk(TyError), - isize: mk(TyInt(ast::IntTy::Isize)), - i8: mk(TyInt(ast::IntTy::I8)), - i16: mk(TyInt(ast::IntTy::I16)), - i32: mk(TyInt(ast::IntTy::I32)), - i64: mk(TyInt(ast::IntTy::I64)), - i128: mk(TyInt(ast::IntTy::I128)), - usize: mk(TyUint(ast::UintTy::Usize)), - u8: mk(TyUint(ast::UintTy::U8)), - u16: mk(TyUint(ast::UintTy::U16)), - u32: mk(TyUint(ast::UintTy::U32)), - u64: mk(TyUint(ast::UintTy::U64)), - u128: mk(TyUint(ast::UintTy::U128)), - f32: mk(TyFloat(ast::FloatTy::F32)), - f64: mk(TyFloat(ast::FloatTy::F64)), + bool: mk(Bool), + char: mk(Char), + never: mk(Never), + err: mk(Error), + isize: mk(Int(ast::IntTy::Isize)), + i8: mk(Int(ast::IntTy::I8)), + i16: mk(Int(ast::IntTy::I16)), + i32: mk(Int(ast::IntTy::I32)), + i64: mk(Int(ast::IntTy::I64)), + i128: mk(Int(ast::IntTy::I128)), + usize: mk(Uint(ast::UintTy::Usize)), + u8: mk(Uint(ast::UintTy::U8)), + u16: mk(Uint(ast::UintTy::U16)), + u32: mk(Uint(ast::UintTy::U32)), + u64: mk(Uint(ast::UintTy::U64)), + u128: mk(Uint(ast::UintTy::U128)), + f32: mk(Float(ast::FloatTy::F32)), + f64: mk(Float(ast::FloatTy::F64)), re_empty: mk_region(RegionKind::ReEmpty), re_static: mk_region(RegionKind::ReStatic), @@ -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 { @@ -1593,12 +1593,12 @@ impl<'a, 'tcx> Lift<'tcx> for &'a Goal<'a> { } } -impl<'a, 'tcx> Lift<'tcx> for &'a Slice> { - type Lifted = &'tcx Slice>; +impl<'a, 'tcx> Lift<'tcx> for &'a List> { + type Lifted = &'tcx List>; fn lift_to_tcx<'b, 'gcx>( &self, tcx: TyCtxt<'b, 'gcx, 'tcx>, - ) -> Option<&'tcx Slice>> { + ) -> Option<&'tcx List>> { if tcx.interners.arena.in_arena(*self as *const _) { return Some(unsafe { mem::transmute(*self) }); } @@ -1611,12 +1611,12 @@ impl<'a, 'tcx> Lift<'tcx> for &'a Slice> { } } -impl<'a, 'tcx> Lift<'tcx> for &'a Slice> { - type Lifted = &'tcx Slice>; +impl<'a, 'tcx> Lift<'tcx> for &'a List> { + type Lifted = &'tcx List>; fn lift_to_tcx<'b, 'gcx>( &self, tcx: TyCtxt<'b, 'gcx, 'tcx>, - ) -> Option<&'tcx Slice>> { + ) -> Option<&'tcx List>> { if tcx.interners.arena.in_arena(*self as *const _) { return Some(unsafe { mem::transmute(*self) }); } @@ -1648,7 +1648,7 @@ impl<'a, 'tcx> Lift<'tcx> for &'a Substs<'a> { type Lifted = &'tcx Substs<'tcx>; fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<&'tcx Substs<'tcx>> { if self.len() == 0 { - return Some(Slice::empty()); + return Some(List::empty()); } if tcx.interners.arena.in_arena(&self[..] as *const _) { return Some(unsafe { mem::transmute(*self) }); @@ -1662,12 +1662,12 @@ impl<'a, 'tcx> Lift<'tcx> for &'a Substs<'a> { } } -impl<'a, 'tcx> Lift<'tcx> for &'a Slice> { - type Lifted = &'tcx Slice>; +impl<'a, 'tcx> Lift<'tcx> for &'a List> { + type Lifted = &'tcx List>; fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) - -> Option<&'tcx Slice>> { + -> Option<&'tcx List>> { if self.len() == 0 { - return Some(Slice::empty()); + return Some(List::empty()); } if tcx.interners.arena.in_arena(*self as *const _) { return Some(unsafe { mem::transmute(*self) }); @@ -1681,12 +1681,12 @@ impl<'a, 'tcx> Lift<'tcx> for &'a Slice> { } } -impl<'a, 'tcx> Lift<'tcx> for &'a Slice> { - type Lifted = &'tcx Slice>; +impl<'a, 'tcx> Lift<'tcx> for &'a List> { + type Lifted = &'tcx List>; fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) - -> Option<&'tcx Slice>> { + -> Option<&'tcx List>> { if self.is_empty() { - return Some(Slice::empty()); + return Some(List::empty()); } if tcx.interners.arena.in_arena(*self as *const _) { return Some(unsafe { mem::transmute(*self) }); @@ -1700,12 +1700,12 @@ impl<'a, 'tcx> Lift<'tcx> for &'a Slice> { } } -impl<'a, 'tcx> Lift<'tcx> for &'a Slice> { - type Lifted = &'tcx Slice>; +impl<'a, 'tcx> Lift<'tcx> for &'a List> { + type Lifted = &'tcx List>; fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) - -> Option<&'tcx Slice>> { + -> Option<&'tcx List>> { if self.is_empty() { - return Some(Slice::empty()); + return Some(List::empty()); } if tcx.interners.arena.in_arena(*self as *const _) { return Some(unsafe { mem::transmute(*self) }); @@ -1719,11 +1719,11 @@ impl<'a, 'tcx> Lift<'tcx> for &'a Slice> { } } -impl<'a, 'tcx> Lift<'tcx> for &'a Slice { - type Lifted = &'tcx Slice; +impl<'a, 'tcx> Lift<'tcx> for &'a List { + type Lifted = &'tcx List; fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option { if self.len() == 0 { - return Some(Slice::empty()); + return Some(List::empty()); } if tcx.interners.arena.in_arena(*self as *const _) { return Some(unsafe { mem::transmute(*self) }); @@ -2035,9 +2035,9 @@ macro_rules! sty_debug_print { for &Interned(t) in tcx.interners.type_.borrow().iter() { let variant = match t.sty { - ty::TyBool | ty::TyChar | ty::TyInt(..) | ty::TyUint(..) | - ty::TyFloat(..) | ty::TyStr | ty::TyNever => continue, - ty::TyError => /* unimportant */ continue, + ty::Bool | ty::Char | ty::Int(..) | ty::Uint(..) | + ty::Float(..) | ty::Str | ty::Never => continue, + ty::Error => /* unimportant */ continue, $(ty::$variant(..) => &mut $variant,)* }; let region = t.flags.intersects(ty::TypeFlags::HAS_RE_INFER); @@ -2076,9 +2076,9 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { pub fn print_debug_stats(self) { sty_debug_print!( self, - TyAdt, TyArray, TySlice, TyRawPtr, TyRef, TyFnDef, TyFnPtr, - TyGenerator, TyGeneratorWitness, TyDynamic, TyClosure, TyTuple, - TyParam, TyInfer, TyProjection, TyAnon, TyForeign); + Adt, Array, Slice, RawPtr, Ref, FnDef, FnPtr, + Generator, GeneratorWitness, Dynamic, Closure, Tuple, + Param, Infer, Projection, Anon, Foreign); println!("Substs interner: #{}", self.interners.substs.borrow().len()); println!("Region interner: #{}", self.interners.region.borrow().len()); @@ -2107,34 +2107,34 @@ impl<'tcx> Hash for Interned<'tcx, TyS<'tcx>> { } } -impl<'tcx: 'lcx, 'lcx> Borrow> for Interned<'tcx, TyS<'tcx>> { - fn borrow<'a>(&'a self) -> &'a TypeVariants<'lcx> { +impl<'tcx: 'lcx, 'lcx> Borrow> for Interned<'tcx, TyS<'tcx>> { + fn borrow<'a>(&'a self) -> &'a TyKind<'lcx> { &self.0.sty } } -// NB: An Interned> compares and hashes as its elements. -impl<'tcx, T: PartialEq> PartialEq for Interned<'tcx, Slice> { - fn eq(&self, other: &Interned<'tcx, Slice>) -> bool { +// NB: An Interned> compares and hashes as its elements. +impl<'tcx, T: PartialEq> PartialEq for Interned<'tcx, List> { + fn eq(&self, other: &Interned<'tcx, List>) -> bool { self.0[..] == other.0[..] } } -impl<'tcx, T: Eq> Eq for Interned<'tcx, Slice> {} +impl<'tcx, T: Eq> Eq for Interned<'tcx, List> {} -impl<'tcx, T: Hash> Hash for Interned<'tcx, Slice> { +impl<'tcx, T: Hash> Hash for Interned<'tcx, List> { fn hash(&self, s: &mut H) { self.0[..].hash(s) } } -impl<'tcx: 'lcx, 'lcx> Borrow<[Ty<'lcx>]> for Interned<'tcx, Slice>> { +impl<'tcx: 'lcx, 'lcx> Borrow<[Ty<'lcx>]> for Interned<'tcx, List>> { fn borrow<'a>(&'a self) -> &'a [Ty<'lcx>] { &self.0[..] } } -impl<'tcx: 'lcx, 'lcx> Borrow<[CanonicalVarInfo]> for Interned<'tcx, Slice> { +impl<'tcx: 'lcx, 'lcx> Borrow<[CanonicalVarInfo]> for Interned<'tcx, List> { fn borrow<'a>(&'a self) -> &'a [CanonicalVarInfo] { &self.0[..] } @@ -2153,14 +2153,14 @@ impl<'tcx> Borrow for Interned<'tcx, RegionKind> { } impl<'tcx: 'lcx, 'lcx> Borrow<[ExistentialPredicate<'lcx>]> - for Interned<'tcx, Slice>> { + for Interned<'tcx, List>> { fn borrow<'a>(&'a self) -> &'a [ExistentialPredicate<'lcx>] { &self.0[..] } } impl<'tcx: 'lcx, 'lcx> Borrow<[Predicate<'lcx>]> - for Interned<'tcx, Slice>> { + for Interned<'tcx, List>> { fn borrow<'a>(&'a self) -> &'a [Predicate<'lcx>] { &self.0[..] } @@ -2173,14 +2173,14 @@ impl<'tcx: 'lcx, 'lcx> Borrow> for Interned<'tcx, Const<'tcx>> { } impl<'tcx: 'lcx, 'lcx> Borrow<[Clause<'lcx>]> -for Interned<'tcx, Slice>> { +for Interned<'tcx, List>> { fn borrow<'a>(&'a self) -> &'a [Clause<'lcx>] { &self.0[..] } } impl<'tcx: 'lcx, 'lcx> Borrow<[Goal<'lcx>]> -for Interned<'tcx, Slice>> { +for Interned<'tcx, List>> { fn borrow<'a>(&'a self) -> &'a [Goal<'lcx>] { &self.0[..] } @@ -2274,9 +2274,9 @@ macro_rules! slice_interners { ($($field:ident: $method:ident($ty:ident)),+) => ( $(intern_method!( 'tcx, $field: $method( &[$ty<'tcx>], - |a, v| Slice::from_arena(a, v), + |a, v| List::from_arena(a, v), Deref::deref, - |xs: &[$ty]| xs.iter().any(keep_local)) -> Slice<$ty<'tcx>>);)+ + |xs: &[$ty]| xs.iter().any(keep_local)) -> List<$ty<'tcx>>);)+ ) } @@ -2298,10 +2298,10 @@ intern_method! { 'tcx, canonical_var_infos: _intern_canonical_var_infos( &[CanonicalVarInfo], - |a, v| Slice::from_arena(a, v), + |a, v| List::from_arena(a, v), Deref::deref, |_xs: &[CanonicalVarInfo]| -> bool { false } - ) -> Slice + ) -> List } impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { @@ -2323,7 +2323,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn coerce_closure_fn_ty(self, sig: PolyFnSig<'tcx>) -> Ty<'tcx> { let converted_sig = sig.map_bound(|s| { let params_iter = match s.inputs()[0].sty { - ty::TyTuple(params) => { + ty::Tuple(params) => { params.into_iter().cloned() } _ => bug!(), @@ -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) } @@ -2374,7 +2374,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } pub fn mk_str(self) -> Ty<'tcx> { - self.mk_ty(TyStr) + self.mk_ty(Str) } pub fn mk_static_str(self) -> Ty<'tcx> { @@ -2383,11 +2383,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn mk_adt(self, def: &'tcx AdtDef, substs: &'tcx Substs<'tcx>) -> Ty<'tcx> { // take a copy of substs so that we own the vectors inside - self.mk_ty(TyAdt(def, substs)) + self.mk_ty(Adt(def, substs)) } pub fn mk_foreign(self, def_id: DefId) -> Ty<'tcx> { - self.mk_ty(TyForeign(def_id)) + self.mk_ty(Foreign(def_id)) } pub fn mk_box(self, ty: Ty<'tcx>) -> Ty<'tcx> { @@ -2406,15 +2406,15 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } } }); - self.mk_ty(TyAdt(adt_def, substs)) + self.mk_ty(Adt(adt_def, substs)) } pub fn mk_ptr(self, tm: TypeAndMut<'tcx>) -> Ty<'tcx> { - self.mk_ty(TyRawPtr(tm)) + self.mk_ty(RawPtr(tm)) } pub fn mk_ref(self, r: Region<'tcx>, tm: TypeAndMut<'tcx>) -> Ty<'tcx> { - self.mk_ty(TyRef(r, tm.ty, tm.mutbl)) + self.mk_ty(Ref(r, tm.ty, tm.mutbl)) } pub fn mk_mut_ref(self, r: Region<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> { @@ -2438,19 +2438,19 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } pub fn mk_array(self, ty: Ty<'tcx>, n: u64) -> Ty<'tcx> { - self.mk_ty(TyArray(ty, ty::Const::from_usize(self, n))) + self.mk_ty(Array(ty, ty::Const::from_usize(self, n))) } pub fn mk_slice(self, ty: Ty<'tcx>) -> Ty<'tcx> { - self.mk_ty(TySlice(ty)) + self.mk_ty(Slice(ty)) } pub fn intern_tup(self, ts: &[Ty<'tcx>]) -> Ty<'tcx> { - self.mk_ty(TyTuple(self.intern_type_list(ts))) + self.mk_ty(Tuple(self.intern_type_list(ts))) } pub fn mk_tup], Ty<'tcx>>>(self, iter: I) -> I::Output { - iter.intern_with(|ts| self.mk_ty(TyTuple(self.intern_type_list(ts)))) + iter.intern_with(|ts| self.mk_ty(Tuple(self.intern_type_list(ts)))) } pub fn mk_nil(self) -> Ty<'tcx> { @@ -2466,31 +2466,31 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } pub fn mk_bool(self) -> Ty<'tcx> { - self.mk_ty(TyBool) + self.mk_ty(Bool) } pub fn mk_fn_def(self, def_id: DefId, substs: &'tcx Substs<'tcx>) -> Ty<'tcx> { - self.mk_ty(TyFnDef(def_id, substs)) + self.mk_ty(FnDef(def_id, substs)) } pub fn mk_fn_ptr(self, fty: PolyFnSig<'tcx>) -> Ty<'tcx> { - self.mk_ty(TyFnPtr(fty)) + self.mk_ty(FnPtr(fty)) } pub fn mk_dynamic( self, - obj: ty::Binder<&'tcx Slice>>, + obj: ty::Binder<&'tcx List>>, reg: ty::Region<'tcx> ) -> Ty<'tcx> { - self.mk_ty(TyDynamic(obj, reg)) + self.mk_ty(Dynamic(obj, reg)) } pub fn mk_projection(self, item_def_id: DefId, substs: &'tcx Substs<'tcx>) -> Ty<'tcx> { - self.mk_ty(TyProjection(ProjectionTy { + self.mk_ty(Projection(ProjectionTy { item_def_id, substs, })) @@ -2498,7 +2498,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn mk_closure(self, closure_id: DefId, closure_substs: ClosureSubsts<'tcx>) -> Ty<'tcx> { - self.mk_ty(TyClosure(closure_id, closure_substs)) + self.mk_ty(Closure(closure_id, closure_substs)) } pub fn mk_generator(self, @@ -2506,11 +2506,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { generator_substs: GeneratorSubsts<'tcx>, movability: hir::GeneratorMovability) -> Ty<'tcx> { - self.mk_ty(TyGenerator(id, generator_substs, movability)) + self.mk_ty(Generator(id, generator_substs, movability)) } - pub fn mk_generator_witness(self, types: ty::Binder<&'tcx Slice>>) -> Ty<'tcx> { - self.mk_ty(TyGeneratorWitness(types)) + pub fn mk_generator_witness(self, types: ty::Binder<&'tcx List>>) -> Ty<'tcx> { + self.mk_ty(GeneratorWitness(types)) } pub fn mk_var(self, v: TyVid) -> Ty<'tcx> { @@ -2526,13 +2526,13 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } pub fn mk_infer(self, it: InferTy) -> Ty<'tcx> { - self.mk_ty(TyInfer(it)) + self.mk_ty(Infer(it)) } pub fn mk_ty_param(self, index: u32, name: InternedString) -> Ty<'tcx> { - self.mk_ty(TyParam(ParamTy { idx: index, name: name })) + self.mk_ty(Param(ParamTy { idx: index, name: name })) } pub fn mk_self_type(self) -> Ty<'tcx> { @@ -2549,40 +2549,40 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } pub fn mk_anon(self, def_id: DefId, substs: &'tcx Substs<'tcx>) -> Ty<'tcx> { - self.mk_ty(TyAnon(def_id, substs)) + self.mk_ty(Anon(def_id, substs)) } pub fn intern_existential_predicates(self, eps: &[ExistentialPredicate<'tcx>]) - -> &'tcx Slice> { + -> &'tcx List> { assert!(!eps.is_empty()); assert!(eps.windows(2).all(|w| w[0].stable_cmp(self, &w[1]) != Ordering::Greater)); self._intern_existential_predicates(eps) } pub fn intern_predicates(self, preds: &[Predicate<'tcx>]) - -> &'tcx Slice> { + -> &'tcx List> { // FIXME consider asking the input slice to be sorted to avoid // re-interning permutations, in which case that would be asserted // here. if preds.len() == 0 { // The macro-generated method below asserts we don't intern an empty slice. - Slice::empty() + List::empty() } else { self._intern_predicates(preds) } } - pub fn intern_type_list(self, ts: &[Ty<'tcx>]) -> &'tcx Slice> { + pub fn intern_type_list(self, ts: &[Ty<'tcx>]) -> &'tcx List> { if ts.len() == 0 { - Slice::empty() + List::empty() } else { self._intern_type_list(ts) } } - pub fn intern_substs(self, ts: &[Kind<'tcx>]) -> &'tcx Slice> { + pub fn intern_substs(self, ts: &[Kind<'tcx>]) -> &'tcx List> { if ts.len() == 0 { - Slice::empty() + List::empty() } else { self._intern_substs(ts) } @@ -2590,7 +2590,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn intern_canonical_var_infos(self, ts: &[CanonicalVarInfo]) -> CanonicalVarInfos<'gcx> { if ts.len() == 0 { - Slice::empty() + List::empty() } else { self.global_tcx()._intern_canonical_var_infos(ts) } @@ -2598,7 +2598,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn intern_clauses(self, ts: &[Clause<'tcx>]) -> Clauses<'tcx> { if ts.len() == 0 { - Slice::empty() + List::empty() } else { self._intern_clauses(ts) } @@ -2606,7 +2606,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn intern_goals(self, ts: &[Goal<'tcx>]) -> Goals<'tcx> { if ts.len() == 0 { - Slice::empty() + List::empty() } else { self._intern_goals(ts) } @@ -2629,24 +2629,24 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } pub fn mk_existential_predicates], - &'tcx Slice>>>(self, iter: I) + &'tcx List>>>(self, iter: I) -> I::Output { iter.intern_with(|xs| self.intern_existential_predicates(xs)) } pub fn mk_predicates], - &'tcx Slice>>>(self, iter: I) + &'tcx List>>>(self, iter: I) -> I::Output { iter.intern_with(|xs| self.intern_predicates(xs)) } pub fn mk_type_list], - &'tcx Slice>>>(self, iter: I) -> I::Output { + &'tcx List>>>(self, iter: I) -> I::Output { iter.intern_with(|xs| self.intern_type_list(xs)) } pub fn mk_substs], - &'tcx Slice>>>(self, iter: I) -> I::Output { + &'tcx List>>>(self, iter: I) -> I::Output { iter.intern_with(|xs| self.intern_substs(xs)) } diff --git a/src/librustc/ty/error.rs b/src/librustc/ty/error.rs index e23034bde7672..aa6ee420a2162 100644 --- a/src/librustc/ty/error.rs +++ b/src/librustc/ty/error.rs @@ -51,7 +51,7 @@ pub enum TypeError<'tcx> { CyclicTy(Ty<'tcx>), ProjectionMismatched(ExpectedFound), ProjectionBoundsLength(ExpectedFound), - ExistentialMismatch(ExpectedFound<&'tcx ty::Slice>>), + ExistentialMismatch(ExpectedFound<&'tcx ty::List>>), OldStyleLUB(Box>), } @@ -175,21 +175,21 @@ impl<'tcx> fmt::Display for TypeError<'tcx> { impl<'a, 'gcx, 'lcx, 'tcx> ty::TyS<'tcx> { pub fn sort_string(&self, tcx: TyCtxt<'a, 'gcx, 'lcx>) -> String { match self.sty { - ty::TyBool | ty::TyChar | ty::TyInt(_) | - ty::TyUint(_) | ty::TyFloat(_) | ty::TyStr | ty::TyNever => self.to_string(), - ty::TyTuple(ref tys) if tys.is_empty() => self.to_string(), + ty::Bool | ty::Char | ty::Int(_) | + ty::Uint(_) | ty::Float(_) | ty::Str | ty::Never => self.to_string(), + ty::Tuple(ref tys) if tys.is_empty() => self.to_string(), - ty::TyAdt(def, _) => format!("{} `{}`", def.descr(), tcx.item_path_str(def.did)), - ty::TyForeign(def_id) => format!("extern type `{}`", tcx.item_path_str(def_id)), - ty::TyArray(_, n) => { + ty::Adt(def, _) => format!("{} `{}`", def.descr(), tcx.item_path_str(def.did)), + ty::Foreign(def_id) => format!("extern type `{}`", tcx.item_path_str(def_id)), + ty::Array(_, n) => { match n.assert_usize(tcx) { Some(n) => format!("array of {} elements", n), None => "array".to_string(), } } - ty::TySlice(_) => "slice".to_string(), - ty::TyRawPtr(_) => "*-ptr".to_string(), - ty::TyRef(region, ty, mutbl) => { + ty::Slice(_) => "slice".to_string(), + ty::RawPtr(_) => "*-ptr".to_string(), + ty::Ref(region, ty, mutbl) => { let tymut = ty::TypeAndMut { ty, mutbl }; let tymut_string = tymut.to_string(); if tymut_string == "_" || //unknown type name, @@ -204,33 +204,33 @@ impl<'a, 'gcx, 'lcx, 'tcx> ty::TyS<'tcx> { format!("&{}", tymut_string) } } - ty::TyFnDef(..) => "fn item".to_string(), - ty::TyFnPtr(_) => "fn pointer".to_string(), - ty::TyDynamic(ref inner, ..) => { + ty::FnDef(..) => "fn item".to_string(), + ty::FnPtr(_) => "fn pointer".to_string(), + ty::Dynamic(ref inner, ..) => { inner.principal().map_or_else(|| "trait".to_string(), |p| format!("trait {}", tcx.item_path_str(p.def_id()))) } - ty::TyClosure(..) => "closure".to_string(), - ty::TyGenerator(..) => "generator".to_string(), - ty::TyGeneratorWitness(..) => "generator witness".to_string(), - ty::TyTuple(..) => "tuple".to_string(), - ty::TyInfer(ty::TyVar(_)) => "inferred type".to_string(), - ty::TyInfer(ty::IntVar(_)) => "integral variable".to_string(), - ty::TyInfer(ty::FloatVar(_)) => "floating-point variable".to_string(), - ty::TyInfer(ty::CanonicalTy(_)) | - ty::TyInfer(ty::FreshTy(_)) => "skolemized type".to_string(), - ty::TyInfer(ty::FreshIntTy(_)) => "skolemized integral type".to_string(), - ty::TyInfer(ty::FreshFloatTy(_)) => "skolemized floating-point type".to_string(), - ty::TyProjection(_) => "associated type".to_string(), - ty::TyParam(ref p) => { + ty::Closure(..) => "closure".to_string(), + ty::Generator(..) => "generator".to_string(), + ty::GeneratorWitness(..) => "generator witness".to_string(), + ty::Tuple(..) => "tuple".to_string(), + ty::Infer(ty::TyVar(_)) => "inferred type".to_string(), + ty::Infer(ty::IntVar(_)) => "integral variable".to_string(), + ty::Infer(ty::FloatVar(_)) => "floating-point variable".to_string(), + ty::Infer(ty::CanonicalTy(_)) | + ty::Infer(ty::FreshTy(_)) => "skolemized type".to_string(), + ty::Infer(ty::FreshIntTy(_)) => "skolemized integral type".to_string(), + ty::Infer(ty::FreshFloatTy(_)) => "skolemized floating-point type".to_string(), + ty::Projection(_) => "associated type".to_string(), + ty::Param(ref p) => { if p.is_self() { "Self".to_string() } else { "type parameter".to_string() } } - ty::TyAnon(..) => "anonymized type".to_string(), - ty::TyError => "type error".to_string(), + ty::Anon(..) => "anonymized type".to_string(), + ty::Error => "type error".to_string(), } } } @@ -251,7 +251,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { db.help("consider boxing your closure and/or using it as a trait object"); } match (&values.found.sty, &values.expected.sty) { // Issue #53280 - (ty::TyInfer(ty::IntVar(_)), ty::TyFloat(_)) => { + (ty::Infer(ty::IntVar(_)), ty::Float(_)) => { if let Ok(snippet) = self.sess.source_map().span_to_snippet(sp) { if snippet.chars().all(|c| c.is_digit(10) || c == '-' || c == '_') { db.span_suggestion_with_applicability( diff --git a/src/librustc/ty/fast_reject.rs b/src/librustc/ty/fast_reject.rs index cf5e55a59f713..567d1c668f7c7 100644 --- a/src/librustc/ty/fast_reject.rs +++ b/src/librustc/ty/fast_reject.rs @@ -68,42 +68,42 @@ pub fn simplify_type<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>, -> Option { match ty.sty { - ty::TyBool => Some(BoolSimplifiedType), - ty::TyChar => Some(CharSimplifiedType), - ty::TyInt(int_type) => Some(IntSimplifiedType(int_type)), - ty::TyUint(uint_type) => Some(UintSimplifiedType(uint_type)), - ty::TyFloat(float_type) => Some(FloatSimplifiedType(float_type)), - ty::TyAdt(def, _) => Some(AdtSimplifiedType(def.did)), - ty::TyStr => Some(StrSimplifiedType), - ty::TyArray(..) | ty::TySlice(_) => Some(ArraySimplifiedType), - ty::TyRawPtr(_) => Some(PtrSimplifiedType), - ty::TyDynamic(ref trait_info, ..) => { + ty::Bool => Some(BoolSimplifiedType), + ty::Char => Some(CharSimplifiedType), + ty::Int(int_type) => Some(IntSimplifiedType(int_type)), + ty::Uint(uint_type) => Some(UintSimplifiedType(uint_type)), + ty::Float(float_type) => Some(FloatSimplifiedType(float_type)), + ty::Adt(def, _) => Some(AdtSimplifiedType(def.did)), + ty::Str => Some(StrSimplifiedType), + ty::Array(..) | ty::Slice(_) => Some(ArraySimplifiedType), + ty::RawPtr(_) => Some(PtrSimplifiedType), + ty::Dynamic(ref trait_info, ..) => { trait_info.principal().map(|p| TraitSimplifiedType(p.def_id())) } - ty::TyRef(_, ty, _) => { + ty::Ref(_, ty, _) => { // since we introduce auto-refs during method lookup, we // just treat &T and T as equivalent from the point of // view of possibly unifying simplify_type(tcx, ty, can_simplify_params) } - ty::TyFnDef(def_id, _) | - ty::TyClosure(def_id, _) => { + ty::FnDef(def_id, _) | + ty::Closure(def_id, _) => { Some(ClosureSimplifiedType(def_id)) } - ty::TyGenerator(def_id, _, _) => { + ty::Generator(def_id, _, _) => { Some(GeneratorSimplifiedType(def_id)) } - ty::TyGeneratorWitness(ref tys) => { + ty::GeneratorWitness(ref tys) => { Some(GeneratorWitnessSimplifiedType(tys.skip_binder().len())) } - ty::TyNever => Some(NeverSimplifiedType), - ty::TyTuple(ref tys) => { + ty::Never => Some(NeverSimplifiedType), + ty::Tuple(ref tys) => { Some(TupleSimplifiedType(tys.len())) } - ty::TyFnPtr(ref f) => { + ty::FnPtr(ref f) => { Some(FunctionSimplifiedType(f.skip_binder().inputs().len())) } - ty::TyProjection(_) | ty::TyParam(_) => { + ty::Projection(_) | ty::Param(_) => { if can_simplify_params { // In normalized types, projections don't unify with // anything. when lazy normalization happens, this @@ -115,13 +115,13 @@ pub fn simplify_type<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>, None } } - ty::TyAnon(def_id, _) => { + ty::Anon(def_id, _) => { Some(AnonSimplifiedType(def_id)) } - ty::TyForeign(def_id) => { + ty::Foreign(def_id) => { Some(ForeignSimplifiedType(def_id)) } - ty::TyInfer(_) | ty::TyError => None, + ty::Infer(_) | ty::Error => None, } } diff --git a/src/librustc/ty/flags.rs b/src/librustc/ty/flags.rs index 3718c436b3a00..b9371ec39ccda 100644 --- a/src/librustc/ty/flags.rs +++ b/src/librustc/ty/flags.rs @@ -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 @@ -67,30 +67,30 @@ impl FlagComputation { } } - fn add_sty(&mut self, st: &ty::TypeVariants) { + fn add_sty(&mut self, st: &ty::TyKind) { match st { - &ty::TyBool | - &ty::TyChar | - &ty::TyInt(_) | - &ty::TyFloat(_) | - &ty::TyUint(_) | - &ty::TyNever | - &ty::TyStr | - &ty::TyForeign(..) => { + &ty::Bool | + &ty::Char | + &ty::Int(_) | + &ty::Float(_) | + &ty::Uint(_) | + &ty::Never | + &ty::Str | + &ty::Foreign(..) => { } - // You might think that we could just return TyError for - // any type containing TyError as a component, and get + // You might think that we could just return Error for + // any type containing Error as a component, and get // rid of the TypeFlags::HAS_TY_ERR flag -- likewise for ty_bot (with // the exception of function types that return bot). // But doing so caused sporadic memory corruption, and // neither I (tjc) nor nmatsakis could figure out why, // so we're doing it this way. - &ty::TyError => { + &ty::Error => { self.add_flags(TypeFlags::HAS_TY_ERR) } - &ty::TyParam(ref p) => { + &ty::Param(ref p) => { self.add_flags(TypeFlags::HAS_FREE_LOCAL_NAMES); if p.is_self() { self.add_flags(TypeFlags::HAS_SELF); @@ -99,25 +99,25 @@ impl FlagComputation { } } - &ty::TyGenerator(_, ref substs, _) => { + &ty::Generator(_, ref substs, _) => { self.add_flags(TypeFlags::HAS_TY_CLOSURE); self.add_flags(TypeFlags::HAS_FREE_LOCAL_NAMES); self.add_substs(&substs.substs); } - &ty::TyGeneratorWitness(ref ts) => { + &ty::GeneratorWitness(ref ts) => { let mut computation = FlagComputation::new(); computation.add_tys(&ts.skip_binder()[..]); self.add_bound_computation(&computation); } - &ty::TyClosure(_, ref substs) => { + &ty::Closure(_, ref substs) => { self.add_flags(TypeFlags::HAS_TY_CLOSURE); self.add_flags(TypeFlags::HAS_FREE_LOCAL_NAMES); self.add_substs(&substs.substs); } - &ty::TyInfer(infer) => { + &ty::Infer(infer) => { self.add_flags(TypeFlags::HAS_FREE_LOCAL_NAMES); // it might, right? self.add_flags(TypeFlags::HAS_TY_INFER); match infer { @@ -136,11 +136,11 @@ impl FlagComputation { } } - &ty::TyAdt(_, substs) => { + &ty::Adt(_, substs) => { self.add_substs(substs); } - &ty::TyProjection(ref data) => { + &ty::Projection(ref data) => { // currently we can't normalize projections that // include bound regions, so track those separately. if !data.has_escaping_regions() { @@ -150,12 +150,12 @@ impl FlagComputation { self.add_projection_ty(data); } - &ty::TyAnon(_, substs) => { + &ty::Anon(_, substs) => { self.add_flags(TypeFlags::HAS_PROJECTION); self.add_substs(substs); } - &ty::TyDynamic(ref obj, r) => { + &ty::Dynamic(ref obj, r) => { let mut computation = FlagComputation::new(); for predicate in obj.skip_binder().iter() { match *predicate { @@ -172,33 +172,33 @@ impl FlagComputation { self.add_region(r); } - &ty::TyArray(tt, len) => { + &ty::Array(tt, len) => { self.add_ty(tt); self.add_const(len); } - &ty::TySlice(tt) => { + &ty::Slice(tt) => { self.add_ty(tt) } - &ty::TyRawPtr(ref m) => { + &ty::RawPtr(ref m) => { self.add_ty(m.ty); } - &ty::TyRef(r, ty, _) => { + &ty::Ref(r, ty, _) => { self.add_region(r); self.add_ty(ty); } - &ty::TyTuple(ref ts) => { + &ty::Tuple(ref ts) => { self.add_tys(&ts[..]); } - &ty::TyFnDef(_, substs) => { + &ty::FnDef(_, substs) => { self.add_substs(substs); } - &ty::TyFnPtr(f) => { + &ty::FnPtr(f) => { self.add_fn_sig(f); } } diff --git a/src/librustc/ty/fold.rs b/src/librustc/ty/fold.rs index e4484041b065c..26010c3d5f55c 100644 --- a/src/librustc/ty/fold.rs +++ b/src/librustc/ty/fold.rs @@ -771,7 +771,7 @@ impl<'tcx> TypeVisitor<'tcx> for LateBoundRegionsCollector { // in the normalized form if self.just_constrained { match t.sty { - ty::TyProjection(..) | ty::TyAnon(..) => { return false; } + ty::Projection(..) | ty::Anon(..) => { return false; } _ => { } } } diff --git a/src/librustc/ty/inhabitedness/mod.rs b/src/librustc/ty/inhabitedness/mod.rs index 0ace44dca77b4..ef5b223620032 100644 --- a/src/librustc/ty/inhabitedness/mod.rs +++ b/src/librustc/ty/inhabitedness/mod.rs @@ -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; @@ -226,7 +226,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> { tcx: TyCtxt<'a, 'gcx, 'tcx>) -> DefIdForest { match self.sty { - TyAdt(def, substs) => { + Adt(def, substs) => { { let substs_set = visited.entry(def.did).or_default(); if !substs_set.insert(substs) { @@ -255,13 +255,13 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> { ret }, - TyNever => DefIdForest::full(tcx), - TyTuple(ref tys) => { + Never => DefIdForest::full(tcx), + Tuple(ref tys) => { DefIdForest::union(tcx, tys.iter().map(|ty| { ty.uninhabited_from(visited, tcx) })) }, - TyArray(ty, len) => { + Array(ty, len) => { match len.assert_usize(tcx) { // If the array is definitely non-empty, it's uninhabited if // the type of its elements is uninhabited. @@ -269,7 +269,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> { _ => DefIdForest::empty() } } - TyRef(_, ty, _) => { + Ref(_, ty, _) => { ty.uninhabited_from(visited, tcx) } diff --git a/src/librustc/ty/instance.rs b/src/librustc/ty/instance.rs index 7329f4832f2e2..68996f52b867a 100644 --- a/src/librustc/ty/instance.rs +++ b/src/librustc/ty/instance.rs @@ -194,7 +194,7 @@ impl<'a, 'b, 'tcx> Instance<'tcx> { ); let def = match item_type.sty { - ty::TyFnDef(..) if { + ty::FnDef(..) if { let f = item_type.fn_sig(tcx); f.abi() == Abi::RustIntrinsic || f.abi() == Abi::PlatformIntrinsic diff --git a/src/librustc/ty/item_path.rs b/src/librustc/ty/item_path.rs index 593470b5d1ecd..e38bb411a14f9 100644 --- a/src/librustc/ty/item_path.rs +++ b/src/librustc/ty/item_path.rs @@ -299,7 +299,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { // impl on `Foo`, but fallback to `::bar` if self-type is // anything other than a simple path. match self_ty.sty { - ty::TyAdt(adt_def, substs) => { + ty::Adt(adt_def, substs) => { if substs.types().next().is_none() { // ignore regions self.push_item_path(buffer, adt_def.did); } else { @@ -307,14 +307,14 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } } - ty::TyForeign(did) => self.push_item_path(buffer, did), + ty::Foreign(did) => self.push_item_path(buffer, did), - ty::TyBool | - ty::TyChar | - ty::TyInt(_) | - ty::TyUint(_) | - ty::TyFloat(_) | - ty::TyStr => { + ty::Bool | + ty::Char | + ty::Int(_) | + ty::Uint(_) | + ty::Float(_) | + ty::Str => { buffer.push(&self_ty.to_string()); } @@ -357,40 +357,40 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { /// decisions and we may want to adjust it later. pub fn characteristic_def_id_of_type(ty: Ty) -> Option { match ty.sty { - ty::TyAdt(adt_def, _) => Some(adt_def.did), + ty::Adt(adt_def, _) => Some(adt_def.did), - ty::TyDynamic(data, ..) => data.principal().map(|p| p.def_id()), + ty::Dynamic(data, ..) => data.principal().map(|p| p.def_id()), - ty::TyArray(subty, _) | - ty::TySlice(subty) => characteristic_def_id_of_type(subty), + ty::Array(subty, _) | + ty::Slice(subty) => characteristic_def_id_of_type(subty), - ty::TyRawPtr(mt) => characteristic_def_id_of_type(mt.ty), + ty::RawPtr(mt) => characteristic_def_id_of_type(mt.ty), - ty::TyRef(_, ty, _) => characteristic_def_id_of_type(ty), + ty::Ref(_, ty, _) => characteristic_def_id_of_type(ty), - ty::TyTuple(ref tys) => tys.iter() + ty::Tuple(ref tys) => tys.iter() .filter_map(|ty| characteristic_def_id_of_type(ty)) .next(), - ty::TyFnDef(def_id, _) | - ty::TyClosure(def_id, _) | - ty::TyGenerator(def_id, _, _) | - ty::TyForeign(def_id) => Some(def_id), - - ty::TyBool | - ty::TyChar | - ty::TyInt(_) | - ty::TyUint(_) | - ty::TyStr | - ty::TyFnPtr(_) | - ty::TyProjection(_) | - ty::TyParam(_) | - ty::TyAnon(..) | - ty::TyInfer(_) | - ty::TyError | - ty::TyGeneratorWitness(..) | - ty::TyNever | - ty::TyFloat(_) => None, + ty::FnDef(def_id, _) | + ty::Closure(def_id, _) | + ty::Generator(def_id, _, _) | + ty::Foreign(def_id) => Some(def_id), + + ty::Bool | + ty::Char | + ty::Int(_) | + ty::Uint(_) | + ty::Str | + ty::FnPtr(_) | + ty::Projection(_) | + ty::Param(_) | + ty::Anon(..) | + ty::Infer(_) | + ty::Error | + ty::GeneratorWitness(..) | + ty::Never | + ty::Float(_) => None, } } diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index 0da4d5ddea2f2..d485b9b32d431 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -470,33 +470,33 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { Ok(match ty.sty { // Basic scalars. - ty::TyBool => { + ty::Bool => { tcx.intern_layout(LayoutDetails::scalar(self, Scalar { value: Int(I8, false), valid_range: 0..=1 })) } - ty::TyChar => { + ty::Char => { tcx.intern_layout(LayoutDetails::scalar(self, Scalar { value: Int(I32, false), valid_range: 0..=0x10FFFF })) } - ty::TyInt(ity) => { + ty::Int(ity) => { scalar(Int(Integer::from_attr(dl, attr::SignedInt(ity)), true)) } - ty::TyUint(ity) => { + ty::Uint(ity) => { scalar(Int(Integer::from_attr(dl, attr::UnsignedInt(ity)), false)) } - ty::TyFloat(fty) => scalar(Float(fty)), - ty::TyFnPtr(_) => { + ty::Float(fty) => scalar(Float(fty)), + ty::FnPtr(_) => { let mut ptr = scalar_unit(Pointer); ptr.valid_range = 1..=*ptr.valid_range.end(); tcx.intern_layout(LayoutDetails::scalar(self, ptr)) } // The never type. - ty::TyNever => { + ty::Never => { tcx.intern_layout(LayoutDetails { variants: Variants::Single { index: 0 }, fields: FieldPlacement::Union(0), @@ -507,8 +507,8 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { } // Potentially-fat pointers. - ty::TyRef(_, pointee, _) | - ty::TyRawPtr(ty::TypeAndMut { ty: pointee, .. }) => { + ty::Ref(_, pointee, _) | + ty::RawPtr(ty::TypeAndMut { ty: pointee, .. }) => { let mut data_ptr = scalar_unit(Pointer); if !ty.is_unsafe_ptr() { data_ptr.valid_range = 1..=*data_ptr.valid_range.end(); @@ -521,13 +521,13 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { let unsized_part = tcx.struct_tail(pointee); let metadata = match unsized_part.sty { - ty::TyForeign(..) => { + ty::Foreign(..) => { return Ok(tcx.intern_layout(LayoutDetails::scalar(self, data_ptr))); } - ty::TySlice(_) | ty::TyStr => { + ty::Slice(_) | ty::Str => { scalar_unit(Int(dl.ptr_sized_integer(), false)) } - ty::TyDynamic(..) => { + ty::Dynamic(..) => { let mut vtable = scalar_unit(Pointer); vtable.valid_range = 1..=*vtable.valid_range.end(); vtable @@ -540,7 +540,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { } // Arrays and slices. - ty::TyArray(element, mut count) => { + ty::Array(element, mut count) => { if count.has_projections() { count = tcx.normalize_erasing_regions(param_env, count); if count.has_projections() { @@ -564,7 +564,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { size }) } - ty::TySlice(element) => { + ty::Slice(element) => { let element = self.layout_of(element)?; tcx.intern_layout(LayoutDetails { variants: Variants::Single { index: 0 }, @@ -577,7 +577,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { size: Size::ZERO }) } - ty::TyStr => { + ty::Str => { tcx.intern_layout(LayoutDetails { variants: Variants::Single { index: 0 }, fields: FieldPlacement::Array { @@ -591,10 +591,10 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { } // Odd unit types. - ty::TyFnDef(..) => { + ty::FnDef(..) => { univariant(&[], &ReprOptions::default(), StructKind::AlwaysSized)? } - ty::TyDynamic(..) | ty::TyForeign(..) => { + ty::Dynamic(..) | ty::Foreign(..) => { let mut unit = univariant_uninterned(&[], &ReprOptions::default(), StructKind::AlwaysSized)?; match unit.abi { @@ -605,21 +605,21 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { } // Tuples, generators and closures. - ty::TyGenerator(def_id, ref substs, _) => { + ty::Generator(def_id, ref substs, _) => { let tys = substs.field_tys(def_id, tcx); univariant(&tys.map(|ty| self.layout_of(ty)).collect::, _>>()?, &ReprOptions::default(), StructKind::AlwaysSized)? } - ty::TyClosure(def_id, ref substs) => { + ty::Closure(def_id, ref substs) => { let tys = substs.upvar_tys(def_id, tcx); univariant(&tys.map(|ty| self.layout_of(ty)).collect::, _>>()?, &ReprOptions::default(), StructKind::AlwaysSized)? } - ty::TyTuple(tys) => { + ty::Tuple(tys) => { let kind = if tys.len() == 0 { StructKind::AlwaysSized } else { @@ -631,7 +631,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { } // SIMD vector types. - ty::TyAdt(def, ..) if def.repr.simd() => { + ty::Adt(def, ..) if def.repr.simd() => { let element = self.layout_of(ty.simd_type(tcx))?; let count = ty.simd_size(tcx) as u64; assert!(count > 0); @@ -664,7 +664,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { } // ADTs. - ty::TyAdt(def, substs) => { + ty::Adt(def, substs) => { // Cache the field layouts. let variants = def.variants.iter().map(|v| { v.fields.iter().map(|field| { @@ -1103,17 +1103,17 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { } // Types with no meaningful known layout. - ty::TyProjection(_) | ty::TyAnon(..) => { + ty::Projection(_) | ty::Anon(..) => { let normalized = tcx.normalize_erasing_regions(param_env, ty); if ty == normalized { return Err(LayoutError::Unknown(ty)); } tcx.layout_raw(param_env.and(normalized))? } - ty::TyGeneratorWitness(..) | ty::TyInfer(_) => { + ty::GeneratorWitness(..) | ty::Infer(_) => { bug!("LayoutDetails::compute: unexpected type `{}`", ty) } - ty::TyParam(_) | ty::TyError => { + ty::Param(_) | ty::Error => { return Err(LayoutError::Unknown(ty)); } }) @@ -1153,12 +1153,12 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { }; let adt_def = match layout.ty.sty { - ty::TyAdt(ref adt_def, _) => { + ty::Adt(ref adt_def, _) => { debug!("print-type-size t: `{:?}` process adt", layout.ty); adt_def } - ty::TyClosure(..) => { + ty::Closure(..) => { debug!("print-type-size t: `{:?}` record closure", layout.ty); record(DataTypeKind::Closure, false, None, vec![]); return; @@ -1294,12 +1294,12 @@ impl<'a, 'tcx> SizeSkeleton<'tcx> { }; match ty.sty { - ty::TyRef(_, pointee, _) | - ty::TyRawPtr(ty::TypeAndMut { ty: pointee, .. }) => { + ty::Ref(_, pointee, _) | + ty::RawPtr(ty::TypeAndMut { ty: pointee, .. }) => { let non_zero = !ty.is_unsafe_ptr(); let tail = tcx.struct_tail(pointee); match tail.sty { - ty::TyParam(_) | ty::TyProjection(_) => { + ty::Param(_) | ty::Projection(_) => { debug_assert!(tail.has_param_types() || tail.has_self_ty()); Ok(SizeSkeleton::Pointer { non_zero, @@ -1314,7 +1314,7 @@ impl<'a, 'tcx> SizeSkeleton<'tcx> { } } - ty::TyAdt(def, substs) => { + ty::Adt(def, substs) => { // Only newtypes and enums w/ nullable pointer optimization. if def.is_union() || def.variants.is_empty() || def.variants.len() > 2 { return Err(err); @@ -1373,7 +1373,7 @@ impl<'a, 'tcx> SizeSkeleton<'tcx> { } } - ty::TyProjection(_) | ty::TyAnon(..) => { + ty::Projection(_) | ty::Anon(..) => { let normalized = tcx.normalize_erasing_regions(param_env, ty); if ty == normalized { Err(err) @@ -1552,7 +1552,7 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx> }); let fields = match this.ty.sty { - ty::TyAdt(def, _) => def.variants[variant_index].fields.len(), + ty::Adt(def, _) => def.variants[variant_index].fields.len(), _ => bug!() }; let tcx = cx.tcx(); @@ -1582,23 +1582,23 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx> fn field(this: TyLayout<'tcx>, cx: C, i: usize) -> C::TyLayout { let tcx = cx.tcx(); cx.layout_of(match this.ty.sty { - ty::TyBool | - ty::TyChar | - ty::TyInt(_) | - ty::TyUint(_) | - ty::TyFloat(_) | - ty::TyFnPtr(_) | - ty::TyNever | - ty::TyFnDef(..) | - ty::TyGeneratorWitness(..) | - ty::TyForeign(..) | - ty::TyDynamic(..) => { + ty::Bool | + ty::Char | + ty::Int(_) | + ty::Uint(_) | + ty::Float(_) | + ty::FnPtr(_) | + ty::Never | + ty::FnDef(..) | + ty::GeneratorWitness(..) | + ty::Foreign(..) | + ty::Dynamic(..) => { bug!("TyLayout::field_type({:?}): not applicable", this) } // Potentially-fat pointers. - ty::TyRef(_, pointee, _) | - ty::TyRawPtr(ty::TypeAndMut { ty: pointee, .. }) => { + ty::Ref(_, pointee, _) | + ty::RawPtr(ty::TypeAndMut { ty: pointee, .. }) => { assert!(i < this.fields.count()); // Reuse the fat *T type as its own thin pointer data field. @@ -1619,9 +1619,9 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx> } match tcx.struct_tail(pointee).sty { - ty::TySlice(_) | - ty::TyStr => tcx.types.usize, - ty::TyDynamic(data, _) => { + ty::Slice(_) | + ty::Str => tcx.types.usize, + ty::Dynamic(data, _) => { let trait_def_id = data.principal().unwrap().def_id(); let num_fns: u64 = crate::traits::supertrait_def_ids(tcx, trait_def_id) .map(|trait_def_id| { @@ -1646,28 +1646,28 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx> } // Arrays and slices. - ty::TyArray(element, _) | - ty::TySlice(element) => element, - ty::TyStr => tcx.types.u8, + ty::Array(element, _) | + ty::Slice(element) => element, + ty::Str => tcx.types.u8, // Tuples, generators and closures. - ty::TyClosure(def_id, ref substs) => { + ty::Closure(def_id, ref substs) => { substs.upvar_tys(def_id, tcx).nth(i).unwrap() } - ty::TyGenerator(def_id, ref substs, _) => { + ty::Generator(def_id, ref substs, _) => { substs.field_tys(def_id, tcx).nth(i).unwrap() } - ty::TyTuple(tys) => tys[i], + ty::Tuple(tys) => tys[i], // SIMD vector types. - ty::TyAdt(def, ..) if def.repr.simd() => { + ty::Adt(def, ..) if def.repr.simd() => { this.ty.simd_type(tcx) } // ADTs. - ty::TyAdt(def, substs) => { + ty::Adt(def, substs) => { match this.variants { Variants::Single { index } => { def.variants[index].fields[i].ty(tcx, substs) @@ -1686,8 +1686,8 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx> } } - ty::TyProjection(_) | ty::TyAnon(..) | ty::TyParam(_) | - ty::TyInfer(_) | ty::TyError => { + ty::Projection(_) | ty::Anon(..) | ty::Param(_) | + ty::Infer(_) | ty::Error => { bug!("TyLayout::field_type: unexpected type `{}`", this.ty) } }) @@ -1749,7 +1749,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { // Locals variables which live across yields are stored // in the generator type as fields. These may be uninitialized // so we don't look for niches there. - if let ty::TyGenerator(..) = layout.ty.sty { + if let ty::Generator(..) = layout.ty.sty { return Ok(None); } diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 486ed85843cd9..8d5006d17b3ab 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -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}; @@ -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::*; @@ -450,7 +450,7 @@ bitflags! { const HAS_FREE_LOCAL_NAMES = 1 << 10; // Present if the type belongs in a local type context. - // Only set for TyInfer other than Fresh. + // Only set for Infer other than Fresh. const KEEP_IN_LOCAL_TCX = 1 << 11; // Is there a projection that does not involve a bound region? @@ -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 @@ -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::Bool | + TyKind::Char | + TyKind::Int(_) | + TyKind::Uint(_) | + TyKind::Float(_) | + TyKind::Infer(InferTy::IntVar(_)) | + TyKind::Infer(InferTy::FloatVar(_)) | + TyKind::Infer(InferTy::FreshIntTy(_)) | + TyKind::Infer(InferTy::FreshFloatTy(_)) => true, + TyKind::Ref(_, 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::Anon(..) | + TyKind::FnDef(..) | + TyKind::FnPtr(..) | + TyKind::Dynamic(..) | + TyKind::Closure(..) | + TyKind::Infer(..) | + TyKind::Projection(..) => false, _ => true, } } @@ -596,8 +596,8 @@ impl<'tcx> serialize::UseSpecializedDecodable for Ty<'tcx> {} pub type CanonicalTy<'gcx> = Canonical<'gcx, Ty<'gcx>>; extern { - /// A dummy type used to force Slice to by unsized without requiring fat pointers - type OpaqueSliceContents; + /// A dummy type used to force List to by unsized without requiring fat pointers + type OpaqueListContents; } /// A wrapper for slices with the additional invariant @@ -605,18 +605,19 @@ extern { /// the same contents can exist in the same context. /// This means we can use pointer for both /// equality comparisons and hashing. +/// Note: `Slice` was already taken by the `Ty`. #[repr(C)] -pub struct Slice { +pub struct List { len: usize, data: [T; 0], - opaque: OpaqueSliceContents, + opaque: OpaqueListContents, } -unsafe impl Sync for Slice {} +unsafe impl Sync for List {} -impl Slice { +impl List { #[inline] - fn from_arena<'tcx>(arena: &'tcx SyncDroplessArena, slice: &[T]) -> &'tcx Slice { + fn from_arena<'tcx>(arena: &'tcx SyncDroplessArena, slice: &[T]) -> &'tcx List { assert!(!mem::needs_drop::()); assert!(mem::size_of::() != 0); assert!(slice.len() != 0); @@ -633,7 +634,7 @@ impl Slice { size, cmp::max(mem::align_of::(), mem::align_of::())); unsafe { - let result = &mut *(mem.as_mut_ptr() as *mut Slice); + let result = &mut *(mem.as_mut_ptr() as *mut List); // Write the length result.len = slice.len(); @@ -646,51 +647,51 @@ impl Slice { } } -impl fmt::Debug for Slice { +impl fmt::Debug for List { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { (**self).fmt(f) } } -impl Encodable for Slice { +impl Encodable for List { #[inline] fn encode(&self, s: &mut S) -> Result<(), S::Error> { (**self).encode(s) } } -impl Ord for Slice where T: Ord { - fn cmp(&self, other: &Slice) -> Ordering { +impl Ord for List where T: Ord { + fn cmp(&self, other: &List) -> Ordering { if self == other { Ordering::Equal } else { <[T] as Ord>::cmp(&**self, &**other) } } } -impl PartialOrd for Slice where T: PartialOrd { - fn partial_cmp(&self, other: &Slice) -> Option { +impl PartialOrd for List where T: PartialOrd { + fn partial_cmp(&self, other: &List) -> Option { if self == other { Some(Ordering::Equal) } else { <[T] as PartialOrd>::partial_cmp(&**self, &**other) } } } -impl PartialEq for Slice { +impl PartialEq for List { #[inline] - fn eq(&self, other: &Slice) -> bool { + fn eq(&self, other: &List) -> bool { ptr::eq(self, other) } } -impl Eq for Slice {} +impl Eq for List {} -impl Hash for Slice { +impl Hash for List { #[inline] fn hash(&self, s: &mut H) { - (self as *const Slice).hash(s) + (self as *const List).hash(s) } } -impl Deref for Slice { +impl Deref for List { type Target = [T]; #[inline(always)] fn deref(&self) -> &[T] { @@ -700,7 +701,7 @@ impl Deref for Slice { } } -impl<'a, T> IntoIterator for &'a Slice { +impl<'a, T> IntoIterator for &'a List { type Item = &'a T; type IntoIter = <&'a [T] as IntoIterator>::IntoIter; #[inline(always)] @@ -709,17 +710,17 @@ impl<'a, T> IntoIterator for &'a Slice { } } -impl<'tcx> serialize::UseSpecializedDecodable for &'tcx Slice> {} +impl<'tcx> serialize::UseSpecializedDecodable for &'tcx List> {} -impl Slice { +impl List { #[inline(always)] - pub fn empty<'a>() -> &'a Slice { + pub fn empty<'a>() -> &'a List { #[repr(align(64), C)] struct EmptySlice([u8; 64]); static EMPTY_SLICE: EmptySlice = EmptySlice([0; 64]); assert!(mem::align_of::() <= 64); unsafe { - &*(&EMPTY_SLICE as *const _ as *const Slice) + &*(&EMPTY_SLICE as *const _ as *const List) } } } @@ -1556,7 +1557,7 @@ pub struct ParamEnv<'tcx> { /// Obligations that the caller must satisfy. This is basically /// the set of bounds on the in-scope type parameters, translated /// into Obligations, and elaborated and normalized. - pub caller_bounds: &'tcx Slice>, + pub caller_bounds: &'tcx List>, /// Typically, this is `Reveal::UserFacing`, but during codegen we /// want `Reveal::All` -- note that this is always paired with an @@ -1570,7 +1571,7 @@ impl<'tcx> ParamEnv<'tcx> { /// Trait`) are left hidden, so this is suitable for ordinary /// type-checking. pub fn empty() -> Self { - Self::new(ty::Slice::empty(), Reveal::UserFacing) + Self::new(List::empty(), Reveal::UserFacing) } /// Construct a trait environment with no where clauses in scope @@ -1581,11 +1582,11 @@ impl<'tcx> ParamEnv<'tcx> { /// NB. If you want to have predicates in scope, use `ParamEnv::new`, /// or invoke `param_env.with_reveal_all()`. pub fn reveal_all() -> Self { - Self::new(ty::Slice::empty(), Reveal::All) + Self::new(List::empty(), Reveal::All) } /// Construct a trait environment with the given set of predicates. - pub fn new(caller_bounds: &'tcx ty::Slice>, + pub fn new(caller_bounds: &'tcx List>, reveal: Reveal) -> Self { ty::ParamEnv { caller_bounds, reveal } @@ -1603,7 +1604,7 @@ impl<'tcx> ParamEnv<'tcx> { /// Returns this same environment but with no caller bounds. pub fn without_caller_bounds(self) -> Self { - ty::ParamEnv { caller_bounds: ty::Slice::empty(), ..self } + ty::ParamEnv { caller_bounds: List::empty(), ..self } } /// Creates a suitable environment in which to perform trait @@ -2229,30 +2230,30 @@ impl<'a, 'gcx, 'tcx> AdtDef { ty: Ty<'tcx>) -> Vec> { let result = match ty.sty { - TyBool | TyChar | TyInt(..) | TyUint(..) | TyFloat(..) | - TyRawPtr(..) | TyRef(..) | TyFnDef(..) | TyFnPtr(_) | - TyArray(..) | TyClosure(..) | TyGenerator(..) | TyNever => { + Bool | Char | Int(..) | Uint(..) | Float(..) | + RawPtr(..) | Ref(..) | FnDef(..) | FnPtr(_) | + Array(..) | Closure(..) | Generator(..) | Never => { vec![] } - TyStr | - TyDynamic(..) | - TySlice(_) | - TyForeign(..) | - TyError | - TyGeneratorWitness(..) => { + Str | + Dynamic(..) | + Slice(_) | + Foreign(..) | + Error | + GeneratorWitness(..) => { // these are never sized - return the target type vec![ty] } - TyTuple(ref tys) => { + Tuple(ref tys) => { match tys.last() { None => vec![], Some(ty) => self.sized_constraint_for_ty(tcx, ty) } } - TyAdt(adt, substs) => { + Adt(adt, substs) => { // recursive case let adt_tys = adt.sized_constraint(tcx); debug!("sized_constraint_for_ty({:?}) intermediate = {:?}", @@ -2263,13 +2264,13 @@ impl<'a, 'gcx, 'tcx> AdtDef { .collect() } - TyProjection(..) | TyAnon(..) => { + Projection(..) | Anon(..) => { // must calculate explicitly. // FIXME: consider special-casing always-Sized projections vec![ty] } - TyParam(..) => { + Param(..) => { // perf hack: if there is a `T: Sized` bound, then // we know that `T` is Sized and do not need to check // it on the impl. @@ -2290,7 +2291,7 @@ impl<'a, 'gcx, 'tcx> AdtDef { } } - TyInfer(..) => { + Infer(..) => { bug!("unexpected type `{:?}` in sized_constraint_for_ty", ty) } @@ -2832,7 +2833,7 @@ fn associated_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) /// - a type parameter or projection whose Sizedness can't be known /// - a tuple of type parameters or projections, if there are multiple /// such. -/// - a TyError, if a type contained itself. The representability +/// - a Error, if a type contained itself. The representability /// check should catch this case. fn adt_sized_constraint<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) diff --git a/src/librustc/ty/outlives.rs b/src/librustc/ty/outlives.rs index ff99a4b7ff638..5171bfb7e0608 100644 --- a/src/librustc/ty/outlives.rs +++ b/src/librustc/ty/outlives.rs @@ -72,14 +72,14 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { // in the `subtys` iterator (e.g., when encountering a // projection). match ty.sty { - ty::TyClosure(def_id, ref substs) => { + ty::Closure(def_id, ref substs) => { for upvar_ty in substs.upvar_tys(def_id, *self) { self.compute_components(upvar_ty, out); } } - ty::TyGenerator(def_id, ref substs, _) => { + ty::Generator(def_id, ref substs, _) => { // Same as the closure case for upvar_ty in substs.upvar_tys(def_id, *self) { self.compute_components(upvar_ty, out); @@ -90,11 +90,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } // All regions are bound inside a witness - ty::TyGeneratorWitness(..) => (), + ty::GeneratorWitness(..) => (), // OutlivesTypeParameterEnv -- the actual checking that `X:'a` // is implied by the environment is done in regionck. - ty::TyParam(p) => { + ty::Param(p) => { out.push(Component::Param(p)); } @@ -106,7 +106,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { // trait-ref. Therefore, if we see any higher-ranke regions, // we simply fallback to the most restrictive rule, which // requires that `Pi: 'a` for all `i`. - ty::TyProjection(ref data) => { + ty::Projection(ref data) => { if !data.has_escaping_regions() { // best case: no escaping regions, so push the // projection and skip the subtree (thus generating no @@ -127,7 +127,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { // We assume that inference variables are fully resolved. // So, if we encounter an inference variable, just record // the unresolved variable as a component. - ty::TyInfer(infer_ty) => { + ty::Infer(infer_ty) => { out.push(Component::UnresolvedInferenceVariable(infer_ty)); } @@ -137,25 +137,25 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { // the type and then visits the types that are lexically // contained within. (The comments refer to relevant rules // from RFC1214.) - ty::TyBool | // OutlivesScalar - ty::TyChar | // OutlivesScalar - ty::TyInt(..) | // OutlivesScalar - ty::TyUint(..) | // OutlivesScalar - ty::TyFloat(..) | // OutlivesScalar - ty::TyNever | // ... - ty::TyAdt(..) | // OutlivesNominalType - ty::TyAnon(..) | // OutlivesNominalType (ish) - ty::TyForeign(..) | // OutlivesNominalType - ty::TyStr | // OutlivesScalar (ish) - ty::TyArray(..) | // ... - ty::TySlice(..) | // ... - ty::TyRawPtr(..) | // ... - ty::TyRef(..) | // OutlivesReference - ty::TyTuple(..) | // ... - ty::TyFnDef(..) | // OutlivesFunction (*) - ty::TyFnPtr(_) | // OutlivesFunction (*) - ty::TyDynamic(..) | // OutlivesObject, OutlivesFragment (*) - ty::TyError => { + ty::Bool | // OutlivesScalar + ty::Char | // OutlivesScalar + ty::Int(..) | // OutlivesScalar + ty::Uint(..) | // OutlivesScalar + ty::Float(..) | // OutlivesScalar + ty::Never | // ... + ty::Adt(..) | // OutlivesNominalType + ty::Anon(..) | // OutlivesNominalType (ish) + ty::Foreign(..) | // OutlivesNominalType + ty::Str | // OutlivesScalar (ish) + ty::Array(..) | // ... + ty::Slice(..) | // ... + ty::RawPtr(..) | // ... + ty::Ref(..) | // OutlivesReference + ty::Tuple(..) | // ... + ty::FnDef(..) | // OutlivesFunction (*) + ty::FnPtr(_) | // OutlivesFunction (*) + ty::Dynamic(..) | // OutlivesObject, OutlivesFragment (*) + ty::Error => { // (*) Bare functions and traits are both binders. In the // RFC, this means we would add the bound regions to the // "bound regions list". In our representation, no such diff --git a/src/librustc/ty/relate.rs b/src/librustc/ty/relate.rs index 4e8f33d6a4a03..d72e48c04fed4 100644 --- a/src/librustc/ty/relate.rs +++ b/src/librustc/ty/relate.rs @@ -316,7 +316,7 @@ impl<'tcx> Relate<'tcx> for ty::ExistentialTraitRef<'tcx> { } #[derive(Debug, Clone)] -struct GeneratorWitness<'tcx>(&'tcx ty::Slice>); +struct GeneratorWitness<'tcx>(&'tcx ty::List>); TupleStructTypeFoldableImpl! { impl<'tcx> TypeFoldable<'tcx> for GeneratorWitness<'tcx> { @@ -363,50 +363,50 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R, let b_sty = &b.sty; debug!("super_tys: a_sty={:?} b_sty={:?}", a_sty, b_sty); match (a_sty, b_sty) { - (&ty::TyInfer(_), _) | - (_, &ty::TyInfer(_)) => + (&ty::Infer(_), _) | + (_, &ty::Infer(_)) => { // The caller should handle these cases! bug!("var types encountered in super_relate_tys") } - (&ty::TyError, _) | (_, &ty::TyError) => + (&ty::Error, _) | (_, &ty::Error) => { Ok(tcx.types.err) } - (&ty::TyNever, _) | - (&ty::TyChar, _) | - (&ty::TyBool, _) | - (&ty::TyInt(_), _) | - (&ty::TyUint(_), _) | - (&ty::TyFloat(_), _) | - (&ty::TyStr, _) + (&ty::Never, _) | + (&ty::Char, _) | + (&ty::Bool, _) | + (&ty::Int(_), _) | + (&ty::Uint(_), _) | + (&ty::Float(_), _) | + (&ty::Str, _) if a == b => { Ok(a) } - (&ty::TyParam(ref a_p), &ty::TyParam(ref b_p)) + (&ty::Param(ref a_p), &ty::Param(ref b_p)) if a_p.idx == b_p.idx => { Ok(a) } - (&ty::TyAdt(a_def, a_substs), &ty::TyAdt(b_def, b_substs)) + (&ty::Adt(a_def, a_substs), &ty::Adt(b_def, b_substs)) if a_def == b_def => { let substs = relation.relate_item_substs(a_def.did, a_substs, b_substs)?; Ok(tcx.mk_adt(a_def, substs)) } - (&ty::TyForeign(a_id), &ty::TyForeign(b_id)) + (&ty::Foreign(a_id), &ty::Foreign(b_id)) if a_id == b_id => { Ok(tcx.mk_foreign(a_id)) } - (&ty::TyDynamic(ref a_obj, ref a_region), &ty::TyDynamic(ref b_obj, ref b_region)) => { + (&ty::Dynamic(ref a_obj, ref a_region), &ty::Dynamic(ref b_obj, ref b_region)) => { let region_bound = relation.with_cause(Cause::ExistentialRegionBound, |relation| { relation.relate_with_variance( @@ -417,18 +417,18 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R, Ok(tcx.mk_dynamic(relation.relate(a_obj, b_obj)?, region_bound)) } - (&ty::TyGenerator(a_id, a_substs, movability), - &ty::TyGenerator(b_id, b_substs, _)) + (&ty::Generator(a_id, a_substs, movability), + &ty::Generator(b_id, b_substs, _)) if a_id == b_id => { - // All TyGenerator types with the same id represent + // All Generator types with the same id represent // the (anonymous) type of the same generator expression. So // all of their regions should be equated. let substs = relation.relate(&a_substs, &b_substs)?; Ok(tcx.mk_generator(a_id, substs, movability)) } - (&ty::TyGeneratorWitness(a_types), &ty::TyGeneratorWitness(b_types)) => + (&ty::GeneratorWitness(a_types), &ty::GeneratorWitness(b_types)) => { // Wrap our types with a temporary GeneratorWitness struct // inside the binder so we can related them @@ -439,24 +439,24 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R, Ok(tcx.mk_generator_witness(types)) } - (&ty::TyClosure(a_id, a_substs), - &ty::TyClosure(b_id, b_substs)) + (&ty::Closure(a_id, a_substs), + &ty::Closure(b_id, b_substs)) if a_id == b_id => { - // All TyClosure types with the same id represent + // All Closure types with the same id represent // the (anonymous) type of the same closure expression. So // all of their regions should be equated. let substs = relation.relate(&a_substs, &b_substs)?; Ok(tcx.mk_closure(a_id, substs)) } - (&ty::TyRawPtr(ref a_mt), &ty::TyRawPtr(ref b_mt)) => + (&ty::RawPtr(ref a_mt), &ty::RawPtr(ref b_mt)) => { let mt = relation.relate(a_mt, b_mt)?; Ok(tcx.mk_ptr(mt)) } - (&ty::TyRef(a_r, a_ty, a_mutbl), &ty::TyRef(b_r, b_ty, b_mutbl)) => + (&ty::Ref(a_r, a_ty, a_mutbl), &ty::Ref(b_r, b_ty, b_mutbl)) => { let r = relation.relate_with_variance(ty::Contravariant, &a_r, &b_r)?; let a_mt = ty::TypeAndMut { ty: a_ty, mutbl: a_mutbl }; @@ -465,7 +465,7 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R, Ok(tcx.mk_ref(r, mt)) } - (&ty::TyArray(a_t, sz_a), &ty::TyArray(b_t, sz_b)) => + (&ty::Array(a_t, sz_a), &ty::Array(b_t, sz_b)) => { let t = relation.relate(&a_t, &b_t)?; assert_eq!(sz_a.ty, tcx.types.usize); @@ -514,26 +514,26 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R, match (to_u64(sz_a), to_u64(sz_b)) { (Ok(sz_a_u64), Ok(sz_b_u64)) => { if sz_a_u64 == sz_b_u64 { - Ok(tcx.mk_ty(ty::TyArray(t, sz_a))) + Ok(tcx.mk_ty(ty::Array(t, sz_a))) } else { Err(TypeError::FixedArraySize( expected_found(relation, &sz_a_u64, &sz_b_u64))) } } - // We reported an error or will ICE, so we can return TyError. + // We reported an error or will ICE, so we can return Error. (Err(ErrorReported), _) | (_, Err(ErrorReported)) => { Ok(tcx.types.err) } } } - (&ty::TySlice(a_t), &ty::TySlice(b_t)) => + (&ty::Slice(a_t), &ty::Slice(b_t)) => { let t = relation.relate(&a_t, &b_t)?; Ok(tcx.mk_slice(t)) } - (&ty::TyTuple(as_), &ty::TyTuple(bs)) => + (&ty::Tuple(as_), &ty::Tuple(bs)) => { if as_.len() == bs.len() { Ok(tcx.mk_tup(as_.iter().zip(bs).map(|(a, b)| relation.relate(a, b)))?) @@ -545,26 +545,26 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R, } } - (&ty::TyFnDef(a_def_id, a_substs), &ty::TyFnDef(b_def_id, b_substs)) + (&ty::FnDef(a_def_id, a_substs), &ty::FnDef(b_def_id, b_substs)) if a_def_id == b_def_id => { let substs = relation.relate_item_substs(a_def_id, a_substs, b_substs)?; Ok(tcx.mk_fn_def(a_def_id, substs)) } - (&ty::TyFnPtr(a_fty), &ty::TyFnPtr(b_fty)) => + (&ty::FnPtr(a_fty), &ty::FnPtr(b_fty)) => { let fty = relation.relate(&a_fty, &b_fty)?; Ok(tcx.mk_fn_ptr(fty)) } - (&ty::TyProjection(ref a_data), &ty::TyProjection(ref b_data)) => + (&ty::Projection(ref a_data), &ty::Projection(ref b_data)) => { let projection_ty = relation.relate(a_data, b_data)?; Ok(tcx.mk_projection(projection_ty.item_def_id, projection_ty.substs)) } - (&ty::TyAnon(a_def_id, a_substs), &ty::TyAnon(b_def_id, b_substs)) + (&ty::Anon(a_def_id, a_substs), &ty::Anon(b_def_id, b_substs)) if a_def_id == b_def_id => { let substs = relate_substs(relation, None, a_substs, b_substs)?; @@ -578,7 +578,7 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R, } } -impl<'tcx> Relate<'tcx> for &'tcx ty::Slice> { +impl<'tcx> Relate<'tcx> for &'tcx ty::List> { fn relate<'a, 'gcx, R>(relation: &mut R, a: &Self, b: &Self) diff --git a/src/librustc/ty/structural_impls.rs b/src/librustc/ty/structural_impls.rs index ad29f808285b1..09ec6c7913941 100644 --- a/src/librustc/ty/structural_impls.rs +++ b/src/librustc/ty/structural_impls.rs @@ -735,7 +735,7 @@ BraceStructTypeFoldableImpl! { impl<'tcx> TypeFoldable<'tcx> for ty::ParamEnv<'tcx> { reveal, caller_bounds } } -impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::Slice> { +impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List> { fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { let v = self.iter().map(|p| p.fold_with(folder)).collect::>(); folder.tcx().intern_existential_predicates(&v) @@ -754,7 +754,7 @@ EnumTypeFoldableImpl! { } } -impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::Slice> { +impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List> { fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { let v = self.iter().map(|t| t.fold_with(folder)).collect::>(); folder.tcx().intern_type_list(&v) @@ -836,33 +836,33 @@ impl<'tcx> TypeFoldable<'tcx> for interpret::GlobalId<'tcx> { impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> { fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { let sty = match self.sty { - ty::TyRawPtr(tm) => ty::TyRawPtr(tm.fold_with(folder)), - ty::TyArray(typ, sz) => ty::TyArray(typ.fold_with(folder), sz.fold_with(folder)), - ty::TySlice(typ) => ty::TySlice(typ.fold_with(folder)), - ty::TyAdt(tid, substs) => ty::TyAdt(tid, substs.fold_with(folder)), - ty::TyDynamic(ref trait_ty, ref region) => - ty::TyDynamic(trait_ty.fold_with(folder), region.fold_with(folder)), - ty::TyTuple(ts) => ty::TyTuple(ts.fold_with(folder)), - ty::TyFnDef(def_id, substs) => { - ty::TyFnDef(def_id, substs.fold_with(folder)) + ty::RawPtr(tm) => ty::RawPtr(tm.fold_with(folder)), + ty::Array(typ, sz) => ty::Array(typ.fold_with(folder), sz.fold_with(folder)), + ty::Slice(typ) => ty::Slice(typ.fold_with(folder)), + ty::Adt(tid, substs) => ty::Adt(tid, substs.fold_with(folder)), + ty::Dynamic(ref trait_ty, ref region) => + ty::Dynamic(trait_ty.fold_with(folder), region.fold_with(folder)), + ty::Tuple(ts) => ty::Tuple(ts.fold_with(folder)), + ty::FnDef(def_id, substs) => { + ty::FnDef(def_id, substs.fold_with(folder)) } - ty::TyFnPtr(f) => ty::TyFnPtr(f.fold_with(folder)), - ty::TyRef(ref r, ty, mutbl) => { - ty::TyRef(r.fold_with(folder), ty.fold_with(folder), mutbl) + ty::FnPtr(f) => ty::FnPtr(f.fold_with(folder)), + ty::Ref(ref r, ty, mutbl) => { + ty::Ref(r.fold_with(folder), ty.fold_with(folder), mutbl) } - ty::TyGenerator(did, substs, movability) => { - ty::TyGenerator( + ty::Generator(did, substs, movability) => { + ty::Generator( did, substs.fold_with(folder), movability) } - ty::TyGeneratorWitness(types) => ty::TyGeneratorWitness(types.fold_with(folder)), - ty::TyClosure(did, substs) => ty::TyClosure(did, substs.fold_with(folder)), - ty::TyProjection(ref data) => ty::TyProjection(data.fold_with(folder)), - ty::TyAnon(did, substs) => ty::TyAnon(did, substs.fold_with(folder)), - ty::TyBool | ty::TyChar | ty::TyStr | ty::TyInt(_) | - ty::TyUint(_) | ty::TyFloat(_) | ty::TyError | ty::TyInfer(_) | - ty::TyParam(..) | ty::TyNever | ty::TyForeign(..) => return self + ty::GeneratorWitness(types) => ty::GeneratorWitness(types.fold_with(folder)), + ty::Closure(did, substs) => ty::Closure(did, substs.fold_with(folder)), + ty::Projection(ref data) => ty::Projection(data.fold_with(folder)), + ty::Anon(did, substs) => ty::Anon(did, substs.fold_with(folder)), + ty::Bool | ty::Char | ty::Str | ty::Int(_) | + ty::Uint(_) | ty::Float(_) | ty::Error | ty::Infer(_) | + ty::Param(..) | ty::Never | ty::Foreign(..) => return self }; if self.sty == sty { @@ -878,26 +878,26 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> { fn super_visit_with>(&self, visitor: &mut V) -> bool { match self.sty { - ty::TyRawPtr(ref tm) => tm.visit_with(visitor), - ty::TyArray(typ, sz) => typ.visit_with(visitor) || sz.visit_with(visitor), - ty::TySlice(typ) => typ.visit_with(visitor), - ty::TyAdt(_, substs) => substs.visit_with(visitor), - ty::TyDynamic(ref trait_ty, ref reg) => + ty::RawPtr(ref tm) => tm.visit_with(visitor), + ty::Array(typ, sz) => typ.visit_with(visitor) || sz.visit_with(visitor), + ty::Slice(typ) => typ.visit_with(visitor), + ty::Adt(_, substs) => substs.visit_with(visitor), + ty::Dynamic(ref trait_ty, ref reg) => trait_ty.visit_with(visitor) || reg.visit_with(visitor), - ty::TyTuple(ts) => ts.visit_with(visitor), - ty::TyFnDef(_, substs) => substs.visit_with(visitor), - ty::TyFnPtr(ref f) => f.visit_with(visitor), - ty::TyRef(r, ty, _) => r.visit_with(visitor) || ty.visit_with(visitor), - ty::TyGenerator(_did, ref substs, _) => { + ty::Tuple(ts) => ts.visit_with(visitor), + ty::FnDef(_, substs) => substs.visit_with(visitor), + ty::FnPtr(ref f) => f.visit_with(visitor), + ty::Ref(r, ty, _) => r.visit_with(visitor) || ty.visit_with(visitor), + ty::Generator(_did, ref substs, _) => { substs.visit_with(visitor) } - ty::TyGeneratorWitness(ref types) => types.visit_with(visitor), - ty::TyClosure(_did, ref substs) => substs.visit_with(visitor), - ty::TyProjection(ref data) => data.visit_with(visitor), - ty::TyAnon(_, ref substs) => substs.visit_with(visitor), - ty::TyBool | ty::TyChar | ty::TyStr | ty::TyInt(_) | - ty::TyUint(_) | ty::TyFloat(_) | ty::TyError | ty::TyInfer(_) | - ty::TyParam(..) | ty::TyNever | ty::TyForeign(..) => false, + ty::GeneratorWitness(ref types) => types.visit_with(visitor), + ty::Closure(_did, ref substs) => substs.visit_with(visitor), + ty::Projection(ref data) => data.visit_with(visitor), + ty::Anon(_, ref substs) => substs.visit_with(visitor), + ty::Bool | ty::Char | ty::Str | ty::Int(_) | + ty::Uint(_) | ty::Float(_) | ty::Error | ty::Infer(_) | + ty::Param(..) | ty::Never | ty::Foreign(..) => false, } } @@ -1010,7 +1010,7 @@ BraceStructTypeFoldableImpl! { } } -impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::Slice> { +impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List> { fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { let v = self.iter().map(|p| p.fold_with(folder)).collect::>(); folder.tcx().intern_predicates(&v) diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index 7c0857cd2f998..7c7ee9b330ecc 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -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; @@ -18,7 +18,7 @@ use polonius_engine::Atom; use rustc_data_structures::indexed_vec::Idx; use ty::subst::{Substs, Subst, Kind, UnpackedKind}; use ty::{self, AdtDef, TypeFlags, Ty, TyCtxt, TypeFoldable}; -use ty::{Slice, TyS, ParamEnvAnd, ParamEnv}; +use ty::{List, TyS, ParamEnvAnd, ParamEnv}; use util::captures::Captures; use mir::interpret::{Scalar, Pointer}; @@ -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> { @@ -82,80 +82,80 @@ 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, + Bool, /// The primitive character type; holds a Unicode scalar value /// (a non-surrogate code point). Written as `char`. - TyChar, + Char, /// A primitive signed integer type. For example, `i32`. - TyInt(ast::IntTy), + Int(ast::IntTy), /// A primitive unsigned integer type. For example, `u32`. - TyUint(ast::UintTy), + Uint(ast::UintTy), /// A primitive floating-point type. For example, `f64`. - TyFloat(ast::FloatTy), + Float(ast::FloatTy), /// Structures, enumerations and unions. /// - /// Substs here, possibly against intuition, *may* contain `TyParam`s. + /// Substs here, possibly against intuition, *may* contain `Param`s. /// That is, even after substitution it is possible that there are type - /// variables. This happens when the `TyAdt` corresponds to an ADT + /// variables. This happens when the `Adt` corresponds to an ADT /// definition and not a concrete use of it. - TyAdt(&'tcx AdtDef, &'tcx Substs<'tcx>), + Adt(&'tcx AdtDef, &'tcx Substs<'tcx>), - TyForeign(DefId), + Foreign(DefId), /// The pointee of a string slice. Written as `str`. - TyStr, + Str, /// An array with the given length. Written as `[T; n]`. - TyArray(Ty<'tcx>, &'tcx ty::Const<'tcx>), + Array(Ty<'tcx>, &'tcx ty::Const<'tcx>), /// The pointee of an array slice. Written as `[T]`. - TySlice(Ty<'tcx>), + Slice(Ty<'tcx>), /// A raw pointer. Written as `*mut T` or `*const T` - TyRawPtr(TypeAndMut<'tcx>), + RawPtr(TypeAndMut<'tcx>), /// A reference; a pointer with an associated lifetime. Written as /// `&'a mut T` or `&'a T`. - TyRef(Region<'tcx>, Ty<'tcx>, hir::Mutability), + Ref(Region<'tcx>, Ty<'tcx>, hir::Mutability), /// The anonymous type of a function declaration/definition. Each /// function has a unique type. - TyFnDef(DefId, &'tcx Substs<'tcx>), + FnDef(DefId, &'tcx Substs<'tcx>), /// A pointer to a function. Written as `fn() -> i32`. - TyFnPtr(PolyFnSig<'tcx>), + FnPtr(PolyFnSig<'tcx>), /// A trait, defined with `trait`. - TyDynamic(Binder<&'tcx Slice>>, ty::Region<'tcx>), + Dynamic(Binder<&'tcx List>>, ty::Region<'tcx>), /// The anonymous type of a closure. Used to represent the type of /// `|a| a`. - TyClosure(DefId, ClosureSubsts<'tcx>), + Closure(DefId, ClosureSubsts<'tcx>), /// The anonymous type of a generator. Used to represent the type of /// `|a| yield a`. - TyGenerator(DefId, GeneratorSubsts<'tcx>, hir::GeneratorMovability), + Generator(DefId, GeneratorSubsts<'tcx>, hir::GeneratorMovability), /// A type representin the types stored inside a generator. /// This should only appear in GeneratorInteriors. - TyGeneratorWitness(Binder<&'tcx Slice>>), + GeneratorWitness(Binder<&'tcx List>>), /// The never type `!` - TyNever, + Never, /// A tuple type. For example, `(i32, bool)`. - TyTuple(&'tcx Slice>), + Tuple(&'tcx List>), /// The projection of an associated type. For example, /// `>::N`. - TyProjection(ProjectionTy<'tcx>), + Projection(ProjectionTy<'tcx>), /// Anonymized (`impl Trait`) type found in a return type. /// The DefId comes either from @@ -163,17 +163,17 @@ pub enum TypeVariants<'tcx> { /// * or the `existential type` declaration /// The substitutions are for the generics of the function in question. /// After typeck, the concrete type can be found in the `types` map. - TyAnon(DefId, &'tcx Substs<'tcx>), + Anon(DefId, &'tcx Substs<'tcx>), /// A type parameter; for example, `T` in `fn f(x: T) {} - TyParam(ParamTy), + Param(ParamTy), /// A type variable used during type-checking. - TyInfer(InferTy), + Infer(InferTy), /// A placeholder for a type which could not be computed; this is /// propagated to avoid useless error messages. - TyError, + Error, } /// A closure can be modeled as a struct that looks like: @@ -348,7 +348,7 @@ impl<'tcx> ClosureSubsts<'tcx> { /// If you have an inference context, use `infcx.closure_sig()`. pub fn closure_sig(self, def_id: DefId, tcx: TyCtxt<'_, 'tcx, 'tcx>) -> ty::PolyFnSig<'tcx> { match self.closure_sig_ty(def_id, tcx).sty { - ty::TyFnPtr(sig) => sig, + ty::FnPtr(sig) => sig, ref t => bug!("closure_sig_ty is not a fn-ptr: {:?}", t), } } @@ -536,9 +536,9 @@ impl<'a, 'gcx, 'tcx> Binder> { } } -impl<'tcx> serialize::UseSpecializedDecodable for &'tcx Slice> {} +impl<'tcx> serialize::UseSpecializedDecodable for &'tcx List> {} -impl<'tcx> Slice> { +impl<'tcx> List> { pub fn principal(&self) -> Option> { match self.get(0) { Some(&ExistentialPredicate::Trait(tr)) => Some(tr), @@ -568,7 +568,7 @@ impl<'tcx> Slice> { } } -impl<'tcx> Binder<&'tcx Slice>> { +impl<'tcx> Binder<&'tcx List>> { pub fn principal(&self) -> Option> { self.skip_binder().principal().map(Binder::bind) } @@ -918,7 +918,7 @@ impl<'tcx> PolyGenSig<'tcx> { /// - `variadic` indicates whether this is a variadic function. (only true for foreign fns) #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)] pub struct FnSig<'tcx> { - pub inputs_and_output: &'tcx Slice>, + pub inputs_and_output: &'tcx List>, pub variadic: bool, pub unsafety: hir::Unsafety, pub abi: abi::Abi, @@ -943,7 +943,7 @@ impl<'tcx> PolyFnSig<'tcx> { pub fn input(&self, index: usize) -> ty::Binder> { self.map_bound_ref(|fn_sig| fn_sig.inputs()[index]) } - pub fn inputs_and_output(&self) -> ty::Binder<&'tcx Slice>> { + pub fn inputs_and_output(&self) -> ty::Binder<&'tcx List>> { self.map_bound_ref(|fn_sig| fn_sig.inputs_and_output) } pub fn output(&self) -> ty::Binder> { @@ -1058,7 +1058,7 @@ pub type Region<'tcx> = &'tcx RegionKind; /// the likes of `liberate_late_bound_regions`. The distinction exists /// because higher-ranked lifetimes aren't supported in all places. See [1][2]. /// -/// Unlike TyParam-s, bound regions are not supposed to exist "in the wild" +/// Unlike Param-s, bound regions are not supposed to exist "in the wild" /// outside their binder, e.g. in types passed to type inference, and /// should first be substituted (by skolemized regions, free regions, /// or region variables). @@ -1469,67 +1469,67 @@ impl RegionKind { impl<'a, 'gcx, 'tcx> TyS<'tcx> { pub fn is_nil(&self) -> bool { match self.sty { - TyTuple(ref tys) => tys.is_empty(), + Tuple(ref tys) => tys.is_empty(), _ => false, } } pub fn is_never(&self) -> bool { match self.sty { - TyNever => true, + Never => true, _ => false, } } pub fn is_primitive(&self) -> bool { match self.sty { - TyBool | TyChar | TyInt(_) | TyUint(_) | TyFloat(_) => true, + Bool | Char | Int(_) | Uint(_) | Float(_) => true, _ => false, } } pub fn is_ty_var(&self) -> bool { match self.sty { - TyInfer(TyVar(_)) => true, + Infer(TyVar(_)) => true, _ => false, } } pub fn is_ty_infer(&self) -> bool { match self.sty { - TyInfer(_) => true, + Infer(_) => true, _ => false, } } pub fn is_phantom_data(&self) -> bool { - if let TyAdt(def, _) = self.sty { + if let Adt(def, _) = self.sty { def.is_phantom_data() } else { false } } - pub fn is_bool(&self) -> bool { self.sty == TyBool } + pub fn is_bool(&self) -> bool { self.sty == Bool } pub fn is_param(&self, index: u32) -> bool { match self.sty { - ty::TyParam(ref data) => data.idx == index, + ty::Param(ref data) => data.idx == index, _ => false, } } pub fn is_self(&self) -> bool { match self.sty { - TyParam(ref p) => p.is_self(), + Param(ref p) => p.is_self(), _ => false, } } pub fn is_slice(&self) -> bool { match self.sty { - TyRawPtr(TypeAndMut { ty, .. }) | TyRef(_, ty, _) => match ty.sty { - TySlice(_) | TyStr => true, + RawPtr(TypeAndMut { ty, .. }) | Ref(_, ty, _) => match ty.sty { + Slice(_) | Str => true, _ => false, }, _ => false @@ -1539,22 +1539,22 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> { #[inline] pub fn is_simd(&self) -> bool { match self.sty { - TyAdt(def, _) => def.repr.simd(), + Adt(def, _) => def.repr.simd(), _ => false, } } pub fn sequence_element_type(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx> { match self.sty { - TyArray(ty, _) | TySlice(ty) => ty, - TyStr => tcx.mk_mach_uint(ast::UintTy::U8), + Array(ty, _) | Slice(ty) => ty, + Str => tcx.mk_mach_uint(ast::UintTy::U8), _ => bug!("sequence_element_type called on non-sequence value: {}", self), } } pub fn simd_type(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx> { match self.sty { - TyAdt(def, substs) => { + Adt(def, substs) => { def.non_enum_variant().fields[0].ty(tcx, substs) } _ => bug!("simd_type called on invalid type") @@ -1563,36 +1563,36 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> { pub fn simd_size(&self, _cx: TyCtxt) -> usize { match self.sty { - TyAdt(def, _) => def.non_enum_variant().fields.len(), + Adt(def, _) => def.non_enum_variant().fields.len(), _ => bug!("simd_size called on invalid type") } } pub fn is_region_ptr(&self) -> bool { match self.sty { - TyRef(..) => true, + Ref(..) => true, _ => false, } } pub fn is_mutable_pointer(&self) -> bool { match self.sty { - TyRawPtr(TypeAndMut { mutbl: hir::Mutability::MutMutable, .. }) | - TyRef(_, _, hir::Mutability::MutMutable) => true, + RawPtr(TypeAndMut { mutbl: hir::Mutability::MutMutable, .. }) | + Ref(_, _, hir::Mutability::MutMutable) => true, _ => false } } pub fn is_unsafe_ptr(&self) -> bool { match self.sty { - TyRawPtr(_) => return true, + RawPtr(_) => return true, _ => return false, } } pub fn is_box(&self) -> bool { match self.sty { - TyAdt(def, _) => def.is_box(), + Adt(def, _) => def.is_box(), _ => false, } } @@ -1600,19 +1600,19 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> { /// panics if called on any type other than `Box` pub fn boxed_ty(&self) -> Ty<'tcx> { match self.sty { - TyAdt(def, substs) if def.is_box() => substs.type_at(0), + Adt(def, substs) if def.is_box() => substs.type_at(0), _ => bug!("`boxed_ty` is called on non-box type {:?}", self), } } /// A scalar type is one that denotes an atomic datum, with no sub-components. - /// (A TyRawPtr is scalar because it represents a non-managed pointer, so its + /// (A RawPtr is scalar because it represents a non-managed pointer, so its /// contents are abstract to rustc.) pub fn is_scalar(&self) -> bool { match self.sty { - TyBool | TyChar | TyInt(_) | TyFloat(_) | TyUint(_) | - TyInfer(IntVar(_)) | TyInfer(FloatVar(_)) | - TyFnDef(..) | TyFnPtr(_) | TyRawPtr(_) => true, + Bool | Char | Int(_) | Float(_) | Uint(_) | + Infer(IntVar(_)) | Infer(FloatVar(_)) | + FnDef(..) | FnPtr(_) | RawPtr(_) => true, _ => false } } @@ -1620,22 +1620,22 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> { /// Returns true if this type is a floating point type and false otherwise. pub fn is_floating_point(&self) -> bool { match self.sty { - TyFloat(_) | - TyInfer(FloatVar(_)) => true, + Float(_) | + Infer(FloatVar(_)) => true, _ => false, } } pub fn is_trait(&self) -> bool { match self.sty { - TyDynamic(..) => true, + Dynamic(..) => true, _ => false, } } pub fn is_enum(&self) -> bool { match self.sty { - TyAdt(adt_def, _) => { + Adt(adt_def, _) => { adt_def.is_enum() } _ => false, @@ -1644,51 +1644,51 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> { pub fn is_closure(&self) -> bool { match self.sty { - TyClosure(..) => true, + Closure(..) => true, _ => false, } } pub fn is_generator(&self) -> bool { match self.sty { - TyGenerator(..) => true, + Generator(..) => true, _ => false, } } pub fn is_integral(&self) -> bool { match self.sty { - TyInfer(IntVar(_)) | TyInt(_) | TyUint(_) => true, + Infer(IntVar(_)) | Int(_) | Uint(_) => true, _ => false } } pub fn is_fresh_ty(&self) -> bool { match self.sty { - TyInfer(FreshTy(_)) => true, + Infer(FreshTy(_)) => true, _ => false, } } pub fn is_fresh(&self) -> bool { match self.sty { - TyInfer(FreshTy(_)) => true, - TyInfer(FreshIntTy(_)) => true, - TyInfer(FreshFloatTy(_)) => true, + Infer(FreshTy(_)) => true, + Infer(FreshIntTy(_)) => true, + Infer(FreshFloatTy(_)) => true, _ => false, } } pub fn is_char(&self) -> bool { match self.sty { - TyChar => true, + Char => true, _ => false, } } pub fn is_fp(&self) -> bool { match self.sty { - TyInfer(FloatVar(_)) | TyFloat(_) => true, + Infer(FloatVar(_)) | Float(_) => true, _ => false } } @@ -1699,22 +1699,22 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> { pub fn is_signed(&self) -> bool { match self.sty { - TyInt(_) => true, + Int(_) => true, _ => false, } } pub fn is_machine(&self) -> bool { match self.sty { - TyInt(ast::IntTy::Isize) | TyUint(ast::UintTy::Usize) => false, - TyInt(..) | TyUint(..) | TyFloat(..) => true, + Int(ast::IntTy::Isize) | Uint(ast::UintTy::Usize) => false, + Int(..) | Uint(..) | Float(..) => true, _ => false, } } pub fn has_concrete_skeleton(&self) -> bool { match self.sty { - TyParam(_) | TyInfer(_) | TyError => false, + Param(_) | Infer(_) | Error => false, _ => true, } } @@ -1725,14 +1725,14 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> { /// Some types---notably unsafe ptrs---can only be dereferenced explicitly. pub fn builtin_deref(&self, explicit: bool) -> Option> { match self.sty { - TyAdt(def, _) if def.is_box() => { + Adt(def, _) if def.is_box() => { Some(TypeAndMut { ty: self.boxed_ty(), mutbl: hir::MutImmutable, }) }, - TyRef(_, ty, mutbl) => Some(TypeAndMut { ty, mutbl }), - TyRawPtr(mt) if explicit => Some(mt), + Ref(_, ty, mutbl) => Some(TypeAndMut { ty, mutbl }), + RawPtr(mt) if explicit => Some(mt), _ => None, } } @@ -1740,38 +1740,38 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> { /// Returns the type of `ty[i]`. pub fn builtin_index(&self) -> Option> { match self.sty { - TyArray(ty, _) | TySlice(ty) => Some(ty), + Array(ty, _) | Slice(ty) => Some(ty), _ => None, } } pub fn fn_sig(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> PolyFnSig<'tcx> { match self.sty { - TyFnDef(def_id, substs) => { + FnDef(def_id, substs) => { tcx.fn_sig(def_id).subst(tcx, substs) } - TyFnPtr(f) => f, + FnPtr(f) => f, _ => bug!("Ty::fn_sig() called on non-fn type: {:?}", self) } } pub fn is_fn(&self) -> bool { match self.sty { - TyFnDef(..) | TyFnPtr(_) => true, + FnDef(..) | FnPtr(_) => true, _ => false, } } pub fn is_impl_trait(&self) -> bool { match self.sty { - TyAnon(..) => true, + Anon(..) => true, _ => false, } } pub fn ty_adt_def(&self) -> Option<&'tcx AdtDef> { match self.sty { - TyAdt(adt, _) => Some(adt), + Adt(adt, _) => Some(adt), _ => None, } } @@ -1781,44 +1781,44 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> { /// ignores late-bound regions binders. pub fn regions(&self) -> Vec> { match self.sty { - TyRef(region, _, _) => { + Ref(region, _, _) => { vec![region] } - TyDynamic(ref obj, region) => { + Dynamic(ref obj, region) => { let mut v = vec![region]; if let Some(p) = obj.principal() { v.extend(p.skip_binder().substs.regions()); } v } - TyAdt(_, substs) | TyAnon(_, substs) => { + Adt(_, substs) | Anon(_, substs) => { substs.regions().collect() } - TyClosure(_, ClosureSubsts { ref substs }) | - TyGenerator(_, GeneratorSubsts { ref substs }, _) => { + Closure(_, ClosureSubsts { ref substs }) | + Generator(_, GeneratorSubsts { ref substs }, _) => { substs.regions().collect() } - TyProjection(ref data) => { + Projection(ref data) => { data.substs.regions().collect() } - TyFnDef(..) | - TyFnPtr(_) | - TyGeneratorWitness(..) | - TyBool | - TyChar | - TyInt(_) | - TyUint(_) | - TyFloat(_) | - TyStr | - TyArray(..) | - TySlice(_) | - TyRawPtr(_) | - TyNever | - TyTuple(..) | - TyForeign(..) | - TyParam(_) | - TyInfer(_) | - TyError => { + FnDef(..) | + FnPtr(_) | + GeneratorWitness(..) | + Bool | + Char | + Int(_) | + Uint(_) | + Float(_) | + Str | + Array(..) | + Slice(_) | + RawPtr(_) | + Never | + Tuple(..) | + Foreign(..) | + Param(_) | + Infer(_) | + Error => { vec![] } } @@ -1838,16 +1838,16 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> { /// is complete, that type variable will be unified. pub fn to_opt_closure_kind(&self) -> Option { match self.sty { - TyInt(int_ty) => match int_ty { + Int(int_ty) => match int_ty { ast::IntTy::I8 => Some(ty::ClosureKind::Fn), ast::IntTy::I16 => Some(ty::ClosureKind::FnMut), ast::IntTy::I32 => Some(ty::ClosureKind::FnOnce), _ => bug!("cannot convert type `{:?}` to a closure kind", self), }, - TyInfer(_) => None, + Infer(_) => None, - TyError => Some(ty::ClosureKind::Fn), + Error => Some(ty::ClosureKind::Fn), _ => bug!("cannot convert type `{:?}` to a closure kind", self), } @@ -1859,31 +1859,31 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> { /// `false` means nothing -- could be sized, might not be. pub fn is_trivially_sized(&self, tcx: TyCtxt<'_, '_, 'tcx>) -> bool { match self.sty { - ty::TyInfer(ty::IntVar(_)) | ty::TyInfer(ty::FloatVar(_)) | - ty::TyUint(_) | ty::TyInt(_) | ty::TyBool | ty::TyFloat(_) | - ty::TyFnDef(..) | ty::TyFnPtr(_) | ty::TyRawPtr(..) | - ty::TyChar | ty::TyRef(..) | ty::TyGenerator(..) | - ty::TyGeneratorWitness(..) | ty::TyArray(..) | ty::TyClosure(..) | - ty::TyNever | ty::TyError => + ty::Infer(ty::IntVar(_)) | ty::Infer(ty::FloatVar(_)) | + ty::Uint(_) | ty::Int(_) | ty::Bool | ty::Float(_) | + ty::FnDef(..) | ty::FnPtr(_) | ty::RawPtr(..) | + ty::Char | ty::Ref(..) | ty::Generator(..) | + ty::GeneratorWitness(..) | ty::Array(..) | ty::Closure(..) | + ty::Never | ty::Error => true, - ty::TyStr | ty::TySlice(_) | ty::TyDynamic(..) | ty::TyForeign(..) => + ty::Str | ty::Slice(_) | ty::Dynamic(..) | ty::Foreign(..) => false, - ty::TyTuple(tys) => + ty::Tuple(tys) => tys.iter().all(|ty| ty.is_trivially_sized(tcx)), - ty::TyAdt(def, _substs) => + ty::Adt(def, _substs) => def.sized_constraint(tcx).is_empty(), - ty::TyProjection(_) | ty::TyParam(_) | ty::TyAnon(..) => false, + ty::Projection(_) | ty::Param(_) | ty::Anon(..) => false, - ty::TyInfer(ty::TyVar(_)) => false, + ty::Infer(ty::TyVar(_)) => false, - ty::TyInfer(ty::CanonicalTy(_)) | - ty::TyInfer(ty::FreshTy(_)) | - ty::TyInfer(ty::FreshIntTy(_)) | - ty::TyInfer(ty::FreshFloatTy(_)) => + ty::Infer(ty::CanonicalTy(_)) | + ty::Infer(ty::FreshTy(_)) | + ty::Infer(ty::FreshIntTy(_)) | + ty::Infer(ty::FreshFloatTy(_)) => bug!("is_trivially_sized applied to unexpected type: {:?}", self), } } diff --git a/src/librustc/ty/subst.rs b/src/librustc/ty/subst.rs index a6ff979f472af..0e85c68b8b1de 100644 --- a/src/librustc/ty/subst.rs +++ b/src/librustc/ty/subst.rs @@ -11,7 +11,7 @@ // Type substitutions. use hir::def_id::DefId; -use ty::{self, Lift, Slice, Ty, TyCtxt}; +use ty::{self, Lift, List, Ty, TyCtxt}; use ty::fold::{TypeFoldable, TypeFolder, TypeVisitor}; use serialize::{self, Encodable, Encoder, Decodable, Decoder}; @@ -177,7 +177,7 @@ impl<'tcx> Decodable for Kind<'tcx> { } /// A substitution mapping generic parameters to new values. -pub type Substs<'tcx> = Slice>; +pub type Substs<'tcx> = List>; impl<'a, 'gcx, 'tcx> Substs<'tcx> { /// Creates a Substs that maps each generic parameter to itself. @@ -449,7 +449,7 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for SubstFolder<'a, 'gcx, 'tcx> { self.ty_stack_depth += 1; let t1 = match t.sty { - ty::TyParam(p) => { + ty::Param(p) => { self.ty_for_param(p, t) } _ => { diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs index 95caa0c185be1..938cdf3048b1c 100644 --- a/src/librustc/ty/util.rs +++ b/src/librustc/ty/util.rs @@ -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; @@ -41,7 +41,7 @@ pub struct Discr<'tcx> { impl<'tcx> fmt::Display for Discr<'tcx> { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { match self.ty.sty { - ty::TyInt(ity) => { + ty::Int(ity) => { let bits = ty::tls::with(|tcx| { Integer::from_attr(tcx, SignedInt(ity)).size().bits() }); @@ -62,8 +62,8 @@ impl<'tcx> Discr<'tcx> { } pub fn checked_add<'a, 'gcx>(self, tcx: TyCtxt<'a, 'gcx, 'tcx>, n: u128) -> (Self, bool) { let (int, signed) = match self.ty.sty { - TyInt(ity) => (Integer::from_attr(tcx, SignedInt(ity)), true), - TyUint(uty) => (Integer::from_attr(tcx, UnsignedInt(uty)), false), + Int(ity) => (Integer::from_attr(tcx, SignedInt(ity)), true), + Uint(uty) => (Integer::from_attr(tcx, UnsignedInt(uty)), false), _ => bug!("non integer discriminant"), }; @@ -193,11 +193,11 @@ impl<'tcx> ty::ParamEnv<'tcx> { let (adt, substs) = match self_type.sty { // These types used to have a builtin impl. // Now libcore provides that impl. - ty::TyUint(_) | ty::TyInt(_) | ty::TyBool | ty::TyFloat(_) | - ty::TyChar | ty::TyRawPtr(..) | ty::TyNever | - ty::TyRef(_, _, hir::MutImmutable) => return Ok(()), + ty::Uint(_) | ty::Int(_) | ty::Bool | ty::Float(_) | + ty::Char | ty::RawPtr(..) | ty::Never | + ty::Ref(_, _, hir::MutImmutable) => return Ok(()), - ty::TyAdt(adt, substs) => (adt, substs), + ty::Adt(adt, substs) => (adt, substs), _ => return Err(CopyImplementationError::NotAnAdt), }; @@ -258,10 +258,10 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn has_error_field(self, ty: Ty<'tcx>) -> bool { match ty.sty { - ty::TyAdt(def, substs) => { + ty::Adt(def, substs) => { for field in def.all_fields() { let field_ty = field.ty(self, substs); - if let TyError = field_ty.sty { + if let Error = field_ty.sty { return true; } } @@ -277,7 +277,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn struct_tail(self, mut ty: Ty<'tcx>) -> Ty<'tcx> { loop { match ty.sty { - ty::TyAdt(def, substs) => { + ty::Adt(def, substs) => { if !def.is_struct() { break; } @@ -287,7 +287,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } } - ty::TyTuple(tys) => { + ty::Tuple(tys) => { if let Some((&last_ty, _)) = tys.split_last() { ty = last_ty; } else { @@ -315,7 +315,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { let (mut a, mut b) = (source, target); loop { match (&a.sty, &b.sty) { - (&TyAdt(a_def, a_substs), &TyAdt(b_def, b_substs)) + (&Adt(a_def, a_substs), &Adt(b_def, b_substs)) if a_def == b_def && a_def.is_struct() => { if let Some(f) = a_def.non_enum_variant().fields.last() { a = f.ty(self, a_substs); @@ -324,7 +324,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { break; } }, - (&TyTuple(a_tys), &TyTuple(b_tys)) + (&Tuple(a_tys), &Tuple(b_tys)) if a_tys.len() == b_tys.len() => { if let Some(a_last) = a_tys.last() { a = a_last; @@ -487,12 +487,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { // parameters marked as pure. let impl_substs = match self.type_of(impl_def_id).sty { - ty::TyAdt(def_, substs) if def_ == def => substs, + ty::Adt(def_, substs) if def_ == def => substs, _ => bug!() }; let item_substs = match self.type_of(def.did).sty { - ty::TyAdt(def_, substs) if def_ == def => substs, + ty::Adt(def_, substs) if def_ == def => substs, _ => bug!() }; @@ -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::Param(ref pt), .. }) => { !impl_generics.type_param(pt, self).pure_wrt_drop } @@ -697,7 +697,7 @@ impl<'a, 'tcx> ty::TyS<'tcx> { -> Representability { match ty.sty { - TyTuple(ref ts) => { + Tuple(ref ts) => { // Find non representable fold_repr(ts.iter().map(|ty| { is_type_structurally_recursive(tcx, sp, seen, representable_cache, ty) @@ -705,10 +705,10 @@ impl<'a, 'tcx> ty::TyS<'tcx> { } // Fixed-length vectors. // FIXME(#11924) Behavior undecided for zero-length vectors. - TyArray(ty, _) => { + Array(ty, _) => { is_type_structurally_recursive(tcx, sp, seen, representable_cache, ty) } - TyAdt(def, substs) => { + Adt(def, substs) => { // Find non representable fields with their spans fold_repr(def.all_fields().map(|field| { let ty = field.ty(tcx, substs); @@ -723,7 +723,7 @@ impl<'a, 'tcx> ty::TyS<'tcx> { } })) } - TyClosure(..) => { + Closure(..) => { // this check is run on type definitions, so we don't expect // to see closure types bug!("requires check invoked on inapplicable type: {:?}", ty) @@ -734,7 +734,7 @@ impl<'a, 'tcx> ty::TyS<'tcx> { fn same_struct_or_enum<'tcx>(ty: Ty<'tcx>, def: &'tcx ty::AdtDef) -> bool { match ty.sty { - TyAdt(ty_def, _) => { + Adt(ty_def, _) => { ty_def == def } _ => false @@ -743,7 +743,7 @@ impl<'a, 'tcx> ty::TyS<'tcx> { fn same_type<'tcx>(a: Ty<'tcx>, b: Ty<'tcx>) -> bool { match (&a.sty, &b.sty) { - (&TyAdt(did_a, substs_a), &TyAdt(did_b, substs_b)) => { + (&Adt(did_a, substs_a), &Adt(did_b, substs_b)) => { if did_a != did_b { return false; } @@ -785,7 +785,7 @@ impl<'a, 'tcx> ty::TyS<'tcx> { ty: Ty<'tcx>) -> Representability { match ty.sty { - TyAdt(def, _) => { + Adt(def, _) => { { // Iterate through stack of previously seen types. let mut iter = seen.iter(); @@ -924,16 +924,16 @@ fn needs_drop_raw<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, match ty.sty { // Fast-path for primitive types - ty::TyInfer(ty::FreshIntTy(_)) | ty::TyInfer(ty::FreshFloatTy(_)) | - ty::TyBool | ty::TyInt(_) | ty::TyUint(_) | ty::TyFloat(_) | ty::TyNever | - ty::TyFnDef(..) | ty::TyFnPtr(_) | ty::TyChar | ty::TyGeneratorWitness(..) | - ty::TyRawPtr(_) | ty::TyRef(..) | ty::TyStr => false, + ty::Infer(ty::FreshIntTy(_)) | ty::Infer(ty::FreshFloatTy(_)) | + ty::Bool | ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::Never | + ty::FnDef(..) | ty::FnPtr(_) | ty::Char | ty::GeneratorWitness(..) | + ty::RawPtr(_) | ty::Ref(..) | ty::Str => false, // Foreign types can never have destructors - ty::TyForeign(..) => false, + ty::Foreign(..) => false, // `ManuallyDrop` doesn't have a destructor regardless of field types. - ty::TyAdt(def, _) if Some(def.did) == tcx.lang_items().manually_drop() => false, + ty::Adt(def, _) if Some(def.did) == tcx.lang_items().manually_drop() => false, // Issue #22536: We first query type_moves_by_default. It sees a // normalized version of the type, and therefore will definitely @@ -951,30 +951,30 @@ fn needs_drop_raw<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, // (see above), it is sound to treat it as having a destructor. // User destructors are the only way to have concrete drop types. - ty::TyAdt(def, _) if def.has_dtor(tcx) => true, + ty::Adt(def, _) if def.has_dtor(tcx) => true, // Can refer to a type which may drop. // FIXME(eddyb) check this against a ParamEnv. - ty::TyDynamic(..) | ty::TyProjection(..) | ty::TyParam(_) | - ty::TyAnon(..) | ty::TyInfer(_) | ty::TyError => true, + ty::Dynamic(..) | ty::Projection(..) | ty::Param(_) | + ty::Anon(..) | ty::Infer(_) | ty::Error => true, // Structural recursion. - ty::TyArray(ty, _) | ty::TySlice(ty) => needs_drop(ty), + ty::Array(ty, _) | ty::Slice(ty) => needs_drop(ty), - ty::TyClosure(def_id, ref substs) => substs.upvar_tys(def_id, tcx).any(needs_drop), + ty::Closure(def_id, ref substs) => substs.upvar_tys(def_id, tcx).any(needs_drop), // Pessimistically assume that all generators will require destructors // as we don't know if a destructor is a noop or not until after the MIR // state transformation pass - ty::TyGenerator(..) => true, + ty::Generator(..) => true, - ty::TyTuple(ref tys) => tys.iter().cloned().any(needs_drop), + ty::Tuple(ref tys) => tys.iter().cloned().any(needs_drop), // unions don't have destructors because of the child types, // only if they manually implement `Drop` (handled above). - ty::TyAdt(def, _) if def.is_union() => false, + ty::Adt(def, _) if def.is_union() => false, - ty::TyAdt(def, substs) => + ty::Adt(def, substs) => def.variants.iter().any( |variant| variant.fields.iter().any( |field| needs_drop(field.ty(tcx, substs)))), @@ -1025,13 +1025,13 @@ impl<'tcx> ExplicitSelf<'tcx> { match self_arg_ty.sty { _ if is_self_ty(self_arg_ty) => ByValue, - ty::TyRef(region, ty, mutbl) if is_self_ty(ty) => { + ty::Ref(region, ty, mutbl) if is_self_ty(ty) => { ByReference(region, mutbl) } - ty::TyRawPtr(ty::TypeAndMut { ty, mutbl }) if is_self_ty(ty) => { + ty::RawPtr(ty::TypeAndMut { ty, mutbl }) if is_self_ty(ty) => { ByRawPointer(mutbl) } - ty::TyAdt(def, _) if def.is_box() && is_self_ty(self_arg_ty.boxed_ty()) => { + ty::Adt(def, _) if def.is_box() && is_self_ty(self_arg_ty.boxed_ty()) => { ByBox } _ => Other diff --git a/src/librustc/ty/walk.rs b/src/librustc/ty/walk.rs index d12f73144269b..e2df7c32f587b 100644 --- a/src/librustc/ty/walk.rs +++ b/src/librustc/ty/walk.rs @@ -81,27 +81,27 @@ pub fn walk_shallow<'tcx>(ty: Ty<'tcx>) -> AccIntoIter> { // types as they are written). fn push_subtypes<'tcx>(stack: &mut TypeWalkerStack<'tcx>, parent_ty: Ty<'tcx>) { match parent_ty.sty { - ty::TyBool | ty::TyChar | ty::TyInt(_) | ty::TyUint(_) | ty::TyFloat(_) | - ty::TyStr | ty::TyInfer(_) | ty::TyParam(_) | ty::TyNever | ty::TyError | - ty::TyForeign(..) => { + ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Float(_) | + ty::Str | ty::Infer(_) | ty::Param(_) | ty::Never | ty::Error | + ty::Foreign(..) => { } - ty::TyArray(ty, len) => { + ty::Array(ty, len) => { push_const(stack, len); stack.push(ty); } - ty::TySlice(ty) => { + ty::Slice(ty) => { stack.push(ty); } - ty::TyRawPtr(ref mt) => { + ty::RawPtr(ref mt) => { stack.push(mt.ty); } - ty::TyRef(_, ty, _) => { + ty::Ref(_, ty, _) => { stack.push(ty); } - ty::TyProjection(ref data) => { + ty::Projection(ref data) => { stack.extend(data.substs.types().rev()); } - ty::TyDynamic(ref obj, ..) => { + ty::Dynamic(ref obj, ..) => { stack.extend(obj.iter().rev().flat_map(|predicate| { let (substs, opt_ty) = match *predicate.skip_binder() { ty::ExistentialPredicate::Trait(tr) => (tr.substs, None), @@ -115,25 +115,25 @@ fn push_subtypes<'tcx>(stack: &mut TypeWalkerStack<'tcx>, parent_ty: Ty<'tcx>) { substs.types().rev().chain(opt_ty) })); } - ty::TyAdt(_, substs) | ty::TyAnon(_, substs) => { + ty::Adt(_, substs) | ty::Anon(_, substs) => { stack.extend(substs.types().rev()); } - ty::TyClosure(_, ref substs) => { + ty::Closure(_, ref substs) => { stack.extend(substs.substs.types().rev()); } - ty::TyGenerator(_, ref substs, _) => { + ty::Generator(_, ref substs, _) => { stack.extend(substs.substs.types().rev()); } - ty::TyGeneratorWitness(ts) => { + ty::GeneratorWitness(ts) => { stack.extend(ts.skip_binder().iter().cloned().rev()); } - ty::TyTuple(ts) => { + ty::Tuple(ts) => { stack.extend(ts.iter().cloned().rev()); } - ty::TyFnDef(_, substs) => { + ty::FnDef(_, substs) => { stack.extend(substs.types().rev()); } - ty::TyFnPtr(sig) => { + ty::FnPtr(sig) => { stack.push(sig.skip_binder().output()); stack.extend(sig.skip_binder().inputs().iter().cloned().rev()); } diff --git a/src/librustc/ty/wf.rs b/src/librustc/ty/wf.rs index b99cdd59773aa..fc55d8f34a23f 100644 --- a/src/librustc/ty/wf.rs +++ b/src/librustc/ty/wf.rs @@ -248,31 +248,31 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> { let param_env = self.param_env; while let Some(ty) = subtys.next() { match ty.sty { - ty::TyBool | - ty::TyChar | - ty::TyInt(..) | - ty::TyUint(..) | - ty::TyFloat(..) | - ty::TyError | - ty::TyStr | - ty::TyGeneratorWitness(..) | - ty::TyNever | - ty::TyParam(_) | - ty::TyForeign(..) => { + ty::Bool | + ty::Char | + ty::Int(..) | + ty::Uint(..) | + ty::Float(..) | + ty::Error | + ty::Str | + ty::GeneratorWitness(..) | + ty::Never | + ty::Param(_) | + ty::Foreign(..) => { // WfScalar, WfParameter, etc } - ty::TySlice(subty) => { + ty::Slice(subty) => { self.require_sized(subty, traits::SliceOrArrayElem); } - ty::TyArray(subty, len) => { + ty::Array(subty, len) => { self.require_sized(subty, traits::SliceOrArrayElem); assert_eq!(len.ty, self.infcx.tcx.types.usize); self.compute_const(len); } - ty::TyTuple(ref tys) => { + ty::Tuple(ref tys) => { if let Some((_last, rest)) = tys.split_last() { for elem in rest { self.require_sized(elem, traits::TupleElem); @@ -280,22 +280,22 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> { } } - ty::TyRawPtr(_) => { + ty::RawPtr(_) => { // simple cases that are WF if their type args are WF } - ty::TyProjection(data) => { + ty::Projection(data) => { subtys.skip_current_subtree(); // subtree handled by compute_projection self.compute_projection(data); } - ty::TyAdt(def, substs) => { + ty::Adt(def, substs) => { // WfNominalType let obligations = self.nominal_obligations(def.did, substs); self.out.extend(obligations); } - ty::TyRef(r, rty, _) => { + ty::Ref(r, rty, _) => { // WfReference if !r.has_escaping_regions() && !rty.has_escaping_regions() { let cause = self.cause(traits::ReferenceOutlivesReferent(ty)); @@ -309,7 +309,7 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> { } } - ty::TyGenerator(..) => { + ty::Generator(..) => { // Walk ALL the types in the generator: this will // include the upvar types as well as the yield // type. Note that this is mildly distinct from @@ -319,7 +319,7 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> { // generators don't take arguments. } - ty::TyClosure(def_id, substs) => { + ty::Closure(def_id, substs) => { // Only check the upvar types for WF, not the rest // of the types within. This is needed because we // capture the signature and it may not be WF @@ -355,12 +355,12 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> { } } - ty::TyFnDef(..) | ty::TyFnPtr(_) => { + ty::FnDef(..) | ty::FnPtr(_) => { // let the loop iterate into the argument/return // types appearing in the fn signature } - ty::TyAnon(did, substs) => { + ty::Anon(did, substs) => { // all of the requirements on type parameters // should've been checked by the instantiation // of whatever returned this exact `impl Trait`. @@ -372,7 +372,7 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> { } } - ty::TyDynamic(data, r) => { + ty::Dynamic(data, r) => { // WfObject // // Here, we defer WF checking due to higher-ranked @@ -408,9 +408,9 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> { // register a pending obligation and keep // moving. (Goal is that an "inductive hypothesis" // is satisfied to ensure termination.) - ty::TyInfer(_) => { + ty::Infer(_) => { let ty = self.infcx.shallow_resolve(ty); - if let ty::TyInfer(_) = ty.sty { // not yet resolved... + if let ty::Infer(_) = ty.sty { // not yet resolved... if ty == ty0 { // ...this is the type we started from! no progress. return false; } @@ -423,7 +423,7 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> { } else { // Yes, resolved, proceed with the // result. Should never return false because - // `ty` is not a TyInfer. + // `ty` is not a Infer. assert!(self.compute(ty)); } } @@ -453,7 +453,7 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> { } fn from_object_ty(&mut self, ty: Ty<'tcx>, - data: ty::Binder<&'tcx ty::Slice>>, + data: ty::Binder<&'tcx ty::List>>, region: ty::Region<'tcx>) { // Imagine a type like this: // @@ -513,7 +513,7 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> { /// `ty::required_region_bounds`, see that for more information. pub fn object_region_bounds<'a, 'gcx, 'tcx>( tcx: TyCtxt<'a, 'gcx, 'tcx>, - existential_predicates: ty::Binder<&'tcx ty::Slice>>) + existential_predicates: ty::Binder<&'tcx ty::List>>) -> Vec> { // Since we don't actually *know* the self type for an object, diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 9513086667b28..0f15c75c2fb36 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -14,11 +14,11 @@ use mir::interpret::ConstValue; use middle::region::{self, BlockRemainder}; use ty::subst::{self, Subst}; use ty::{BrAnon, BrEnv, BrFresh, BrNamed}; -use ty::{TyBool, TyChar, TyAdt}; -use ty::{TyError, TyStr, TyArray, TySlice, TyFloat, TyFnDef, TyFnPtr}; -use ty::{TyParam, TyRawPtr, TyRef, TyNever, TyTuple}; -use ty::{TyClosure, TyGenerator, TyGeneratorWitness, TyForeign, TyProjection, TyAnon}; -use ty::{TyDynamic, TyInt, TyUint, TyInfer}; +use ty::{Bool, Char, Adt}; +use ty::{Error, Str, Array, Slice, Float, FnDef, FnPtr}; +use ty::{Param, RawPtr, Ref, Never, Tuple}; +use ty::{Closure, Generator, GeneratorWitness, Foreign, Projection, Anon}; +use ty::{Dynamic, Int, Uint, Infer}; use ty::{self, RegionVid, Ty, TyCtxt, TypeFoldable, GenericParamCount, GenericParamDefKind}; use util::nodemap::FxHashSet; @@ -371,7 +371,7 @@ impl PrintContext { if !verbose && fn_trait_kind.is_some() && projections.len() == 1 { let projection_ty = projections[0].ty; - if let TyTuple(ref args) = substs.type_at(1).sty { + if let Tuple(ref args) = substs.type_at(1).sty { return self.fn_sig(f, args, false, projection_ty); } } @@ -586,7 +586,7 @@ impl<'a, T: Print> Print for &'a T { } define_print! { - ('tcx) &'tcx ty::Slice>, (self, f, cx) { + ('tcx) &'tcx ty::List>, (self, f, cx) { display { // Generate the main trait ref, including associated types. ty::tls::with(|tcx| { @@ -672,7 +672,7 @@ impl<'tcx> fmt::Debug for ty::UpvarBorrow<'tcx> { } define_print! { - ('tcx) &'tcx ty::Slice>, (self, f, cx) { + ('tcx) &'tcx ty::List>, (self, f, cx) { display { write!(f, "{{")?; let mut tys = self.iter(); @@ -993,7 +993,7 @@ impl fmt::Debug for ty::FloatVarValue { define_print_multi! { [ - ('tcx) ty::Binder<&'tcx ty::Slice>>, + ('tcx) ty::Binder<&'tcx ty::List>>, ('tcx) ty::Binder>, ('tcx) ty::Binder>, ('tcx) ty::Binder>, @@ -1029,22 +1029,22 @@ 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"), - TyChar => write!(f, "char"), - TyInt(t) => write!(f, "{}", t.ty_to_string()), - TyUint(t) => write!(f, "{}", t.ty_to_string()), - TyFloat(t) => write!(f, "{}", t.ty_to_string()), - TyRawPtr(ref tm) => { + Bool => write!(f, "bool"), + Char => write!(f, "char"), + Int(t) => write!(f, "{}", t.ty_to_string()), + Uint(t) => write!(f, "{}", t.ty_to_string()), + Float(t) => write!(f, "{}", t.ty_to_string()), + RawPtr(ref tm) => { write!(f, "*{} ", match tm.mutbl { hir::MutMutable => "mut", hir::MutImmutable => "const", })?; tm.ty.print(f, cx) } - TyRef(r, ty, mutbl) => { + Ref(r, ty, mutbl) => { write!(f, "&")?; let s = r.print_to_string(cx); if s != "'_" { @@ -1055,8 +1055,8 @@ define_print! { } ty::TypeAndMut { ty, mutbl }.print(f, cx) } - TyNever => write!(f, "!"), - TyTuple(ref tys) => { + Never => write!(f, "!"), + Tuple(ref tys) => { write!(f, "(")?; let mut tys = tys.iter(); if let Some(&ty) = tys.next() { @@ -1070,7 +1070,7 @@ define_print! { } write!(f, ")") } - TyFnDef(def_id, substs) => { + FnDef(def_id, substs) => { ty::tls::with(|tcx| { let mut sig = tcx.fn_sig(def_id); if let Some(substs) = tcx.lift(&substs) { @@ -1081,14 +1081,14 @@ define_print! { cx.parameterized(f, substs, def_id, &[])?; write!(f, "}}") } - TyFnPtr(ref bare_fn) => { + FnPtr(ref bare_fn) => { bare_fn.print(f, cx) } - TyInfer(infer_ty) => write!(f, "{}", infer_ty), - TyError => write!(f, "[type error]"), - TyParam(ref param_ty) => write!(f, "{}", param_ty), - TyAdt(def, substs) => cx.parameterized(f, substs, def.did, &[]), - TyDynamic(data, r) => { + Infer(infer_ty) => write!(f, "{}", infer_ty), + Error => write!(f, "[type error]"), + Param(ref param_ty) => write!(f, "{}", param_ty), + Adt(def, substs) => cx.parameterized(f, substs, def.did, &[]), + Dynamic(data, r) => { let r = r.print_to_string(cx); if !r.is_empty() { write!(f, "(")?; @@ -1101,11 +1101,11 @@ define_print! { Ok(()) } } - TyForeign(def_id) => parameterized(f, subst::Substs::empty(), def_id, &[]), - TyProjection(ref data) => data.print(f, cx), - TyAnon(def_id, substs) => { + Foreign(def_id) => parameterized(f, subst::Substs::empty(), def_id, &[]), + Projection(ref data) => data.print(f, cx), + Anon(def_id, substs) => { if cx.is_verbose { - return write!(f, "TyAnon({:?}, {:?})", def_id, substs); + return write!(f, "Anon({:?}, {:?})", def_id, substs); } ty::tls::with(|tcx| { @@ -1154,8 +1154,8 @@ define_print! { Ok(()) }) } - TyStr => write!(f, "str"), - TyGenerator(did, substs, movability) => ty::tls::with(|tcx| { + Str => write!(f, "str"), + Generator(did, substs, movability) => ty::tls::with(|tcx| { let upvar_tys = substs.upvar_tys(did, tcx); let witness = substs.witness(did, tcx); if movability == hir::GeneratorMovability::Movable { @@ -1193,10 +1193,10 @@ define_print! { print!(f, cx, write(" "), print(witness), write("]")) }), - TyGeneratorWitness(types) => { + GeneratorWitness(types) => { ty::tls::with(|tcx| cx.in_binder(f, tcx, &types, tcx.lift(&types))) } - TyClosure(did, substs) => ty::tls::with(|tcx| { + Closure(did, substs) => ty::tls::with(|tcx| { let upvar_tys = substs.upvar_tys(did, tcx); write!(f, "[closure")?; @@ -1233,7 +1233,7 @@ define_print! { write!(f, "]") }), - TyArray(ty, sz) => { + Array(ty, sz) => { print!(f, cx, write("["), print(ty), write("; "))?; match sz.val { ConstValue::Unevaluated(_def_id, _substs) => { @@ -1245,7 +1245,7 @@ define_print! { } write!(f, "]") } - TySlice(ty) => { + Slice(ty) => { print!(f, cx, write("["), print(ty), write("]")) } } diff --git a/src/librustc_borrowck/borrowck/check_loans.rs b/src/librustc_borrowck/borrowck/check_loans.rs index dab60ef16613d..847d37be89933 100644 --- a/src/librustc_borrowck/borrowck/check_loans.rs +++ b/src/librustc_borrowck/borrowck/check_loans.rs @@ -843,7 +843,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { } LpExtend(ref lp_base, _, LpInterior(_, InteriorField(_))) => { match lp_base.to_type().sty { - ty::TyAdt(def, _) if def.has_dtor(self.tcx()) => { + ty::Adt(def, _) if def.has_dtor(self.tcx()) => { // In the case where the owner implements drop, then // the path must be initialized to prevent a case of // partial reinitialization diff --git a/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs b/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs index b76931c301748..5c165fbad6943 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs @@ -191,14 +191,14 @@ fn check_and_get_illegal_move_origin<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, Categorization::Interior(ref b, mc::InteriorField(_)) | Categorization::Interior(ref b, mc::InteriorElement(Kind::Pattern)) => { match b.ty.sty { - ty::TyAdt(def, _) => { + ty::Adt(def, _) => { if def.has_dtor(bccx.tcx) { Some(cmt.clone()) } else { check_and_get_illegal_move_origin(bccx, b) } } - ty::TySlice(..) => Some(cmt.clone()), + ty::Slice(..) => Some(cmt.clone()), _ => { check_and_get_illegal_move_origin(bccx, b) } diff --git a/src/librustc_borrowck/borrowck/gather_loans/move_error.rs b/src/librustc_borrowck/borrowck/gather_loans/move_error.rs index e1c3ac839902f..31778668e6da0 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/move_error.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/move_error.rs @@ -154,7 +154,7 @@ fn report_cannot_move_out_of<'a, 'tcx>(bccx: &'a BorrowckCtxt<'a, 'tcx>, Categorization::Downcast(ref b, _) | Categorization::Interior(ref b, mc::InteriorField(_)) => { match b.ty.sty { - ty::TyAdt(def, _) if def.has_dtor(bccx.tcx) => { + ty::Adt(def, _) if def.has_dtor(bccx.tcx) => { bccx.cannot_move_out_of_interior_of_drop( move_from.span, b.ty, Origin::Ast) } diff --git a/src/librustc_borrowck/borrowck/gather_loans/restrictions.rs b/src/librustc_borrowck/borrowck/gather_loans/restrictions.rs index e332f68327546..d9784cc2177fd 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/restrictions.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/restrictions.rs @@ -104,7 +104,7 @@ impl<'a, 'tcx> RestrictionsContext<'a, 'tcx> { let result = self.restrict(&cmt_base); // Borrowing one union field automatically borrows all its fields. match base_ty.sty { - ty::TyAdt(adt_def, _) if adt_def.is_union() => match result { + ty::Adt(adt_def, _) if adt_def.is_union() => match result { RestrictionResult::Safe => RestrictionResult::Safe, RestrictionResult::SafeIf(base_lp, mut base_vec) => { for (i, field) in adt_def.non_enum_variant().fields.iter().enumerate() { diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index 7208e1ca36299..a3ca329b92d7f 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -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::Closure(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) { diff --git a/src/librustc_borrowck/borrowck/move_data.rs b/src/librustc_borrowck/borrowck/move_data.rs index 979d71a0923c4..d9f223daf6091 100644 --- a/src/librustc_borrowck/borrowck/move_data.rs +++ b/src/librustc_borrowck/borrowck/move_data.rs @@ -329,7 +329,7 @@ impl<'a, 'tcx> MoveData<'tcx> { // all parent union fields, moves do not propagate upwards automatically. let mut lp = orig_lp.clone(); while let LpExtend(ref base_lp, mutbl, lp_elem) = lp.clone().kind { - if let (&ty::TyAdt(adt_def, _), LpInterior(opt_variant_id, interior)) + if let (&ty::Adt(adt_def, _), LpInterior(opt_variant_id, interior)) = (&base_lp.ty.sty, lp_elem) { if adt_def.is_union() { for (i, field) in adt_def.non_enum_variant().fields.iter().enumerate() { @@ -381,7 +381,7 @@ impl<'a, 'tcx> MoveData<'tcx> { span: Span) { // Assigning to one union field automatically assigns to all its fields. if let LpExtend(ref base_lp, mutbl, LpInterior(opt_variant_id, interior)) = lp.kind { - if let ty::TyAdt(adt_def, _) = base_lp.ty.sty { + if let ty::Adt(adt_def, _) = base_lp.ty.sty { if adt_def.is_union() { for (i, field) in adt_def.non_enum_variant().fields.iter().enumerate() { let field = diff --git a/src/librustc_codegen_llvm/abi.rs b/src/librustc_codegen_llvm/abi.rs index 79343505c78a5..684f2b358858f 100644 --- a/src/librustc_codegen_llvm/abi.rs +++ b/src/librustc_codegen_llvm/abi.rs @@ -364,7 +364,7 @@ impl<'tcx> FnTypeExt<'tcx> for FnType<'tcx, Ty<'tcx>> { assert!(!sig.variadic && extra_args.is_empty()); match sig.inputs().last().unwrap().sty { - ty::TyTuple(ref tupled_arguments) => { + ty::Tuple(ref tupled_arguments) => { inputs = &sig.inputs()[0..sig.inputs().len() - 1]; tupled_arguments } diff --git a/src/librustc_codegen_llvm/base.rs b/src/librustc_codegen_llvm/base.rs index 3834672633c05..009c6da9d8d15 100644 --- a/src/librustc_codegen_llvm/base.rs +++ b/src/librustc_codegen_llvm/base.rs @@ -166,12 +166,12 @@ pub fn compare_simd_types( op: hir::BinOpKind ) -> &'ll Value { let signed = match t.sty { - ty::TyFloat(_) => { + ty::Float(_) => { let cmp = bin_op_to_fcmp_predicate(op); return bx.sext(bx.fcmp(cmp, lhs, rhs), ret_ty); }, - ty::TyUint(_) => false, - ty::TyInt(_) => true, + ty::Uint(_) => false, + ty::Int(_) => true, _ => bug!("compare_simd_types: invalid SIMD type"), }; @@ -197,16 +197,16 @@ pub fn unsized_info( ) -> &'ll Value { let (source, target) = cx.tcx.struct_lockstep_tails(source, target); match (&source.sty, &target.sty) { - (&ty::TyArray(_, len), &ty::TySlice(_)) => { + (&ty::Array(_, len), &ty::Slice(_)) => { C_usize(cx, len.unwrap_usize(cx.tcx)) } - (&ty::TyDynamic(..), &ty::TyDynamic(..)) => { + (&ty::Dynamic(..), &ty::Dynamic(..)) => { // For now, upcasts are limited to changes in marker // traits, and hence never actually require an actual // change to the vtable. old_info.expect("unsized_info: missing old info for trait upcast") } - (_, &ty::TyDynamic(ref data, ..)) => { + (_, &ty::Dynamic(ref data, ..)) => { let vtable_ptr = cx.layout_of(cx.tcx.mk_mut_ptr(target)) .field(cx, abi::FAT_PTR_EXTRA); consts::ptrcast(meth::get_vtable(cx, source, data.principal()), @@ -227,23 +227,23 @@ pub fn unsize_thin_ptr( ) -> (&'ll Value, &'ll Value) { debug!("unsize_thin_ptr: {:?} => {:?}", src_ty, dst_ty); match (&src_ty.sty, &dst_ty.sty) { - (&ty::TyRef(_, a, _), - &ty::TyRef(_, b, _)) | - (&ty::TyRef(_, a, _), - &ty::TyRawPtr(ty::TypeAndMut { ty: b, .. })) | - (&ty::TyRawPtr(ty::TypeAndMut { ty: a, .. }), - &ty::TyRawPtr(ty::TypeAndMut { ty: b, .. })) => { + (&ty::Ref(_, a, _), + &ty::Ref(_, b, _)) | + (&ty::Ref(_, a, _), + &ty::RawPtr(ty::TypeAndMut { ty: b, .. })) | + (&ty::RawPtr(ty::TypeAndMut { ty: a, .. }), + &ty::RawPtr(ty::TypeAndMut { ty: b, .. })) => { assert!(bx.cx.type_is_sized(a)); let ptr_ty = bx.cx.layout_of(b).llvm_type(bx.cx).ptr_to(); (bx.pointercast(src, ptr_ty), unsized_info(bx.cx, a, b, None)) } - (&ty::TyAdt(def_a, _), &ty::TyAdt(def_b, _)) if def_a.is_box() && def_b.is_box() => { + (&ty::Adt(def_a, _), &ty::Adt(def_b, _)) if def_a.is_box() && def_b.is_box() => { let (a, b) = (src_ty.boxed_ty(), dst_ty.boxed_ty()); assert!(bx.cx.type_is_sized(a)); let ptr_ty = bx.cx.layout_of(b).llvm_type(bx.cx).ptr_to(); (bx.pointercast(src, ptr_ty), unsized_info(bx.cx, a, b, None)) } - (&ty::TyAdt(def_a, _), &ty::TyAdt(def_b, _)) => { + (&ty::Adt(def_a, _), &ty::Adt(def_b, _)) => { assert_eq!(def_a, def_b); let src_layout = bx.cx.layout_of(src_ty); @@ -299,16 +299,16 @@ pub fn coerce_unsized_into( OperandValue::Pair(base, info).store(bx, dst); }; match (&src_ty.sty, &dst_ty.sty) { - (&ty::TyRef(..), &ty::TyRef(..)) | - (&ty::TyRef(..), &ty::TyRawPtr(..)) | - (&ty::TyRawPtr(..), &ty::TyRawPtr(..)) => { + (&ty::Ref(..), &ty::Ref(..)) | + (&ty::Ref(..), &ty::RawPtr(..)) | + (&ty::RawPtr(..), &ty::RawPtr(..)) => { coerce_ptr() } - (&ty::TyAdt(def_a, _), &ty::TyAdt(def_b, _)) if def_a.is_box() && def_b.is_box() => { + (&ty::Adt(def_a, _), &ty::Adt(def_b, _)) if def_a.is_box() && def_b.is_box() => { coerce_ptr() } - (&ty::TyAdt(def_a, _), &ty::TyAdt(def_b, _)) => { + (&ty::Adt(def_a, _), &ty::Adt(def_b, _)) => { assert_eq!(def_a, def_b); for i in 0..def_a.variants[0].fields.len() { diff --git a/src/librustc_codegen_llvm/common.rs b/src/librustc_codegen_llvm/common.rs index 51fc610408b52..53bb02ddd99d9 100644 --- a/src/librustc_codegen_llvm/common.rs +++ b/src/librustc_codegen_llvm/common.rs @@ -413,10 +413,10 @@ pub fn ty_fn_sig<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, -> ty::PolyFnSig<'tcx> { match ty.sty { - ty::TyFnDef(..) | - // Shims currently have type TyFnPtr. Not sure this should remain. - ty::TyFnPtr(_) => ty.fn_sig(cx.tcx), - ty::TyClosure(def_id, substs) => { + ty::FnDef(..) | + // Shims currently have type FnPtr. Not sure this should remain. + ty::FnPtr(_) => ty.fn_sig(cx.tcx), + ty::Closure(def_id, substs) => { let tcx = cx.tcx; let sig = substs.closure_sig(def_id, tcx); @@ -429,7 +429,7 @@ pub fn ty_fn_sig<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, sig.abi )) } - ty::TyGenerator(def_id, substs, _) => { + ty::Generator(def_id, substs, _) => { let tcx = cx.tcx; let sig = substs.poly_sig(def_id, cx.tcx); diff --git a/src/librustc_codegen_llvm/consts.rs b/src/librustc_codegen_llvm/consts.rs index 770a22ad65842..6f09ebb382697 100644 --- a/src/librustc_codegen_llvm/consts.rs +++ b/src/librustc_codegen_llvm/consts.rs @@ -250,7 +250,7 @@ fn check_and_apply_linkage( // static and call it a day. Some linkages (like weak) will make it such // that the static actually has a null value. let llty2 = match ty.sty { - ty::TyRawPtr(ref mt) => cx.layout_of(mt.ty).llvm_type(cx), + ty::RawPtr(ref mt) => cx.layout_of(mt.ty).llvm_type(cx), _ => { if span.is_some() { cx.sess().span_fatal(span.unwrap(), "must have type `*const T` or `*mut T`") diff --git a/src/librustc_codegen_llvm/context.rs b/src/librustc_codegen_llvm/context.rs index 32ea2c5eb8f35..9547f4a190e78 100644 --- a/src/librustc_codegen_llvm/context.rs +++ b/src/librustc_codegen_llvm/context.rs @@ -434,8 +434,8 @@ impl<'b, 'tcx> CodegenCx<'b, 'tcx> { let tail = self.tcx.struct_tail(ty); match tail.sty { - ty::TyForeign(..) => false, - ty::TyStr | ty::TySlice(..) | ty::TyDynamic(..) => true, + ty::Foreign(..) => false, + ty::Str | ty::Slice(..) | ty::Dynamic(..) => true, _ => bug!("unexpected unsized tail: {:?}", tail.sty), } } diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs index c79a1a4bd04c6..c7a515016c01b 100644 --- a/src/librustc_codegen_llvm/debuginfo/metadata.rs +++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs @@ -309,7 +309,7 @@ fn fixed_vec_metadata( let (size, align) = cx.size_and_align_of(array_or_slice_type); let upper_bound = match array_or_slice_type.sty { - ty::TyArray(_, len) => { + ty::Array(_, len) => { len.unwrap_usize(cx.tcx) as c_longlong } _ => -1 @@ -396,7 +396,7 @@ fn subroutine_type_metadata( let signature_metadata: Vec<_> = iter::once( // return type match signature.output().sty { - ty::TyTuple(ref tys) if tys.is_empty() => None, + ty::Tuple(ref tys) if tys.is_empty() => None, _ => Some(type_metadata(cx, signature.output(), span)) } ).chain( @@ -435,7 +435,7 @@ fn trait_pointer_metadata( // But it does not describe the trait's methods. let containing_scope = match trait_type.sty { - ty::TyDynamic(ref data, ..) => if let Some(principal) = data.principal() { + ty::Dynamic(ref data, ..) => if let Some(principal) = data.principal() { let def_id = principal.def_id(); Some(get_namespace_for_item(cx, def_id)) } else { @@ -534,13 +534,13 @@ pub fn type_metadata( let ptr_metadata = |ty: Ty<'tcx>| { match ty.sty { - ty::TySlice(typ) => { + ty::Slice(typ) => { Ok(vec_slice_metadata(cx, t, typ, unique_type_id, usage_site_span)) } - ty::TyStr => { + ty::Str => { Ok(vec_slice_metadata(cx, t, cx.tcx.types.u8, unique_type_id, usage_site_span)) } - ty::TyDynamic(..) => { + ty::Dynamic(..) => { Ok(MetadataCreationResult::new( trait_pointer_metadata(cx, ty, Some(t), unique_type_id), false)) @@ -562,48 +562,48 @@ pub fn type_metadata( }; let MetadataCreationResult { metadata, already_stored_in_typemap } = match t.sty { - ty::TyNever | - ty::TyBool | - ty::TyChar | - ty::TyInt(_) | - ty::TyUint(_) | - ty::TyFloat(_) => { + ty::Never | + ty::Bool | + ty::Char | + ty::Int(_) | + ty::Uint(_) | + ty::Float(_) => { MetadataCreationResult::new(basic_type_metadata(cx, t), false) } - ty::TyTuple(ref elements) if elements.is_empty() => { + ty::Tuple(ref elements) if elements.is_empty() => { MetadataCreationResult::new(basic_type_metadata(cx, t), false) } - ty::TyArray(typ, _) | - ty::TySlice(typ) => { + ty::Array(typ, _) | + ty::Slice(typ) => { fixed_vec_metadata(cx, unique_type_id, t, typ, usage_site_span) } - ty::TyStr => { + ty::Str => { fixed_vec_metadata(cx, unique_type_id, t, cx.tcx.types.i8, usage_site_span) } - ty::TyDynamic(..) => { + ty::Dynamic(..) => { MetadataCreationResult::new( trait_pointer_metadata(cx, t, None, unique_type_id), false) } - ty::TyForeign(..) => { + ty::Foreign(..) => { MetadataCreationResult::new( foreign_type_metadata(cx, t, unique_type_id), false) } - ty::TyRawPtr(ty::TypeAndMut{ty, ..}) | - ty::TyRef(_, ty, _) => { + ty::RawPtr(ty::TypeAndMut{ty, ..}) | + ty::Ref(_, ty, _) => { match ptr_metadata(ty) { Ok(res) => res, Err(metadata) => return metadata, } } - ty::TyAdt(def, _) if def.is_box() => { + ty::Adt(def, _) if def.is_box() => { match ptr_metadata(t.boxed_ty()) { Ok(res) => res, Err(metadata) => return metadata, } } - ty::TyFnDef(..) | ty::TyFnPtr(_) => { + ty::FnDef(..) | ty::FnPtr(_) => { let fn_metadata = subroutine_type_metadata(cx, unique_type_id, t.fn_sig(cx.tcx), @@ -619,7 +619,7 @@ pub fn type_metadata( MetadataCreationResult::new(pointer_type_metadata(cx, t, fn_metadata), false) } - ty::TyClosure(def_id, substs) => { + ty::Closure(def_id, substs) => { let upvar_tys : Vec<_> = substs.upvar_tys(def_id, cx.tcx).collect(); prepare_tuple_metadata(cx, t, @@ -627,7 +627,7 @@ pub fn type_metadata( unique_type_id, usage_site_span).finalize(cx) } - ty::TyGenerator(def_id, substs, _) => { + ty::Generator(def_id, substs, _) => { let upvar_tys : Vec<_> = substs.field_tys(def_id, cx.tcx).map(|t| { cx.tcx.normalize_erasing_regions(ParamEnv::reveal_all(), t) }).collect(); @@ -637,7 +637,7 @@ pub fn type_metadata( unique_type_id, usage_site_span).finalize(cx) } - ty::TyAdt(def, ..) => match def.adt_kind() { + ty::Adt(def, ..) => match def.adt_kind() { AdtKind::Struct => { prepare_struct_metadata(cx, t, @@ -658,7 +658,7 @@ pub fn type_metadata( usage_site_span).finalize(cx) } }, - ty::TyTuple(ref elements) => { + ty::Tuple(ref elements) => { prepare_tuple_metadata(cx, t, &elements[..], @@ -765,18 +765,18 @@ fn basic_type_metadata(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll DIType { debug!("basic_type_metadata: {:?}", t); let (name, encoding) = match t.sty { - ty::TyNever => ("!", DW_ATE_unsigned), - ty::TyTuple(ref elements) if elements.is_empty() => + ty::Never => ("!", DW_ATE_unsigned), + ty::Tuple(ref elements) if elements.is_empty() => ("()", DW_ATE_unsigned), - ty::TyBool => ("bool", DW_ATE_boolean), - ty::TyChar => ("char", DW_ATE_unsigned_char), - ty::TyInt(int_ty) => { + ty::Bool => ("bool", DW_ATE_boolean), + ty::Char => ("char", DW_ATE_unsigned_char), + ty::Int(int_ty) => { (int_ty.ty_to_string(), DW_ATE_signed) }, - ty::TyUint(uint_ty) => { + ty::Uint(uint_ty) => { (uint_ty.ty_to_string(), DW_ATE_unsigned) }, - ty::TyFloat(float_ty) => { + ty::Float(float_ty) => { (float_ty.ty_to_string(), DW_ATE_float) }, _ => bug!("debuginfo::basic_type_metadata - t is invalid type") @@ -1009,7 +1009,7 @@ fn prepare_struct_metadata( let struct_name = compute_debuginfo_type_name(cx, struct_type, false); let (struct_def_id, variant) = match struct_type.sty { - ty::TyAdt(def, _) => (def.did, def.non_enum_variant()), + ty::Adt(def, _) => (def.did, def.non_enum_variant()), _ => bug!("prepare_struct_metadata on a non-ADT") }; @@ -1126,7 +1126,7 @@ fn prepare_union_metadata( let union_name = compute_debuginfo_type_name(cx, union_type, false); let (union_def_id, variant) = match union_type.sty { - ty::TyAdt(def, _) => (def.did, def.non_enum_variant()), + ty::Adt(def, _) => (def.did, def.non_enum_variant()), _ => bug!("prepare_union_metadata on a non-ADT") }; diff --git a/src/librustc_codegen_llvm/debuginfo/mod.rs b/src/librustc_codegen_llvm/debuginfo/mod.rs index fcb8bc3fe2b21..99919a940b405 100644 --- a/src/librustc_codegen_llvm/debuginfo/mod.rs +++ b/src/librustc_codegen_llvm/debuginfo/mod.rs @@ -323,7 +323,7 @@ pub fn create_function_debug_context( // Return type -- llvm::DIBuilder wants this at index 0 signature.push(match sig.output().sty { - ty::TyTuple(ref tys) if tys.is_empty() => None, + ty::Tuple(ref tys) if tys.is_empty() => None, _ => Some(type_metadata(cx, sig.output(), syntax_pos::DUMMY_SP)) }); @@ -347,7 +347,7 @@ pub fn create_function_debug_context( // already inaccurate due to ABI adjustments (see #42800). signature.extend(inputs.iter().map(|&t| { let t = match t.sty { - ty::TyArray(ct, _) + ty::Array(ct, _) if (ct == cx.tcx.types.u8) || cx.layout_of(ct).is_zst() => { cx.tcx.mk_imm_ptr(ct) } @@ -362,7 +362,7 @@ pub fn create_function_debug_context( } if sig.abi == Abi::RustCall && !sig.inputs().is_empty() { - if let ty::TyTuple(args) = sig.inputs()[sig.inputs().len() - 1].sty { + if let ty::Tuple(args) = sig.inputs()[sig.inputs().len() - 1].sty { signature.extend( args.iter().map(|argument_type| { Some(type_metadata(cx, argument_type, syntax_pos::DUMMY_SP)) @@ -460,7 +460,7 @@ pub fn create_function_debug_context( // Only "class" methods are generally understood by LLVM, // so avoid methods on other types (e.g. `<*mut T>::null`). match impl_self_ty.sty { - ty::TyAdt(def, ..) if !def.is_box() => { + ty::Adt(def, ..) if !def.is_box() => { Some(type_metadata(cx, impl_self_ty, syntax_pos::DUMMY_SP)) } _ => None diff --git a/src/librustc_codegen_llvm/debuginfo/type_names.rs b/src/librustc_codegen_llvm/debuginfo/type_names.rs index 05a74db3a6ca9..a08b964cd721d 100644 --- a/src/librustc_codegen_llvm/debuginfo/type_names.rs +++ b/src/librustc_codegen_llvm/debuginfo/type_names.rs @@ -41,19 +41,19 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, let cpp_like_names = cx.sess().target.target.options.is_like_msvc; match t.sty { - ty::TyBool => output.push_str("bool"), - ty::TyChar => output.push_str("char"), - ty::TyStr => output.push_str("str"), - ty::TyNever => output.push_str("!"), - ty::TyInt(int_ty) => output.push_str(int_ty.ty_to_string()), - ty::TyUint(uint_ty) => output.push_str(uint_ty.ty_to_string()), - ty::TyFloat(float_ty) => output.push_str(float_ty.ty_to_string()), - ty::TyForeign(def_id) => push_item_name(cx, def_id, qualified, output), - ty::TyAdt(def, substs) => { + ty::Bool => output.push_str("bool"), + ty::Char => output.push_str("char"), + ty::Str => output.push_str("str"), + ty::Never => output.push_str("!"), + ty::Int(int_ty) => output.push_str(int_ty.ty_to_string()), + ty::Uint(uint_ty) => output.push_str(uint_ty.ty_to_string()), + ty::Float(float_ty) => output.push_str(float_ty.ty_to_string()), + ty::Foreign(def_id) => push_item_name(cx, def_id, qualified, output), + ty::Adt(def, substs) => { push_item_name(cx, def.did, qualified, output); push_type_params(cx, substs, output); }, - ty::TyTuple(component_types) => { + ty::Tuple(component_types) => { output.push('('); for &component_type in component_types { push_debuginfo_type_name(cx, component_type, true, output); @@ -65,7 +65,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, } output.push(')'); }, - ty::TyRawPtr(ty::TypeAndMut { ty: inner_type, mutbl } ) => { + ty::RawPtr(ty::TypeAndMut { ty: inner_type, mutbl } ) => { if !cpp_like_names { output.push('*'); } @@ -80,7 +80,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, output.push('*'); } }, - ty::TyRef(_, inner_type, mutbl) => { + ty::Ref(_, inner_type, mutbl) => { if !cpp_like_names { output.push('&'); } @@ -94,13 +94,13 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, output.push('*'); } }, - ty::TyArray(inner_type, len) => { + ty::Array(inner_type, len) => { output.push('['); push_debuginfo_type_name(cx, inner_type, true, output); output.push_str(&format!("; {}", len.unwrap_usize(cx.tcx))); output.push(']'); }, - ty::TySlice(inner_type) => { + ty::Slice(inner_type) => { if cpp_like_names { output.push_str("slice<"); } else { @@ -115,7 +115,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, output.push(']'); } }, - ty::TyDynamic(ref trait_data, ..) => { + ty::Dynamic(ref trait_data, ..) => { if let Some(principal) = trait_data.principal() { let principal = cx.tcx.normalize_erasing_late_bound_regions( ty::ParamEnv::reveal_all(), @@ -125,7 +125,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, push_type_params(cx, principal.substs, output); } }, - ty::TyFnDef(..) | ty::TyFnPtr(_) => { + ty::FnDef(..) | ty::FnPtr(_) => { let sig = t.fn_sig(cx.tcx); if sig.unsafety() == hir::Unsafety::Unsafe { output.push_str("unsafe "); @@ -165,18 +165,18 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, push_debuginfo_type_name(cx, sig.output(), true, output); } }, - ty::TyClosure(..) => { + ty::Closure(..) => { output.push_str("closure"); } - ty::TyGenerator(..) => { + ty::Generator(..) => { output.push_str("generator"); } - ty::TyError | - ty::TyInfer(_) | - ty::TyProjection(..) | - ty::TyAnon(..) | - ty::TyGeneratorWitness(..) | - ty::TyParam(_) => { + ty::Error | + ty::Infer(_) | + ty::Projection(..) | + ty::Anon(..) | + ty::GeneratorWitness(..) | + ty::Param(_) => { bug!("debuginfo: Trying to create type name for \ unexpected type: {:?}", t); } diff --git a/src/librustc_codegen_llvm/glue.rs b/src/librustc_codegen_llvm/glue.rs index 37ce51da77823..ff33cec043729 100644 --- a/src/librustc_codegen_llvm/glue.rs +++ b/src/librustc_codegen_llvm/glue.rs @@ -35,12 +35,12 @@ pub fn size_and_align_of_dst(bx: &Builder<'_, 'll, 'tcx>, t: Ty<'tcx>, info: Opt return (size, align); } match t.sty { - ty::TyDynamic(..) => { + ty::Dynamic(..) => { // load size/align from vtable let vtable = info.unwrap(); (meth::SIZE.get_usize(bx, vtable), meth::ALIGN.get_usize(bx, vtable)) } - ty::TySlice(_) | ty::TyStr => { + ty::Slice(_) | ty::Str => { let unit = t.sequence_element_type(bx.tcx()); // The info in this case is the length of the str, so the size is that // times the unit size. @@ -81,7 +81,7 @@ pub fn size_and_align_of_dst(bx: &Builder<'_, 'll, 'tcx>, t: Ty<'tcx>, info: Opt let size = bx.add(sized_size, unsized_size); // Packed types ignore the alignment of their fields. - if let ty::TyAdt(def, _) = t.sty { + if let ty::Adt(def, _) = t.sty { if def.repr.packed() { unsized_align = sized_align; } diff --git a/src/librustc_codegen_llvm/intrinsic.rs b/src/librustc_codegen_llvm/intrinsic.rs index be3e0d9d4b1ed..5d00e0807991e 100644 --- a/src/librustc_codegen_llvm/intrinsic.rs +++ b/src/librustc_codegen_llvm/intrinsic.rs @@ -98,7 +98,7 @@ pub fn codegen_intrinsic_call( let tcx = cx.tcx; let (def_id, substs) = match callee_ty.sty { - ty::TyFnDef(def_id, substs) => (def_id, substs), + ty::FnDef(def_id, substs) => (def_id, substs), _ => bug!("expected fn item type, found {}", callee_ty) }; @@ -1149,7 +1149,7 @@ fn generic_simd_intrinsic( m_len, v_len ); match m_elem_ty.sty { - ty::TyInt(_) => {}, + ty::Int(_) => {}, _ => { return_error!("mask element type is `{}`, expected `i_`", m_elem_ty); } @@ -1191,7 +1191,7 @@ fn generic_simd_intrinsic( } } let ety = match in_elem.sty { - ty::TyFloat(f) if f.bit_width() == 32 => { + ty::Float(f) if f.bit_width() == 32 => { if in_len < 2 || in_len > 16 { return_error!( "unsupported floating-point vector `{}` with length `{}` \ @@ -1200,7 +1200,7 @@ fn generic_simd_intrinsic( } "f32" }, - ty::TyFloat(f) if f.bit_width() == 64 => { + ty::Float(f) if f.bit_width() == 64 => { if in_len < 2 || in_len > 8 { return_error!("unsupported floating-point vector `{}` with length `{}` \ out-of-range [2, 8]", @@ -1208,7 +1208,7 @@ fn generic_simd_intrinsic( } "f64" }, - ty::TyFloat(f) => { + ty::Float(f) => { return_error!("unsupported element type `{}` of floating-point vector `{}`", f, in_ty); }, @@ -1288,9 +1288,9 @@ fn generic_simd_intrinsic( fn llvm_vector_str(elem_ty: ty::Ty, vec_len: usize, no_pointers: usize) -> String { let p0s: String = "p0".repeat(no_pointers); match elem_ty.sty { - ty::TyInt(v) => format!("v{}{}i{}", vec_len, p0s, v.bit_width().unwrap()), - ty::TyUint(v) => format!("v{}{}i{}", vec_len, p0s, v.bit_width().unwrap()), - ty::TyFloat(v) => format!("v{}{}f{}", vec_len, p0s, v.bit_width()), + ty::Int(v) => format!("v{}{}i{}", vec_len, p0s, v.bit_width().unwrap()), + ty::Uint(v) => format!("v{}{}i{}", vec_len, p0s, v.bit_width().unwrap()), + ty::Float(v) => format!("v{}{}f{}", vec_len, p0s, v.bit_width()), _ => unreachable!(), } } @@ -1299,9 +1299,9 @@ fn generic_simd_intrinsic( mut no_pointers: usize) -> &'ll Type { // FIXME: use cx.layout_of(ty).llvm_type() ? let mut elem_ty = match elem_ty.sty { - ty::TyInt(v) => Type::int_from_ty(cx, v), - ty::TyUint(v) => Type::uint_from_ty(cx, v), - ty::TyFloat(v) => Type::float_from_ty(cx, v), + ty::Int(v) => Type::int_from_ty(cx, v), + ty::Uint(v) => Type::uint_from_ty(cx, v), + ty::Float(v) => Type::float_from_ty(cx, v), _ => unreachable!(), }; while no_pointers > 0 { @@ -1343,7 +1343,7 @@ fn generic_simd_intrinsic( // This counts how many pointers fn ptr_count(t: ty::Ty) -> usize { match t.sty { - ty::TyRawPtr(p) => 1 + ptr_count(p.ty), + ty::RawPtr(p) => 1 + ptr_count(p.ty), _ => 0, } } @@ -1351,7 +1351,7 @@ fn generic_simd_intrinsic( // Non-ptr type fn non_ptr(t: ty::Ty) -> ty::Ty { match t.sty { - ty::TyRawPtr(p) => non_ptr(p.ty), + ty::RawPtr(p) => non_ptr(p.ty), _ => t, } } @@ -1359,7 +1359,7 @@ fn generic_simd_intrinsic( // The second argument must be a simd vector with an element type that's a pointer // to the element type of the first argument let (pointer_count, underlying_ty) = match arg_tys[1].simd_type(tcx).sty { - ty::TyRawPtr(p) if p.ty == in_elem => (ptr_count(arg_tys[1].simd_type(tcx)), + ty::RawPtr(p) if p.ty == in_elem => (ptr_count(arg_tys[1].simd_type(tcx)), non_ptr(arg_tys[1].simd_type(tcx))), _ => { require!(false, "expected element type `{}` of second argument `{}` \ @@ -1376,7 +1376,7 @@ fn generic_simd_intrinsic( // The element type of the third argument must be a signed integer type of any width: match arg_tys[2].simd_type(tcx).sty { - ty::TyInt(_) => (), + ty::Int(_) => (), _ => { require!(false, "expected element type `{}` of third argument `{}` \ to be a signed integer type", @@ -1439,7 +1439,7 @@ fn generic_simd_intrinsic( // This counts how many pointers fn ptr_count(t: ty::Ty) -> usize { match t.sty { - ty::TyRawPtr(p) => 1 + ptr_count(p.ty), + ty::RawPtr(p) => 1 + ptr_count(p.ty), _ => 0, } } @@ -1447,7 +1447,7 @@ fn generic_simd_intrinsic( // Non-ptr type fn non_ptr(t: ty::Ty) -> ty::Ty { match t.sty { - ty::TyRawPtr(p) => non_ptr(p.ty), + ty::RawPtr(p) => non_ptr(p.ty), _ => t, } } @@ -1455,7 +1455,7 @@ fn generic_simd_intrinsic( // The second argument must be a simd vector with an element type that's a pointer // to the element type of the first argument let (pointer_count, underlying_ty) = match arg_tys[1].simd_type(tcx).sty { - ty::TyRawPtr(p) if p.ty == in_elem && p.mutbl == hir::MutMutable + ty::RawPtr(p) if p.ty == in_elem && p.mutbl == hir::MutMutable => (ptr_count(arg_tys[1].simd_type(tcx)), non_ptr(arg_tys[1].simd_type(tcx))), _ => { @@ -1473,7 +1473,7 @@ fn generic_simd_intrinsic( // The element type of the third argument must be a signed integer type of any width: match arg_tys[2].simd_type(tcx).sty { - ty::TyInt(_) => (), + ty::Int(_) => (), _ => { require!(false, "expected element type `{}` of third argument `{}` \ to be a signed integer type", @@ -1522,7 +1522,7 @@ fn generic_simd_intrinsic( "expected return type `{}` (element of input `{}`), found `{}`", in_elem, in_ty, ret_ty); return match in_elem.sty { - ty::TyInt(_) | ty::TyUint(_) => { + ty::Int(_) | ty::Uint(_) => { let r = bx.$integer_reduce(args[0].immediate()); if $ordered { // if overflow occurs, the result is the @@ -1536,7 +1536,7 @@ fn generic_simd_intrinsic( Ok(bx.$integer_reduce(args[0].immediate())) } }, - ty::TyFloat(f) => { + ty::Float(f) => { // ordered arithmetic reductions take an accumulator let acc = if $ordered { let acc = args[1].immediate(); @@ -1597,13 +1597,13 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#, "expected return type `{}` (element of input `{}`), found `{}`", in_elem, in_ty, ret_ty); return match in_elem.sty { - ty::TyInt(_i) => { + ty::Int(_i) => { Ok(bx.$int_red(args[0].immediate(), true)) }, - ty::TyUint(_u) => { + ty::Uint(_u) => { Ok(bx.$int_red(args[0].immediate(), false)) }, - ty::TyFloat(_f) => { + ty::Float(_f) => { Ok(bx.$float_red(args[0].immediate())) } _ => { @@ -1632,7 +1632,7 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#, args[0].immediate() } else { match in_elem.sty { - ty::TyInt(_) | ty::TyUint(_) => {}, + ty::Int(_) | ty::Uint(_) => {}, _ => { return_error!("unsupported {} from `{}` with element `{}` to `{}`", $name, in_ty, in_elem, ret_ty) @@ -1645,7 +1645,7 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#, bx.trunc(args[0].immediate(), i1xn) }; return match in_elem.sty { - ty::TyInt(_) | ty::TyUint(_) => { + ty::Int(_) | ty::Uint(_) => { let r = bx.$red(input); Ok( if !$boolean { @@ -1688,15 +1688,15 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#, let (in_style, in_width) = match in_elem.sty { // vectors of pointer-sized integers should've been // disallowed before here, so this unwrap is safe. - ty::TyInt(i) => (Style::Int(true), i.bit_width().unwrap()), - ty::TyUint(u) => (Style::Int(false), u.bit_width().unwrap()), - ty::TyFloat(f) => (Style::Float, f.bit_width()), + ty::Int(i) => (Style::Int(true), i.bit_width().unwrap()), + ty::Uint(u) => (Style::Int(false), u.bit_width().unwrap()), + ty::Float(f) => (Style::Float, f.bit_width()), _ => (Style::Unsupported, 0) }; let (out_style, out_width) = match out_elem.sty { - ty::TyInt(i) => (Style::Int(true), i.bit_width().unwrap()), - ty::TyUint(u) => (Style::Int(false), u.bit_width().unwrap()), - ty::TyFloat(f) => (Style::Float, f.bit_width()), + ty::Int(i) => (Style::Int(true), i.bit_width().unwrap()), + ty::Uint(u) => (Style::Int(false), u.bit_width().unwrap()), + ty::Float(f) => (Style::Float, f.bit_width()), _ => (Style::Unsupported, 0) }; @@ -1757,18 +1757,18 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#, } } arith! { - simd_add: TyUint, TyInt => add, TyFloat => fadd; - simd_sub: TyUint, TyInt => sub, TyFloat => fsub; - simd_mul: TyUint, TyInt => mul, TyFloat => fmul; - simd_div: TyUint => udiv, TyInt => sdiv, TyFloat => fdiv; - simd_rem: TyUint => urem, TyInt => srem, TyFloat => frem; - simd_shl: TyUint, TyInt => shl; - simd_shr: TyUint => lshr, TyInt => ashr; - simd_and: TyUint, TyInt => and; - simd_or: TyUint, TyInt => or; - simd_xor: TyUint, TyInt => xor; - simd_fmax: TyFloat => maxnum; - simd_fmin: TyFloat => minnum; + simd_add: Uint, Int => add, Float => fadd; + simd_sub: Uint, Int => sub, Float => fsub; + simd_mul: Uint, Int => mul, Float => fmul; + simd_div: Uint => udiv, Int => sdiv, Float => fdiv; + simd_rem: Uint => urem, Int => srem, Float => frem; + simd_shl: Uint, Int => shl; + simd_shr: Uint => lshr, Int => ashr; + simd_and: Uint, Int => and; + simd_or: Uint, Int => or; + simd_xor: Uint, Int => xor; + simd_fmax: Float => maxnum; + simd_fmin: Float => minnum; } span_bug!(span, "unknown SIMD intrinsic"); } @@ -1779,7 +1779,7 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#, // stuffs. fn int_type_width_signed(ty: Ty, cx: &CodegenCx) -> Option<(u64, bool)> { match ty.sty { - ty::TyInt(t) => Some((match t { + ty::Int(t) => Some((match t { ast::IntTy::Isize => cx.tcx.sess.target.isize_ty.bit_width().unwrap() as u64, ast::IntTy::I8 => 8, ast::IntTy::I16 => 16, @@ -1787,7 +1787,7 @@ fn int_type_width_signed(ty: Ty, cx: &CodegenCx) -> Option<(u64, bool)> { ast::IntTy::I64 => 64, ast::IntTy::I128 => 128, }, true)), - ty::TyUint(t) => Some((match t { + ty::Uint(t) => Some((match t { ast::UintTy::Usize => cx.tcx.sess.target.usize_ty.bit_width().unwrap() as u64, ast::UintTy::U8 => 8, ast::UintTy::U16 => 16, @@ -1801,9 +1801,9 @@ 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 { +fn float_type_width<'tcx>(sty: &ty::TyKind<'tcx>) -> Option { match *sty { - ty::TyFloat(t) => Some(t.bit_width() as u64), + ty::Float(t) => Some(t.bit_width() as u64), _ => None, } } diff --git a/src/librustc_codegen_llvm/mir/analyze.rs b/src/librustc_codegen_llvm/mir/analyze.rs index 993138aee1cec..0206744eb2b6b 100644 --- a/src/librustc_codegen_llvm/mir/analyze.rs +++ b/src/librustc_codegen_llvm/mir/analyze.rs @@ -131,7 +131,7 @@ impl Visitor<'tcx> for LocalAnalyzer<'mir, 'a, 'll, 'tcx> { func: mir::Operand::Constant(ref c), ref args, .. } => match c.ty.sty { - ty::TyFnDef(did, _) => Some((did, args)), + ty::FnDef(did, _) => Some((did, args)), _ => None, }, _ => None, diff --git a/src/librustc_codegen_llvm/mir/block.rs b/src/librustc_codegen_llvm/mir/block.rs index 02de587467277..a534b4e478fb7 100644 --- a/src/librustc_codegen_llvm/mir/block.rs +++ b/src/librustc_codegen_llvm/mir/block.rs @@ -296,7 +296,7 @@ impl FunctionCx<'a, 'll, 'tcx> { &args1[..] }; let (drop_fn, fn_ty) = match ty.sty { - ty::TyDynamic(..) => { + ty::Dynamic(..) => { let fn_ty = drop_fn.ty(bx.cx.tcx); let sig = common::ty_fn_sig(bx.cx, fn_ty); let sig = bx.tcx().normalize_erasing_late_bound_regions( @@ -417,14 +417,14 @@ impl FunctionCx<'a, 'll, 'tcx> { let callee = self.codegen_operand(&bx, func); let (instance, mut llfn) = match callee.layout.ty.sty { - ty::TyFnDef(def_id, substs) => { + ty::FnDef(def_id, substs) => { (Some(ty::Instance::resolve(bx.cx.tcx, ty::ParamEnv::reveal_all(), def_id, substs).unwrap()), None) } - ty::TyFnPtr(_) => { + ty::FnPtr(_) => { (None, Some(callee.immediate())) } _ => bug!("{} is not callable", callee.layout.ty) diff --git a/src/librustc_codegen_llvm/mir/constant.rs b/src/librustc_codegen_llvm/mir/constant.rs index 6774ce818c1f6..2657543b2d167 100644 --- a/src/librustc_codegen_llvm/mir/constant.rs +++ b/src/librustc_codegen_llvm/mir/constant.rs @@ -182,7 +182,7 @@ impl FunctionCx<'a, 'll, 'tcx> { .and_then(|c| { let field_ty = c.ty.builtin_index().unwrap(); let fields = match c.ty.sty { - ty::TyArray(_, n) => n.unwrap_usize(bx.tcx()), + ty::Array(_, n) => n.unwrap_usize(bx.tcx()), ref other => bug!("invalid simd shuffle type: {}", other), }; let values: Result, Lrc<_>> = (0..fields).map(|field| { diff --git a/src/librustc_codegen_llvm/mir/mod.rs b/src/librustc_codegen_llvm/mir/mod.rs index d3cb97f65ce26..9e65144bd60a1 100644 --- a/src/librustc_codegen_llvm/mir/mod.rs +++ b/src/librustc_codegen_llvm/mir/mod.rs @@ -467,7 +467,7 @@ fn arg_local_refs( let arg_ty = fx.monomorphize(&arg_decl.ty); let tupled_arg_tys = match arg_ty.sty { - ty::TyTuple(ref tys) => tys, + ty::Tuple(ref tys) => tys, _ => bug!("spread argument isn't a tuple?!") }; @@ -592,14 +592,14 @@ fn arg_local_refs( // Or is it the closure environment? let (closure_layout, env_ref) = match arg.layout.ty.sty { - ty::TyRawPtr(ty::TypeAndMut { ty, .. }) | - ty::TyRef(_, ty, _) => (bx.cx.layout_of(ty), true), + ty::RawPtr(ty::TypeAndMut { ty, .. }) | + ty::Ref(_, ty, _) => (bx.cx.layout_of(ty), true), _ => (arg.layout, false) }; let (def_id, upvar_substs) = match closure_layout.ty.sty { - ty::TyClosure(def_id, substs) => (def_id, UpvarSubsts::Closure(substs)), - ty::TyGenerator(def_id, substs, _) => (def_id, UpvarSubsts::Generator(substs)), + ty::Closure(def_id, substs) => (def_id, UpvarSubsts::Closure(substs)), + ty::Generator(def_id, substs, _) => (def_id, UpvarSubsts::Generator(substs)), _ => bug!("upvar_decls with non-closure arg0 type `{}`", closure_layout.ty) }; let upvar_tys = upvar_substs.upvar_tys(def_id, tcx); @@ -639,7 +639,7 @@ fn arg_local_refs( // a pointer in an alloca for debuginfo atm. let mut ops = if env_ref || env_alloca { &ops[..] } else { &ops[1..] }; - let ty = if let (true, &ty::TyRef(_, ty, _)) = (decl.by_ref, &ty.sty) { + let ty = if let (true, &ty::Ref(_, ty, _)) = (decl.by_ref, &ty.sty) { ty } else { ops = &ops[..ops.len() - 1]; diff --git a/src/librustc_codegen_llvm/mir/place.rs b/src/librustc_codegen_llvm/mir/place.rs index 89d41dcc8e994..ce3292eaa426d 100644 --- a/src/librustc_codegen_llvm/mir/place.rs +++ b/src/librustc_codegen_llvm/mir/place.rs @@ -211,8 +211,8 @@ impl PlaceRef<'ll, 'tcx> { return simple(); } _ if !field.is_unsized() => return simple(), - ty::TySlice(..) | ty::TyStr | ty::TyForeign(..) => return simple(), - ty::TyAdt(def, _) => { + ty::Slice(..) | ty::Str | ty::Foreign(..) => return simple(), + ty::Adt(def, _) => { if def.repr.packed() { // FIXME(eddyb) generalize the adjustment when we // start supporting packing to larger alignments. diff --git a/src/librustc_codegen_llvm/mir/rvalue.rs b/src/librustc_codegen_llvm/mir/rvalue.rs index 84427d8b40f79..25f32360815e7 100644 --- a/src/librustc_codegen_llvm/mir/rvalue.rs +++ b/src/librustc_codegen_llvm/mir/rvalue.rs @@ -214,7 +214,7 @@ impl FunctionCx<'a, 'll, 'tcx> { let val = match *kind { mir::CastKind::ReifyFnPointer => { match operand.layout.ty.sty { - ty::TyFnDef(def_id, substs) => { + ty::FnDef(def_id, substs) => { if bx.cx.tcx.has_attr(def_id, "rustc_args_required_const") { bug!("reifying a fn ptr that requires \ const arguments"); @@ -229,7 +229,7 @@ impl FunctionCx<'a, 'll, 'tcx> { } mir::CastKind::ClosureFnPointer => { match operand.layout.ty.sty { - ty::TyClosure(def_id, substs) => { + ty::Closure(def_id, substs) => { let instance = monomorphize::resolve_closure( bx.cx.tcx, def_id, substs, ty::ClosureKind::FnOnce); OperandValue::Immediate(callee::get_fn(bx.cx, instance)) @@ -545,7 +545,7 @@ impl FunctionCx<'a, 'll, 'tcx> { // because codegen_place() panics if Local is operand. if let mir::Place::Local(index) = *place { if let LocalRef::Operand(Some(op)) = self.locals[index] { - if let ty::TyArray(_, n) = op.layout.ty.sty { + if let ty::Array(_, n) = op.layout.ty.sty { let n = n.unwrap_usize(bx.cx.tcx); return common::C_usize(bx.cx, n); } @@ -753,60 +753,60 @@ enum OverflowOp { fn get_overflow_intrinsic(oop: OverflowOp, bx: &Builder<'_, 'll, '_>, ty: Ty) -> &'ll Value { use syntax::ast::IntTy::*; use syntax::ast::UintTy::*; - use rustc::ty::{TyInt, TyUint}; + use rustc::ty::{Int, Uint}; let tcx = bx.tcx(); let new_sty = match ty.sty { - TyInt(Isize) => TyInt(tcx.sess.target.isize_ty), - TyUint(Usize) => TyUint(tcx.sess.target.usize_ty), - ref t @ TyUint(_) | ref t @ TyInt(_) => t.clone(), + Int(Isize) => Int(tcx.sess.target.isize_ty), + Uint(Usize) => Uint(tcx.sess.target.usize_ty), + ref t @ Uint(_) | ref t @ Int(_) => t.clone(), _ => panic!("tried to get overflow intrinsic for op applied to non-int type") }; let name = match oop { OverflowOp::Add => match new_sty { - TyInt(I8) => "llvm.sadd.with.overflow.i8", - TyInt(I16) => "llvm.sadd.with.overflow.i16", - TyInt(I32) => "llvm.sadd.with.overflow.i32", - TyInt(I64) => "llvm.sadd.with.overflow.i64", - TyInt(I128) => "llvm.sadd.with.overflow.i128", - - TyUint(U8) => "llvm.uadd.with.overflow.i8", - TyUint(U16) => "llvm.uadd.with.overflow.i16", - TyUint(U32) => "llvm.uadd.with.overflow.i32", - TyUint(U64) => "llvm.uadd.with.overflow.i64", - TyUint(U128) => "llvm.uadd.with.overflow.i128", + Int(I8) => "llvm.sadd.with.overflow.i8", + Int(I16) => "llvm.sadd.with.overflow.i16", + Int(I32) => "llvm.sadd.with.overflow.i32", + Int(I64) => "llvm.sadd.with.overflow.i64", + Int(I128) => "llvm.sadd.with.overflow.i128", + + Uint(U8) => "llvm.uadd.with.overflow.i8", + Uint(U16) => "llvm.uadd.with.overflow.i16", + Uint(U32) => "llvm.uadd.with.overflow.i32", + Uint(U64) => "llvm.uadd.with.overflow.i64", + Uint(U128) => "llvm.uadd.with.overflow.i128", _ => unreachable!(), }, OverflowOp::Sub => match new_sty { - TyInt(I8) => "llvm.ssub.with.overflow.i8", - TyInt(I16) => "llvm.ssub.with.overflow.i16", - TyInt(I32) => "llvm.ssub.with.overflow.i32", - TyInt(I64) => "llvm.ssub.with.overflow.i64", - TyInt(I128) => "llvm.ssub.with.overflow.i128", - - TyUint(U8) => "llvm.usub.with.overflow.i8", - TyUint(U16) => "llvm.usub.with.overflow.i16", - TyUint(U32) => "llvm.usub.with.overflow.i32", - TyUint(U64) => "llvm.usub.with.overflow.i64", - TyUint(U128) => "llvm.usub.with.overflow.i128", + Int(I8) => "llvm.ssub.with.overflow.i8", + Int(I16) => "llvm.ssub.with.overflow.i16", + Int(I32) => "llvm.ssub.with.overflow.i32", + Int(I64) => "llvm.ssub.with.overflow.i64", + Int(I128) => "llvm.ssub.with.overflow.i128", + + Uint(U8) => "llvm.usub.with.overflow.i8", + Uint(U16) => "llvm.usub.with.overflow.i16", + Uint(U32) => "llvm.usub.with.overflow.i32", + Uint(U64) => "llvm.usub.with.overflow.i64", + Uint(U128) => "llvm.usub.with.overflow.i128", _ => unreachable!(), }, OverflowOp::Mul => match new_sty { - TyInt(I8) => "llvm.smul.with.overflow.i8", - TyInt(I16) => "llvm.smul.with.overflow.i16", - TyInt(I32) => "llvm.smul.with.overflow.i32", - TyInt(I64) => "llvm.smul.with.overflow.i64", - TyInt(I128) => "llvm.smul.with.overflow.i128", - - TyUint(U8) => "llvm.umul.with.overflow.i8", - TyUint(U16) => "llvm.umul.with.overflow.i16", - TyUint(U32) => "llvm.umul.with.overflow.i32", - TyUint(U64) => "llvm.umul.with.overflow.i64", - TyUint(U128) => "llvm.umul.with.overflow.i128", + Int(I8) => "llvm.smul.with.overflow.i8", + Int(I16) => "llvm.smul.with.overflow.i16", + Int(I32) => "llvm.smul.with.overflow.i32", + Int(I64) => "llvm.smul.with.overflow.i64", + Int(I128) => "llvm.smul.with.overflow.i128", + + Uint(U8) => "llvm.umul.with.overflow.i8", + Uint(U16) => "llvm.umul.with.overflow.i16", + Uint(U32) => "llvm.umul.with.overflow.i32", + Uint(U64) => "llvm.umul.with.overflow.i64", + Uint(U128) => "llvm.umul.with.overflow.i128", _ => unreachable!(), }, diff --git a/src/librustc_codegen_llvm/type_of.rs b/src/librustc_codegen_llvm/type_of.rs index 69d91b327283d..e6907030ae635 100644 --- a/src/librustc_codegen_llvm/type_of.rs +++ b/src/librustc_codegen_llvm/type_of.rs @@ -56,19 +56,19 @@ fn uncached_llvm_type<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, } let name = match layout.ty.sty { - ty::TyClosure(..) | - ty::TyGenerator(..) | - ty::TyAdt(..) | + ty::Closure(..) | + ty::Generator(..) | + ty::Adt(..) | // FIXME(eddyb) producing readable type names for trait objects can result // in problematically distinct types due to HRTB and subtyping (see #47638). - // ty::TyDynamic(..) | - ty::TyForeign(..) | - ty::TyStr => { + // ty::Dynamic(..) | + ty::Foreign(..) | + ty::Str => { let mut name = String::with_capacity(32); let printer = DefPathBasedNames::new(cx.tcx, true, true); printer.push_type_name(layout.ty, &mut name); match (&layout.ty.sty, &layout.variants) { - (&ty::TyAdt(def, _), &layout::Variants::Single { index }) => { + (&ty::Adt(def, _), &layout::Variants::Single { index }) => { if def.is_enum() && !def.variants.is_empty() { write!(&mut name, "::{}", def.variants[index].name).unwrap(); } @@ -252,14 +252,14 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyLayout<'tcx> { return llty; } let llty = match self.ty.sty { - ty::TyRef(_, ty, _) | - ty::TyRawPtr(ty::TypeAndMut { ty, .. }) => { + ty::Ref(_, ty, _) | + ty::RawPtr(ty::TypeAndMut { ty, .. }) => { cx.layout_of(ty).llvm_type(cx).ptr_to() } - ty::TyAdt(def, _) if def.is_box() => { + ty::Adt(def, _) if def.is_box() => { cx.layout_of(self.ty.boxed_ty()).llvm_type(cx).ptr_to() } - ty::TyFnPtr(sig) => { + ty::FnPtr(sig) => { let sig = cx.tcx.normalize_erasing_late_bound_regions( ty::ParamEnv::reveal_all(), &sig, @@ -344,11 +344,11 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyLayout<'tcx> { // HACK(eddyb) special-case fat pointers until LLVM removes // pointee types, to avoid bitcasting every `OperandRef::deref`. match self.ty.sty { - ty::TyRef(..) | - ty::TyRawPtr(_) => { + ty::Ref(..) | + ty::RawPtr(_) => { return self.field(cx, index).llvm_type(cx); } - ty::TyAdt(def, _) if def.is_box() => { + ty::Adt(def, _) if def.is_box() => { let ptr_ty = cx.tcx.mk_mut_ptr(self.ty.boxed_ty()); return cx.layout_of(ptr_ty).scalar_pair_element_llvm_type(cx, index, immediate); } @@ -410,7 +410,7 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyLayout<'tcx> { let mut result = None; match self.ty.sty { - ty::TyRawPtr(mt) if offset.bytes() == 0 => { + ty::RawPtr(mt) if offset.bytes() == 0 => { let (size, align) = cx.size_and_align_of(mt.ty); result = Some(PointeeInfo { size, @@ -419,7 +419,7 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyLayout<'tcx> { }); } - ty::TyRef(_, ty, mt) if offset.bytes() == 0 => { + ty::Ref(_, ty, mt) if offset.bytes() == 0 => { let (size, align) = cx.size_and_align_of(ty); let kind = match mt { @@ -497,7 +497,7 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyLayout<'tcx> { // FIXME(eddyb) This should be for `ptr::Unique`, not `Box`. if let Some(ref mut pointee) = result { - if let ty::TyAdt(def, _) = self.ty.sty { + if let ty::Adt(def, _) = self.ty.sty { if def.is_box() && offset.bytes() == 0 { pointee.safe = Some(PointerKind::UniqueOwned); } diff --git a/src/librustc_codegen_utils/symbol_names.rs b/src/librustc_codegen_utils/symbol_names.rs index d834a6502b280..33ce06217a46e 100644 --- a/src/librustc_codegen_utils/symbol_names.rs +++ b/src/librustc_codegen_utils/symbol_names.rs @@ -171,7 +171,7 @@ fn get_symbol_hash<'a, 'tcx>( // If this is a function, we hash the signature as well. // This is not *strictly* needed, but it may help in some // situations, see the `run-make/a-b-a-linker-guard` test. - if let ty::TyFnDef(..) = item_type.sty { + if let ty::FnDef(..) = item_type.sty { item_type.fn_sig(tcx).hash_stable(&mut hcx, &mut hasher); } diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 681e919580567..c26d8555214c1 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -1320,7 +1320,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutableTransmutes { let msg = "mutating transmuted &mut T from &T may cause undefined behavior, \ consider instead using an UnsafeCell"; match get_transmute_from_to(cx, expr) { - Some((&ty::TyRef(_, _, from_mt), &ty::TyRef(_, _, to_mt))) => { + Some((&ty::Ref(_, _, from_mt), &ty::Ref(_, _, to_mt))) => { if to_mt == hir::Mutability::MutMutable && from_mt == hir::Mutability::MutImmutable { cx.span_lint(MUTABLE_TRANSMUTES, expr.span, msg); @@ -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 { diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index a37b2eb5fd449..d9f6e7de5b5e4 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -84,7 +84,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { } hir::ExprKind::Lit(ref lit) => { match cx.tables.node_id_to_type(e.hir_id).sty { - ty::TyInt(t) => { + ty::Int(t) => { match lit.node { ast::LitKind::Int(v, ast::LitIntType::Signed(_)) | ast::LitKind::Int(v, ast::LitIntType::Unsuffixed) => { @@ -104,7 +104,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { report_bin_hex_error( cx, e, - ty::TyInt(t), + ty::Int(t), repr_str, v, negative, @@ -122,7 +122,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { _ => bug!(), }; } - ty::TyUint(t) => { + ty::Uint(t) => { let uint_type = if let ast::UintTy::Usize = t { cx.sess().target.usize_ty } else { @@ -139,7 +139,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { let parent_id = cx.tcx.hir.get_parent_node(e.id); if let hir_map::NodeExpr(parent_expr) = cx.tcx.hir.get(parent_id) { if let hir::ExprKind::Cast(..) = parent_expr.node { - if let ty::TyChar = cx.tables.expr_ty(parent_expr).sty { + if let ty::Char = cx.tables.expr_ty(parent_expr).sty { let mut err = cx.struct_span_lint( OVERFLOWING_LITERALS, parent_expr.span, @@ -159,7 +159,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { report_bin_hex_error( cx, e, - ty::TyUint(t), + ty::Uint(t), repr_str, lit_val, false, @@ -173,7 +173,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { ); } } - ty::TyFloat(t) => { + ty::Float(t) => { let is_infinite = match lit.node { ast::LitKind::Float(v, _) | ast::LitKind::FloatUnsuffixed(v) => { @@ -256,7 +256,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { // the comparison let norm_binop = if swap { rev_binop(binop) } else { binop }; match cx.tables.node_id_to_type(expr.hir_id).sty { - ty::TyInt(int_ty) => { + ty::Int(int_ty) => { let (min, max) = int_ty_range(int_ty); let lit_val: i128 = match lit.node { hir::ExprKind::Lit(ref li) => { @@ -270,7 +270,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { }; is_valid(norm_binop, lit_val, min, max) } - ty::TyUint(uint_ty) => { + ty::Uint(uint_ty) => { let (min, max) :(u128, u128) = uint_ty_range(uint_ty); let lit_val: u128 = match lit.node { hir::ExprKind::Lit(ref li) => { @@ -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 { @@ -348,13 +348,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { } } match t { - &ty::TyInt(i) => find_fit!(i, val, negative, + &ty::Int(i) => find_fit!(i, val, negative, I8 => [U8] => [I16, I32, I64, I128], I16 => [U16] => [I32, I64, I128], I32 => [U32] => [I64, I128], I64 => [U64] => [I128], I128 => [U128] => []), - &ty::TyUint(u) => find_fit!(u, val, negative, + &ty::Uint(u) => find_fit!(u, val, negative, U8 => [U8, U16, U32, U64, U128] => [], U16 => [U16, U32, U64, U128] => [], U32 => [U32, U64, U128] => [], @@ -367,19 +367,19 @@ 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, ) { let (t, actually) = match ty { - ty::TyInt(t) => { + ty::Int(t) => { let ity = attr::IntType::SignedInt(t); let bits = layout::Integer::from_attr(cx.tcx, ity).size().bits(); let actually = (val << (128 - bits)) as i128 >> (128 - bits); (format!("{:?}", t), actually.to_string()) } - ty::TyUint(t) => { + ty::Uint(t) => { let ity = attr::IntType::UnsignedInt(t); let bits = layout::Integer::from_attr(cx.tcx, ity).size().bits(); let actually = (val << (128 - bits)) >> (128 - bits); @@ -460,10 +460,10 @@ fn is_repr_nullable_ptr<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, if def.variants[data_idx].fields.len() == 1 { match def.variants[data_idx].fields[0].ty(tcx, substs).sty { - ty::TyFnPtr(_) => { + ty::FnPtr(_) => { return true; } - ty::TyRef(..) => { + ty::Ref(..) => { return true; } _ => {} @@ -492,7 +492,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { } match ty.sty { - ty::TyAdt(def, substs) => { + ty::Adt(def, substs) => { if def.is_phantom_data() { return FfiPhantom(ty); } @@ -633,51 +633,51 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { } } - ty::TyChar => FfiUnsafe { + ty::Char => FfiUnsafe { ty: ty, reason: "the `char` type has no C equivalent", help: Some("consider using `u32` or `libc::wchar_t` instead"), }, - ty::TyInt(ast::IntTy::I128) | ty::TyUint(ast::UintTy::U128) => FfiUnsafe { + ty::Int(ast::IntTy::I128) | ty::Uint(ast::UintTy::U128) => FfiUnsafe { ty: ty, reason: "128-bit integers don't currently have a known stable ABI", help: None, }, // Primitive types with a stable representation. - ty::TyBool | ty::TyInt(..) | ty::TyUint(..) | ty::TyFloat(..) | ty::TyNever => FfiSafe, + ty::Bool | ty::Int(..) | ty::Uint(..) | ty::Float(..) | ty::Never => FfiSafe, - ty::TySlice(_) => FfiUnsafe { + ty::Slice(_) => FfiUnsafe { ty: ty, reason: "slices have no C equivalent", help: Some("consider using a raw pointer instead"), }, - ty::TyDynamic(..) => FfiUnsafe { + ty::Dynamic(..) => FfiUnsafe { ty: ty, reason: "trait objects have no C equivalent", help: None, }, - ty::TyStr => FfiUnsafe { + ty::Str => FfiUnsafe { ty: ty, reason: "string slices have no C equivalent", help: Some("consider using `*const u8` and a length instead"), }, - ty::TyTuple(..) => FfiUnsafe { + ty::Tuple(..) => FfiUnsafe { ty: ty, reason: "tuples have unspecified layout", help: Some("consider using a struct instead"), }, - ty::TyRawPtr(ty::TypeAndMut { ty, .. }) | - ty::TyRef(_, ty, _) => self.check_type_for_ffi(cache, ty), + ty::RawPtr(ty::TypeAndMut { ty, .. }) | + ty::Ref(_, ty, _) => self.check_type_for_ffi(cache, ty), - ty::TyArray(ty, _) => self.check_type_for_ffi(cache, ty), + ty::Array(ty, _) => self.check_type_for_ffi(cache, ty), - ty::TyFnPtr(sig) => { + ty::FnPtr(sig) => { match sig.abi() { Abi::Rust | Abi::RustIntrinsic | Abi::PlatformIntrinsic | Abi::RustCall => { return FfiUnsafe { @@ -712,17 +712,17 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { FfiSafe } - ty::TyForeign(..) => FfiSafe, - - ty::TyParam(..) | - ty::TyInfer(..) | - ty::TyError | - ty::TyClosure(..) | - ty::TyGenerator(..) | - ty::TyGeneratorWitness(..) | - ty::TyProjection(..) | - ty::TyAnon(..) | - ty::TyFnDef(..) => bug!("Unexpected type in foreign function"), + ty::Foreign(..) => FfiSafe, + + ty::Param(..) | + ty::Infer(..) | + ty::Error | + ty::Closure(..) | + ty::Generator(..) | + ty::GeneratorWitness(..) | + ty::Projection(..) | + ty::Anon(..) | + ty::FnDef(..) => bug!("Unexpected type in foreign function"), } } @@ -746,7 +746,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { if let Some(s) = help { diag.help(s); } - if let ty::TyAdt(def, _) = unsafe_ty.sty { + if let ty::Adt(def, _) = unsafe_ty.sty { if let Some(sp) = self.cx.tcx.hir.span_if_local(def.did) { diag.span_note(sp, "type defined here"); } diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index 2b8540ea3861a..7a9d18676cf6c 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -60,9 +60,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults { let t = cx.tables.expr_ty(&expr); let ty_warned = match t.sty { - ty::TyTuple(ref tys) if tys.is_empty() => return, - ty::TyNever => return, - ty::TyAdt(def, _) => { + ty::Tuple(ref tys) if tys.is_empty() => return, + ty::Never => return, + ty::Adt(def, _) => { if def.variants.is_empty() { return; } else { diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index f4dd8861e2a2c..f1e7e3de67d04 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -429,7 +429,7 @@ impl<'tcx> EntryKind<'tcx> { EntryKind::Trait(_) => Def::Trait(did), EntryKind::Enum(..) => Def::Enum(did), EntryKind::MacroDef(_) => Def::Macro(did, MacroKind::Bang), - EntryKind::ForeignType => Def::TyForeign(did), + EntryKind::ForeignType => Def::ForeignTy(did), EntryKind::ForeignMod | EntryKind::GlobalAsm | diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index a68c0692eb5e9..44d8d4a727769 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -1342,7 +1342,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { let node_id = self.tcx.hir.as_local_node_id(def_id).unwrap(); let hir_id = self.tcx.hir.node_to_hir_id(node_id); let kind = match tables.node_id_to_type(hir_id).sty { - ty::TyGenerator(def_id, ..) => { + ty::Generator(def_id, ..) => { let layout = self.tcx.generator_layout(def_id); let data = GeneratorData { layout: layout.clone(), @@ -1350,7 +1350,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { EntryKind::Generator(self.lazy(&data)) } - ty::TyClosure(def_id, substs) => { + ty::Closure(def_id, substs) => { let sig = substs.closure_sig(def_id, self.tcx); let data = ClosureData { sig: self.lazy(&sig) }; EntryKind::Closure(self.lazy(&data)) @@ -1865,7 +1865,7 @@ pub fn encode_metadata<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) pub fn get_repr_options<'a, 'tcx, 'gcx>(tcx: &TyCtxt<'a, 'tcx, 'gcx>, did: DefId) -> ReprOptions { let ty = tcx.type_of(did); match ty.sty { - ty::TyAdt(ref def, _) => return def.repr, + ty::Adt(ref def, _) => return def.repr, _ => bug!("{} is not an ADT", ty), } } diff --git a/src/librustc_mir/borrow_check/error_reporting.rs b/src/librustc_mir/borrow_check/error_reporting.rs index 2ae06375af13c..f1df135f7ee83 100644 --- a/src/librustc_mir/borrow_check/error_reporting.rs +++ b/src/librustc_mir/borrow_check/error_reporting.rs @@ -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::Closure(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); @@ -834,19 +834,19 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { self.describe_field_from_ty(&ty.boxed_ty(), field) } else { match ty.sty { - ty::TyAdt(def, _) => if def.is_enum() { + ty::Adt(def, _) => if def.is_enum() { field.index().to_string() } else { def.non_enum_variant().fields[field.index()] .ident .to_string() }, - ty::TyTuple(_) => field.index().to_string(), - ty::TyRef(_, ty, _) | ty::TyRawPtr(ty::TypeAndMut { ty, .. }) => { + ty::Tuple(_) => field.index().to_string(), + ty::Ref(_, ty, _) | ty::RawPtr(ty::TypeAndMut { ty, .. }) => { self.describe_field_from_ty(&ty, field) } - ty::TyArray(ty, _) | ty::TySlice(ty) => self.describe_field_from_ty(&ty, field), - ty::TyClosure(def_id, _) | ty::TyGenerator(def_id, _, _) => { + ty::Array(ty, _) | ty::Slice(ty) => self.describe_field_from_ty(&ty, field), + ty::Closure(def_id, _) | ty::Generator(def_id, _, _) => { // Convert the def-id into a node-id. node-ids are only valid for // the local code in the current crate, so this returns an `Option` in case // the closure comes from another crate. But in that case we wouldn't diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 4390ca371823a..f4071e02f5580 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -935,14 +935,14 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { // individual fields instead. This way if `foo` has a // destructor but `bar` does not, we will only check for // borrows of `x.foo` and not `x.bar`. See #47703. - ty::TyAdt(def, substs) if def.is_struct() && !def.has_dtor(self.tcx) => { + ty::Adt(def, substs) if def.is_struct() && !def.has_dtor(self.tcx) => { def.all_fields() .map(|field| field.ty(gcx, substs)) .enumerate() .for_each(|field| drop_field(self, field)); } // Same as above, but for tuples. - ty::TyTuple(tys) => { + ty::Tuple(tys) => { tys.iter() .cloned() .enumerate() @@ -950,7 +950,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { } // Closures also have disjoint fields, but they are only // directly accessed in the body of the closure. - ty::TyClosure(def, substs) + ty::Closure(def, substs) if *drop_place == Place::Local(Local::new(1)) && !self.mir.upvar_decls.is_empty() => { @@ -961,7 +961,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { } // Generators also have disjoint fields, but they are only // directly accessed in the body of the generator. - ty::TyGenerator(def, substs, _) + ty::Generator(def, substs, _) if *drop_place == Place::Local(Local::new(1)) && !self.mir.upvar_decls.is_empty() => { @@ -978,7 +978,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { // the base case below, we would have a Deep Write due to // the box being `needs_drop`, and that Deep Write would // touch `&mut` data in the box. - ty::TyAdt(def, _) if def.is_box() => { + ty::Adt(def, _) if def.is_box() => { // When/if we add a `&own T` type, this action would // be like running the destructor of the `&own T`. // (And the owner of backing storage referenced by the @@ -1818,7 +1818,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { // be already initialized let tcx = self.tcx; match base.ty(self.mir, tcx).to_ty(tcx).sty { - ty::TyAdt(def, _) if def.has_dtor(tcx) => { + ty::Adt(def, _) if def.has_dtor(tcx) => { // FIXME: analogous code in // check_loans.rs first maps @@ -2062,7 +2062,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { // Check the kind of deref to decide match base_ty.sty { - ty::TyRef(_, _, mutbl) => { + ty::Ref(_, _, mutbl) => { match mutbl { // Shared borrowed data is never mutable hir::MutImmutable => Err(place), @@ -2086,7 +2086,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { } } } - ty::TyRawPtr(tnm) => { + ty::RawPtr(tnm) => { match tnm.mutbl { // `*const` raw pointers are not mutable hir::MutImmutable => return Err(place), diff --git a/src/librustc_mir/borrow_check/move_errors.rs b/src/librustc_mir/borrow_check/move_errors.rs index 5ef647585c38e..497e8e07853fb 100644 --- a/src/librustc_mir/borrow_check/move_errors.rs +++ b/src/librustc_mir/borrow_check/move_errors.rs @@ -261,10 +261,10 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> { .any(|p| p.is_upvar_field_projection(self.mir, &self.tcx) .is_some()); match ty.sty { - ty::TyArray(..) | ty::TySlice(..) => self + ty::Array(..) | ty::Slice(..) => self .tcx .cannot_move_out_of_interior_noncopy(span, ty, None, origin), - ty::TyClosure(def_id, closure_substs) + ty::Closure(def_id, closure_substs) if !self.mir.upvar_decls.is_empty() && is_upvar_field_projection => { let closure_kind_ty = diff --git a/src/librustc_mir/borrow_check/nll/invalidation.rs b/src/librustc_mir/borrow_check/nll/invalidation.rs index dc37c21fdabeb..f233a17597a54 100644 --- a/src/librustc_mir/borrow_check/nll/invalidation.rs +++ b/src/librustc_mir/borrow_check/nll/invalidation.rs @@ -312,26 +312,26 @@ impl<'cg, 'cx, 'tcx, 'gcx> InvalidationGenerator<'cg, 'cx, 'tcx, 'gcx> { // individual fields instead. This way if `foo` has a // destructor but `bar` does not, we will only check for // borrows of `x.foo` and not `x.bar`. See #47703. - ty::TyAdt(def, substs) if def.is_struct() && !def.has_dtor(self.infcx.tcx) => { + ty::Adt(def, substs) if def.is_struct() && !def.has_dtor(self.infcx.tcx) => { def.all_fields() .map(|field| field.ty(gcx, substs)) .enumerate() .for_each(|field| drop_field(self, field)); } // Same as above, but for tuples. - ty::TyTuple(tys) => { + ty::Tuple(tys) => { tys.iter().cloned().enumerate() .for_each(|field| drop_field(self, field)); } // Closures and generators also have disjoint fields, but they are only // directly accessed in the body of the closure/generator. - ty::TyGenerator(def, substs, ..) + ty::Generator(def, substs, ..) if *drop_place == Place::Local(Local::new(1)) && !self.mir.upvar_decls.is_empty() => { substs.upvar_tys(def, self.infcx.tcx).enumerate() .for_each(|field| drop_field(self, field)); } - ty::TyClosure(def, substs) + ty::Closure(def, substs) if *drop_place == Place::Local(Local::new(1)) && !self.mir.upvar_decls.is_empty() => { substs.upvar_tys(def, self.infcx.tcx).enumerate() diff --git a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs index 532c36f427b5a..6177194ab914d 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs @@ -376,7 +376,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { // & // - let's call the lifetime of this reference `'1` ( - ty::TyRef(region, referent_ty, _), + ty::Ref(region, referent_ty, _), hir::TyKind::Rptr(_lifetime, referent_hir_ty), ) => { if region.to_region_vid() == needle_fr { @@ -403,7 +403,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { // Match up something like `Foo<'1>` ( - ty::TyAdt(_adt_def, substs), + ty::Adt(_adt_def, substs), hir::TyKind::Path(hir::QPath::Resolved(None, path)), ) => { if let Some(last_segment) = path.segments.last() { @@ -423,16 +423,16 @@ impl<'tcx> RegionInferenceContext<'tcx> { // The following cases don't have lifetimes, so we // just worry about trying to match up the rustc type // with the HIR types: - (ty::TyTuple(elem_tys), hir::TyKind::Tup(elem_hir_tys)) => { + (ty::Tuple(elem_tys), hir::TyKind::Tup(elem_hir_tys)) => { search_stack.extend(elem_tys.iter().cloned().zip(elem_hir_tys)); } - (ty::TySlice(elem_ty), hir::TyKind::Slice(elem_hir_ty)) - | (ty::TyArray(elem_ty, _), hir::TyKind::Array(elem_hir_ty, _)) => { + (ty::Slice(elem_ty), hir::TyKind::Slice(elem_hir_ty)) + | (ty::Array(elem_ty, _), hir::TyKind::Array(elem_hir_ty, _)) => { search_stack.push((elem_ty, elem_hir_ty)); } - (ty::TyRawPtr(mut_ty), hir::TyKind::Ptr(mut_hir_ty)) => { + (ty::RawPtr(mut_ty), hir::TyKind::Ptr(mut_hir_ty)) => { search_stack.push((mut_ty.ty, &mut_hir_ty.ty)); } diff --git a/src/librustc_mir/borrow_check/nll/type_check/mod.rs b/src/librustc_mir/borrow_check/nll/type_check/mod.rs index 2a78feed84915..2fb5861dff444 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/mod.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/mod.rs @@ -37,7 +37,7 @@ use rustc::mir::*; use rustc::traits::query::type_op; use rustc::traits::query::{Fallible, NoSolution}; use rustc::ty::fold::TypeFoldable; -use rustc::ty::{self, CanonicalTy, RegionVid, ToPolyTraitRef, Ty, TyCtxt, TypeVariants}; +use rustc::ty::{self, CanonicalTy, RegionVid, ToPolyTraitRef, Ty, TyCtxt, TyKind}; use rustc_errors::Diagnostic; use std::fmt; use std::rc::Rc; @@ -320,7 +320,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> { // constraints on `'a` and `'b`. These constraints // would be lost if we just look at the normalized // value. - if let ty::TyFnDef(def_id, substs) = constant.literal.ty.sty { + if let ty::FnDef(def_id, substs) = constant.literal.ty.sty { let tcx = self.tcx(); let type_checker = &mut self.cx; @@ -483,7 +483,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> { } ProjectionElem::Subslice { from, to } => PlaceTy::Ty { ty: match base_ty.sty { - ty::TyArray(inner, size) => { + ty::Array(inner, size) => { let size = size.unwrap_usize(tcx); let min_size = (from as u64) + (to as u64); if let Some(rest_size) = size.checked_sub(min_size) { @@ -497,12 +497,12 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> { ) } } - ty::TySlice(..) => base_ty, + ty::Slice(..) => base_ty, _ => span_mirbug_and_err!(self, place, "slice of non-array {:?}", base_ty), }, }, ProjectionElem::Downcast(adt_def1, index) => match base_ty.sty { - ty::TyAdt(adt_def, substs) if adt_def.is_enum() && adt_def == adt_def1 => { + ty::Adt(adt_def, substs) if adt_def.is_enum() && adt_def == adt_def1 => { if index >= adt_def.variants.len() { PlaceTy::Ty { ty: span_mirbug_and_err!( @@ -578,8 +578,8 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> { variant_index, } => (&adt_def.variants[variant_index], substs), PlaceTy::Ty { ty } => match ty.sty { - ty::TyAdt(adt_def, substs) if !adt_def.is_enum() => (&adt_def.variants[0], substs), - ty::TyClosure(def_id, substs) => { + ty::Adt(adt_def, substs) if !adt_def.is_enum() => (&adt_def.variants[0], substs), + ty::Closure(def_id, substs) => { return match substs.upvar_tys(def_id, tcx).nth(field.index()) { Some(ty) => Ok(ty), None => Err(FieldAccessError::OutOfRange { @@ -587,7 +587,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> { }), } } - ty::TyGenerator(def_id, substs, _) => { + ty::Generator(def_id, substs, _) => { // Try pre-transform fields first (upvars and current state) if let Some(ty) = substs.pre_transforms_tys(def_id, tcx).nth(field.index()) { return Ok(ty); @@ -602,7 +602,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> { }), }; } - ty::TyTuple(tys) => { + ty::Tuple(tys) => { return match tys.get(field.index()) { Some(&ty) => Ok(ty), None => Err(FieldAccessError::OutOfRange { @@ -917,7 +917,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { } => { let place_type = place.ty(mir, tcx).to_ty(tcx); let adt = match place_type.sty { - TypeVariants::TyAdt(adt, _) if adt.is_enum() => adt, + TyKind::Adt(adt, _) if adt.is_enum() => adt, _ => { span_bug!( stmt.source_info.span, @@ -1032,7 +1032,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { let func_ty = func.ty(mir, tcx); debug!("check_terminator: call, func_ty={:?}", func_ty); let sig = match func_ty.sty { - ty::TyFnDef(..) | ty::TyFnPtr(_) => func_ty.fn_sig(tcx), + ty::FnDef(..) | ty::FnPtr(_) => func_ty.fn_sig(tcx), _ => { span_mirbug!(self, term, "call to non-function {:?}", func_ty); return; @@ -1472,7 +1472,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { CastKind::ClosureFnPointer => { let sig = match op.ty(mir, tcx).sty { - ty::TyClosure(def_id, substs) => { + ty::Closure(def_id, substs) => { substs.closure_sig_ty(def_id, tcx).fn_sig(tcx) } _ => bug!(), @@ -1650,7 +1650,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { debug!("add_reborrow_constraint - base_ty = {:?}", base_ty); match base_ty.sty { - ty::TyRef(ref_region, _, mutbl) => { + ty::Ref(ref_region, _, mutbl) => { constraints.outlives_constraints.push(OutlivesConstraint { sup: ref_region.to_region_vid(), sub: borrow_region.to_region_vid(), @@ -1697,11 +1697,11 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { } } } - ty::TyRawPtr(..) => { + ty::RawPtr(..) => { // deref of raw pointer, guaranteed to be valid break; } - ty::TyAdt(def, _) if def.is_box() => { + ty::Adt(def, _) if def.is_box() => { // deref of `Box`, need the base to be valid - propagate } _ => bug!("unexpected deref ty {:?} in {:?}", base_ty, borrowed_place), diff --git a/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs b/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs index ac9bf65b61b0f..deb972ee04611 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs @@ -36,7 +36,7 @@ pub(super) fn sub_types<'tcx>( ty::Variance::Covariant, locations, borrowck_context, - ty::Slice::empty(), + ty::List::empty(), ).relate(&a, &b)?; Ok(()) } @@ -54,7 +54,7 @@ pub(super) fn eq_types<'tcx>( ty::Variance::Invariant, locations, borrowck_context, - ty::Slice::empty(), + ty::List::empty(), ).relate(&a, &b)?; Ok(()) } @@ -325,7 +325,7 @@ impl<'cx, 'bccx, 'gcx, 'tcx> TypeRelation<'cx, 'gcx, 'tcx> fn tys(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> { // Watch out for the case that we are matching a `?T` against the // right-hand side. - if let ty::TyInfer(ty::CanonicalTy(var)) = a.sty { + if let ty::Infer(ty::CanonicalTy(var)) = a.sty { self.equate_var(var, b.into())?; Ok(a) } else { diff --git a/src/librustc_mir/borrow_check/nll/universal_regions.rs b/src/librustc_mir/borrow_check/nll/universal_regions.rs index 765c4cf906e68..8112b71b12752 100644 --- a/src/librustc_mir/borrow_check/nll/universal_regions.rs +++ b/src/librustc_mir/borrow_check/nll/universal_regions.rs @@ -64,7 +64,7 @@ pub struct UniversalRegions<'tcx> { /// The "defining" type for this function, with all universal /// regions instantiated. For a closure or generator, this is the - /// closure type, but for a top-level function it's the `TyFnDef`. + /// closure type, but for a top-level function it's the `FnDef`. pub defining_ty: DefiningTy<'tcx>, /// The return type of this function, with all regions replaced by @@ -437,11 +437,11 @@ impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> { .replace_free_regions_with_nll_infer_vars(FR, &defining_ty); match defining_ty.sty { - ty::TyClosure(def_id, substs) => DefiningTy::Closure(def_id, substs), - ty::TyGenerator(def_id, substs, movability) => { + ty::Closure(def_id, substs) => DefiningTy::Closure(def_id, substs), + ty::Generator(def_id, substs, movability) => { DefiningTy::Generator(def_id, substs, movability) } - ty::TyFnDef(def_id, substs) => DefiningTy::FnDef(def_id, substs), + ty::FnDef(def_id, substs) => DefiningTy::FnDef(def_id, substs), _ => span_bug!( tcx.def_span(self.mir_def_id), "expected defining type for `{:?}`: `{:?}`", @@ -506,7 +506,7 @@ impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> { &self, indices: &UniversalRegionIndices<'tcx>, defining_ty: DefiningTy<'tcx>, - ) -> ty::Binder<&'tcx ty::Slice>> { + ) -> ty::Binder<&'tcx ty::List>> { let tcx = self.infcx.tcx; match defining_ty { DefiningTy::Closure(def_id, substs) => { @@ -524,7 +524,7 @@ impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> { let (&output, tuplized_inputs) = inputs_and_output.split_last().unwrap(); assert_eq!(tuplized_inputs.len(), 1, "multiple closure inputs"); let inputs = match tuplized_inputs[0].sty { - ty::TyTuple(inputs) => inputs, + ty::Tuple(inputs) => inputs, _ => bug!("closure inputs not a tuple: {:?}", tuplized_inputs[0]), }; diff --git a/src/librustc_mir/borrow_check/place_ext.rs b/src/librustc_mir/borrow_check/place_ext.rs index be0091068c2e2..2b4a1553e1a89 100644 --- a/src/librustc_mir/borrow_check/place_ext.rs +++ b/src/librustc_mir/borrow_check/place_ext.rs @@ -54,7 +54,7 @@ impl<'tcx> PlaceExt<'tcx> for Place<'tcx> { // original path into a new variable and // borrowed *that* one, leaving the original // path unborrowed. - ty::TyRawPtr(..) | ty::TyRef(_, _, hir::MutImmutable) => true, + ty::RawPtr(..) | ty::Ref(_, _, hir::MutImmutable) => true, _ => proj.base.ignore_borrow(tcx, mir), } } diff --git a/src/librustc_mir/borrow_check/places_conflict.rs b/src/librustc_mir/borrow_check/places_conflict.rs index 85abec7e7acc4..f791735690922 100644 --- a/src/librustc_mir/borrow_check/places_conflict.rs +++ b/src/librustc_mir/borrow_check/places_conflict.rs @@ -170,7 +170,7 @@ fn place_components_conflict<'gcx, 'tcx>( debug!("places_conflict: shallow access behind ptr"); return false; } - (ProjectionElem::Deref, ty::TyRef(_, _, hir::MutImmutable), _) => { + (ProjectionElem::Deref, ty::Ref(_, _, hir::MutImmutable), _) => { // the borrow goes through a dereference of a shared reference. // // I'm not sure why we are tracking these borrows - shared @@ -329,7 +329,7 @@ fn place_element_conflict<'a, 'gcx: 'tcx, 'tcx>( } (Place::Promoted(p1), Place::Promoted(p2)) => { if p1.0 == p2.0 { - if let ty::TyArray(_, size) = p1.1.sty { + if let ty::Array(_, size) = p1.1.sty { if size.unwrap_usize(tcx) == 0 { // Ignore conflicts with promoted [T; 0]. debug!("place_element_conflict: IGNORE-LEN-0-PROMOTED"); @@ -366,7 +366,7 @@ fn place_element_conflict<'a, 'gcx: 'tcx, 'tcx>( } else { let ty = pi1.base.ty(mir, tcx).to_ty(tcx); match ty.sty { - ty::TyAdt(def, _) if def.is_union() => { + ty::Adt(def, _) if def.is_union() => { // Different fields of a union, we are basically stuck. debug!("place_element_conflict: STUCK-UNION"); Overlap::Arbitrary diff --git a/src/librustc_mir/borrow_check/prefixes.rs b/src/librustc_mir/borrow_check/prefixes.rs index 9b16130d25ec4..8dcc114330621 100644 --- a/src/librustc_mir/borrow_check/prefixes.rs +++ b/src/librustc_mir/borrow_check/prefixes.rs @@ -155,8 +155,8 @@ impl<'cx, 'gcx, 'tcx> Iterator for Prefixes<'cx, 'gcx, 'tcx> { let ty = proj.base.ty(self.mir, self.tcx).to_ty(self.tcx); match ty.sty { - ty::TyRawPtr(_) | - ty::TyRef( + ty::RawPtr(_) | + ty::Ref( _, /*rgn*/ _, /*ty*/ hir::MutImmutable @@ -166,7 +166,7 @@ impl<'cx, 'gcx, 'tcx> Iterator for Prefixes<'cx, 'gcx, 'tcx> { return Some(cursor); } - ty::TyRef( + ty::Ref( _, /*rgn*/ _, /*ty*/ hir::MutMutable, @@ -175,7 +175,7 @@ impl<'cx, 'gcx, 'tcx> Iterator for Prefixes<'cx, 'gcx, 'tcx> { return Some(cursor); } - ty::TyAdt(..) if ty.is_box() => { + ty::Adt(..) if ty.is_box() => { self.next = Some(&proj.base); return Some(cursor); } diff --git a/src/librustc_mir/build/expr/into.rs b/src/librustc_mir/build/expr/into.rs index 59a7f49af8074..2b05e2c023a5c 100644 --- a/src/librustc_mir/build/expr/into.rs +++ b/src/librustc_mir/build/expr/into.rs @@ -216,7 +216,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { // FIXME(canndrew): This is_never should probably be an is_uninhabited let diverges = expr.ty.is_never(); let intrinsic = match ty.sty { - ty::TyFnDef(def_id, _) => { + ty::FnDef(def_id, _) => { let f = ty.fn_sig(this.hir.tcx()); if f.abi() == Abi::RustIntrinsic || f.abi() == Abi::PlatformIntrinsic { diff --git a/src/librustc_mir/build/matches/test.rs b/src/librustc_mir/build/matches/test.rs index 7106e02284da3..15a983635f7ae 100644 --- a/src/librustc_mir/build/matches/test.rs +++ b/src/librustc_mir/build/matches/test.rs @@ -227,7 +227,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { } TestKind::SwitchInt { switch_ty, ref options, indices: _ } => { - let (ret, terminator) = if switch_ty.sty == ty::TyBool { + let (ret, terminator) = if switch_ty.sty == ty::Bool { assert!(options.len() > 0 && options.len() <= 2); let (true_bb, false_bb) = (self.cfg.start_new_block(), self.cfg.start_new_block()); @@ -272,8 +272,8 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { // array, so we can call `<[u8]>::eq` rather than having to find an // `<[u8; N]>::eq`. let unsize = |ty: Ty<'tcx>| match ty.sty { - ty::TyRef(region, rty, _) => match rty.sty { - ty::TyArray(inner_ty, n) => Some((region, inner_ty, n)), + ty::Ref(region, rty, _) => match rty.sty { + ty::Array(inner_ty, n) => Some((region, inner_ty, n)), _ => None, }, _ => None, diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs index c0c431804d8c1..179bc2426ab4a 100644 --- a/src/librustc_mir/build/mod.rs +++ b/src/librustc_mir/build/mod.rs @@ -67,13 +67,13 @@ pub fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Mir<'t let ty = tcx.type_of(tcx.hir.local_def_id(id)); let mut abi = fn_sig.abi; let implicit_argument = match ty.sty { - ty::TyClosure(..) => { + ty::Closure(..) => { // HACK(eddyb) Avoid having RustCall on closures, // as it adds unnecessary (and wrong) auto-tupling. abi = Abi::Rust; Some(ArgInfo(liberated_closure_env_ty(tcx, id, body_id), None, None, None)) } - ty::TyGenerator(..) => { + ty::Generator(..) => { let gen_ty = tcx.body_tables(body_id).node_id_to_type(fn_hir_id); Some(ArgInfo(gen_ty, None, None, None)) } @@ -115,7 +115,7 @@ pub fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Mir<'t let (yield_ty, return_ty) = if body.is_generator { let gen_sig = match ty.sty { - ty::TyGenerator(gen_def_id, gen_substs, ..) => + ty::Generator(gen_def_id, gen_substs, ..) => gen_substs.sig(gen_def_id, tcx), _ => span_bug!(tcx.hir.span(id), "generator w/o generator type: {:?}", ty), @@ -241,7 +241,7 @@ fn liberated_closure_env_ty<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>, let closure_ty = tcx.body_tables(body_id).node_id_to_type(closure_expr_hir_id); let (closure_def_id, closure_substs) = match closure_ty.sty { - ty::TyClosure(closure_def_id, closure_substs) => (closure_def_id, closure_substs), + ty::Closure(closure_def_id, closure_substs) => (closure_def_id, closure_substs), _ => bug!("closure expr does not have closure type: {:?}", closure_ty) }; diff --git a/src/librustc_mir/dataflow/drop_flag_effects.rs b/src/librustc_mir/dataflow/drop_flag_effects.rs index 1cbe0dcc017f9..7af1daae4cad5 100644 --- a/src/librustc_mir/dataflow/drop_flag_effects.rs +++ b/src/librustc_mir/dataflow/drop_flag_effects.rs @@ -61,17 +61,17 @@ fn place_contents_drop_state_cannot_differ<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, place: &mir::Place<'tcx>) -> bool { let ty = place.ty(mir, tcx).to_ty(tcx); match ty.sty { - ty::TyArray(..) => { + ty::Array(..) => { debug!("place_contents_drop_state_cannot_differ place: {:?} ty: {:?} => false", place, ty); false } - ty::TySlice(..) | ty::TyRef(..) | ty::TyRawPtr(..) => { + ty::Slice(..) | ty::Ref(..) | ty::RawPtr(..) => { debug!("place_contents_drop_state_cannot_differ place: {:?} ty: {:?} refd => true", place, ty); true } - ty::TyAdt(def, _) if (def.has_dtor(tcx) && !def.is_box()) || def.is_union() => { + ty::Adt(def, _) if (def.has_dtor(tcx) && !def.is_box()) || def.is_union() => { debug!("place_contents_drop_state_cannot_differ place: {:?} ty: {:?} Drop => true", place, ty); true diff --git a/src/librustc_mir/dataflow/move_paths/builder.rs b/src/librustc_mir/dataflow/move_paths/builder.rs index 60030f2702055..2148363c79712 100644 --- a/src/librustc_mir/dataflow/move_paths/builder.rs +++ b/src/librustc_mir/dataflow/move_paths/builder.rs @@ -134,19 +134,19 @@ impl<'b, 'a, 'gcx, 'tcx> Gatherer<'b, 'a, 'gcx, 'tcx> { let tcx = self.builder.tcx; let place_ty = proj.base.ty(mir, tcx).to_ty(tcx); match place_ty.sty { - ty::TyRef(..) | ty::TyRawPtr(..) => + ty::Ref(..) | ty::RawPtr(..) => return Err(MoveError::cannot_move_out_of( self.loc, BorrowedContent { target_place: place.clone() })), - ty::TyAdt(adt, _) if adt.has_dtor(tcx) && !adt.is_box() => + ty::Adt(adt, _) if adt.has_dtor(tcx) && !adt.is_box() => return Err(MoveError::cannot_move_out_of(self.loc, InteriorOfTypeWithDestructor { container_ty: place_ty })), // move out of union - always move the entire union - ty::TyAdt(adt, _) if adt.is_union() => + ty::Adt(adt, _) if adt.is_union() => return Err(MoveError::UnionMove { path: base }), - ty::TySlice(_) => + ty::Slice(_) => return Err(MoveError::cannot_move_out_of( self.loc, InteriorOfSliceOrArray { @@ -155,7 +155,7 @@ impl<'b, 'a, 'gcx, 'tcx> Gatherer<'b, 'a, 'gcx, 'tcx> { _ => false }, })), - ty::TyArray(..) => match proj.elem { + ty::Array(..) => match proj.elem { ProjectionElem::Index(..) => return Err(MoveError::cannot_move_out_of( self.loc, diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs index b60da286d9555..04a3b5c115f22 100644 --- a/src/librustc_mir/hair/cx/expr.rs +++ b/src/librustc_mir/hair/cx/expr.rs @@ -284,7 +284,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, hir::ExprKind::AddrOf(mutbl, ref expr) => { let region = match expr_ty.sty { - ty::TyRef(r, _, _) => r, + ty::Ref(r, _, _) => r, _ => span_bug!(expr.span, "type of & not region"), }; ExprKind::Borrow { @@ -418,7 +418,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, hir::ExprKind::Struct(ref qpath, ref fields, ref base) => { match expr_ty.sty { - ty::TyAdt(adt, substs) => { + ty::Adt(adt, substs) => { match adt.adt_kind() { AdtKind::Struct | AdtKind::Union => { ExprKind::Adt { @@ -472,8 +472,8 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, hir::ExprKind::Closure(..) => { let closure_ty = cx.tables().expr_ty(expr); let (def_id, substs, movability) = match closure_ty.sty { - ty::TyClosure(def_id, substs) => (def_id, UpvarSubsts::Closure(substs), None), - ty::TyGenerator(def_id, substs, movability) => { + ty::Closure(def_id, substs) => (def_id, UpvarSubsts::Closure(substs), None), + ty::Generator(def_id, substs, movability) => { (def_id, UpvarSubsts::Generator(substs), Some(movability)) } _ => { @@ -775,7 +775,7 @@ fn convert_path_expr<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, match cx.tables().node_id_to_type(expr.hir_id).sty { // A unit struct/variant which is used as a value. // We return a completely different ExprKind here to account for this special case. - ty::TyAdt(adt_def, substs) => { + ty::Adt(adt_def, substs) => { ExprKind::Adt { adt_def, variant_index: adt_def.variant_index_with_id(def_id), @@ -827,7 +827,7 @@ fn convert_var<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, }); let region = cx.tcx.mk_region(region); - let self_expr = if let ty::TyClosure(_, closure_substs) = closure_ty.sty { + let self_expr = if let ty::Closure(_, closure_substs) = closure_ty.sty { match cx.infcx.closure_kind(closure_def_id, closure_substs).unwrap() { ty::ClosureKind::Fn => { let ref_closure_ty = cx.tcx.mk_ref(region, @@ -977,7 +977,7 @@ fn overloaded_place<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, // same region and mutability as the receiver. This holds for // `Deref(Mut)::Deref(_mut)` and `Index(Mut)::index(_mut)`. let (region, mutbl) = match recv_ty.sty { - ty::TyRef(region, _, mutbl) => (region, mutbl), + ty::Ref(region, _, mutbl) => (region, mutbl), _ => span_bug!(expr.span, "overloaded_place: receiver is not a reference"), }; let ref_ty = cx.tcx.mk_ref(region, ty::TypeAndMut { diff --git a/src/librustc_mir/hair/cx/mod.rs b/src/librustc_mir/hair/cx/mod.rs index 79483e454ecea..ef21348cd3ca1 100644 --- a/src/librustc_mir/hair/cx/mod.rs +++ b/src/librustc_mir/hair/cx/mod.rs @@ -188,7 +188,7 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> { } LitKind::FloatUnsuffixed(n) => { let fty = match ty.sty { - ty::TyFloat(fty) => fty, + ty::Float(fty) => fty, _ => bug!() }; parse_float(n, fty) diff --git a/src/librustc_mir/hair/pattern/_match.rs b/src/librustc_mir/hair/pattern/_match.rs index 81f7d439feb25..e9d65caf08743 100644 --- a/src/librustc_mir/hair/pattern/_match.rs +++ b/src/librustc_mir/hair/pattern/_match.rs @@ -206,7 +206,7 @@ struct LiteralExpander; impl<'tcx> PatternFolder<'tcx> for LiteralExpander { fn fold_pattern(&mut self, pat: &Pattern<'tcx>) -> Pattern<'tcx> { match (&pat.ty.sty, &*pat.kind) { - (&ty::TyRef(_, rty, _), &PatternKind::Constant { ref value }) => { + (&ty::Ref(_, rty, _), &PatternKind::Constant { ref value }) => { Pattern { ty: pat.ty, span: pat.span, @@ -381,14 +381,14 @@ impl<'a, 'tcx> MatchCheckCtxt<'a, 'tcx> { fn is_non_exhaustive_enum(&self, ty: Ty<'tcx>) -> bool { match ty.sty { - ty::TyAdt(adt_def, ..) => adt_def.is_enum() && adt_def.is_non_exhaustive(), + ty::Adt(adt_def, ..) => adt_def.is_enum() && adt_def.is_non_exhaustive(), _ => false, } } fn is_local(&self, ty: Ty<'tcx>) -> bool { match ty.sty { - ty::TyAdt(adt_def, ..) => adt_def.did.is_local(), + ty::Adt(adt_def, ..) => adt_def.did.is_local(), _ => false, } } @@ -548,8 +548,8 @@ impl<'tcx> Witness<'tcx> { let mut pats = self.0.drain((len - arity) as usize..).rev(); match ty.sty { - ty::TyAdt(..) | - ty::TyTuple(..) => { + ty::Adt(..) | + ty::Tuple(..) => { let pats = pats.enumerate().map(|(i, p)| { FieldPattern { field: Field::new(i), @@ -557,7 +557,7 @@ impl<'tcx> Witness<'tcx> { } }).collect(); - if let ty::TyAdt(adt, substs) = ty.sty { + if let ty::Adt(adt, substs) = ty.sty { if adt.is_enum() { PatternKind::Variant { adt_def: adt, @@ -573,11 +573,11 @@ impl<'tcx> Witness<'tcx> { } } - ty::TyRef(..) => { + ty::Ref(..) => { PatternKind::Deref { subpattern: pats.nth(0).unwrap() } } - ty::TySlice(_) | ty::TyArray(..) => { + ty::Slice(_) | ty::Array(..) => { PatternKind::Slice { prefix: pats.collect(), slice: None, @@ -619,12 +619,12 @@ fn all_constructors<'a, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>, debug!("all_constructors({:?})", pcx.ty); let exhaustive_integer_patterns = cx.tcx.features().exhaustive_integer_patterns; let ctors = match pcx.ty.sty { - ty::TyBool => { + ty::Bool => { [true, false].iter().map(|&b| { ConstantValue(ty::Const::from_bool(cx.tcx, b)) }).collect() } - ty::TyArray(ref sub_ty, len) if len.assert_usize(cx.tcx).is_some() => { + ty::Array(ref sub_ty, len) if len.assert_usize(cx.tcx).is_some() => { let len = len.unwrap_usize(cx.tcx); if len != 0 && cx.is_uninhabited(sub_ty) { vec![] @@ -633,21 +633,21 @@ fn all_constructors<'a, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>, } } // Treat arrays of a constant but unknown length like slices. - ty::TyArray(ref sub_ty, _) | - ty::TySlice(ref sub_ty) => { + ty::Array(ref sub_ty, _) | + ty::Slice(ref sub_ty) => { if cx.is_uninhabited(sub_ty) { vec![Slice(0)] } else { (0..pcx.max_slice_length+1).map(|length| Slice(length)).collect() } } - ty::TyAdt(def, substs) if def.is_enum() => { + ty::Adt(def, substs) if def.is_enum() => { def.variants.iter() .filter(|v| !cx.is_variant_uninhabited(v, substs)) .map(|v| Variant(v.did)) .collect() } - ty::TyChar if exhaustive_integer_patterns => { + ty::Char if exhaustive_integer_patterns => { let endpoint = |c: char| { let ty = ty::ParamEnv::empty().and(cx.tcx.types.char); ty::Const::from_bits(cx.tcx, c as u128, ty) @@ -658,7 +658,7 @@ fn all_constructors<'a, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>, ConstantRange(endpoint('\u{E000}'), endpoint('\u{10FFFF}'), RangeEnd::Included), ] } - ty::TyInt(ity) if exhaustive_integer_patterns => { + ty::Int(ity) if exhaustive_integer_patterns => { // FIXME(49937): refactor these bit manipulations into interpret. let bits = Integer::from_attr(cx.tcx, SignedInt(ity)).size().bits() as u128; let min = 1u128 << (bits - 1); @@ -668,7 +668,7 @@ fn all_constructors<'a, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>, ty::Const::from_bits(cx.tcx, max as u128, ty), RangeEnd::Included)] } - ty::TyUint(uty) if exhaustive_integer_patterns => { + ty::Uint(uty) if exhaustive_integer_patterns => { // FIXME(49937): refactor these bit manipulations into interpret. let bits = Integer::from_attr(cx.tcx, UnsignedInt(uty)).size().bits() as u128; let max = !0u128 >> (128 - bits); @@ -861,7 +861,7 @@ impl<'tcx> IntRange<'tcx> { // The return value of `signed_bias` should be XORed with an endpoint to encode/decode it. fn signed_bias(tcx: TyCtxt<'_, 'tcx, 'tcx>, ty: Ty<'tcx>) -> u128 { match ty.sty { - ty::TyInt(ity) => { + ty::Int(ity) => { let bits = Integer::from_attr(tcx, SignedInt(ity)).size().bits() as u128; 1u128 << (bits - 1) } @@ -1243,7 +1243,7 @@ fn pat_constructors<'tcx>(cx: &mut MatchCheckCtxt, PatternKind::Constant { value } => Some(vec![ConstantValue(value)]), PatternKind::Range { lo, hi, end } => Some(vec![ConstantRange(lo, hi, end)]), PatternKind::Array { .. } => match pcx.ty.sty { - ty::TyArray(_, length) => Some(vec![ + ty::Array(_, length) => Some(vec![ Slice(length.unwrap_usize(cx.tcx)) ]), _ => span_bug!(pat.span, "bad ty {:?} for array pattern", pcx.ty) @@ -1267,14 +1267,14 @@ fn pat_constructors<'tcx>(cx: &mut MatchCheckCtxt, fn constructor_arity(_cx: &MatchCheckCtxt, ctor: &Constructor, ty: Ty) -> u64 { debug!("constructor_arity({:#?}, {:?})", ctor, ty); match ty.sty { - ty::TyTuple(ref fs) => fs.len() as u64, - ty::TySlice(..) | ty::TyArray(..) => match *ctor { + ty::Tuple(ref fs) => fs.len() as u64, + ty::Slice(..) | ty::Array(..) => match *ctor { Slice(length) => length, ConstantValue(_) => 0, _ => bug!("bad slice pattern {:?} {:?}", ctor, ty) }, - ty::TyRef(..) => 1, - ty::TyAdt(adt, _) => { + ty::Ref(..) => 1, + ty::Adt(adt, _) => { adt.variants[ctor.variant_index_for_adt(adt)].fields.len() as u64 } _ => 0 @@ -1291,14 +1291,14 @@ fn constructor_sub_pattern_tys<'a, 'tcx: 'a>(cx: &MatchCheckCtxt<'a, 'tcx>, { debug!("constructor_sub_pattern_tys({:#?}, {:?})", ctor, ty); match ty.sty { - ty::TyTuple(ref fs) => fs.into_iter().map(|t| *t).collect(), - ty::TySlice(ty) | ty::TyArray(ty, _) => match *ctor { + ty::Tuple(ref fs) => fs.into_iter().map(|t| *t).collect(), + ty::Slice(ty) | ty::Array(ty, _) => match *ctor { Slice(length) => (0..length).map(|_| ty).collect(), ConstantValue(_) => vec![], _ => bug!("bad slice pattern {:?} {:?}", ctor, ty) }, - ty::TyRef(_, rty, _) => vec![rty], - ty::TyAdt(adt, substs) => { + ty::Ref(_, rty, _) => vec![rty], + ty::Adt(adt, substs) => { if adt.is_box() { // Use T as the sub pattern type of Box. vec![substs.type_at(0)] @@ -1382,7 +1382,7 @@ fn slice_pat_covered_by_constructor<'tcx>( fn should_treat_range_exhaustively(tcx: TyCtxt<'_, 'tcx, 'tcx>, ctor: &Constructor<'tcx>) -> bool { if tcx.features().exhaustive_integer_patterns { if let ConstantValue(value) | ConstantRange(value, _, _) = ctor { - if let ty::TyChar | ty::TyInt(_) | ty::TyUint(_) = value.ty.sty { + if let ty::Char | ty::Int(_) | ty::Uint(_) = value.ty.sty { return true; } } diff --git a/src/librustc_mir/hair/pattern/check_match.rs b/src/librustc_mir/hair/pattern/check_match.rs index 7f6298fd17173..604cc61a17ecb 100644 --- a/src/librustc_mir/hair/pattern/check_match.rs +++ b/src/librustc_mir/hair/pattern/check_match.rs @@ -258,8 +258,8 @@ impl<'a, 'tcx> MatchVisitor<'a, 'tcx> { fn conservative_is_uninhabited(&self, scrutinee_ty: Ty<'tcx>) -> bool { // "rustc-1.0-style" uncontentious uninhabitableness check match scrutinee_ty.sty { - ty::TyNever => true, - ty::TyAdt(def, _) => def.variants.is_empty(), + ty::Never => true, + ty::Adt(def, _) => def.variants.is_empty(), _ => false } } @@ -315,7 +315,7 @@ fn check_for_bindings_named_the_same_as_variants(cx: &MatchVisitor, pat: &Pat) { return true; } let pat_ty = cx.tables.pat_ty(p); - if let ty::TyAdt(edef, _) = pat_ty.sty { + if let ty::Adt(edef, _) = pat_ty.sty { if edef.is_enum() && edef.variants.iter().any(|variant| { variant.name == ident.name && variant.ctor_kind == CtorKind::Const }) { diff --git a/src/librustc_mir/hair/pattern/mod.rs b/src/librustc_mir/hair/pattern/mod.rs index 16d6a08981abc..384ee0079dc84 100644 --- a/src/librustc_mir/hair/pattern/mod.rs +++ b/src/librustc_mir/hair/pattern/mod.rs @@ -148,7 +148,7 @@ impl<'tcx> fmt::Display for Pattern<'tcx> { PatternKind::Variant { adt_def, variant_index, .. } => { Some(&adt_def.variants[variant_index]) } - _ => if let ty::TyAdt(adt, _) = self.ty.sty { + _ => if let ty::Adt(adt, _) = self.ty.sty { if !adt.is_enum() { Some(&adt.variants[0]) } else { @@ -165,7 +165,7 @@ impl<'tcx> fmt::Display for Pattern<'tcx> { if let Some(variant) = variant { write!(f, "{}", variant.name)?; - // Only for TyAdt we can have `S {...}`, + // Only for Adt we can have `S {...}`, // which we handle separately here. if variant.ctor_kind == CtorKind::Fictive { write!(f, " {{ ")?; @@ -216,8 +216,8 @@ impl<'tcx> fmt::Display for Pattern<'tcx> { } PatternKind::Deref { ref subpattern } => { match self.ty.sty { - ty::TyAdt(def, _) if def.is_box() => write!(f, "box ")?, - ty::TyRef(_, _, mutbl) => { + ty::Adt(def, _) if def.is_box() => write!(f, "box ")?, + ty::Ref(_, _, mutbl) => { write!(f, "&")?; if mutbl == hir::MutMutable { write!(f, "mut ")?; @@ -413,7 +413,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { PatKind::Slice(ref prefix, ref slice, ref suffix) => { match ty.sty { - ty::TyRef(_, ty, _) => + ty::Ref(_, ty, _) => PatternKind::Deref { subpattern: Pattern { ty, @@ -422,10 +422,10 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { pat.span, ty, prefix, slice, suffix)) }, }, - ty::TySlice(..) | - ty::TyArray(..) => + ty::Slice(..) | + ty::Array(..) => self.slice_or_array_pattern(pat.span, ty, prefix, slice, suffix), - ty::TyError => { // Avoid ICE + ty::Error => { // Avoid ICE return Pattern { span: pat.span, ty, kind: Box::new(PatternKind::Wild) }; } ref sty => @@ -438,7 +438,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { PatKind::Tuple(ref subpatterns, ddpos) => { match ty.sty { - ty::TyTuple(ref tys) => { + ty::Tuple(ref tys) => { let subpatterns = subpatterns.iter() .enumerate_and_adjust(tys.len(), ddpos) @@ -450,7 +450,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { PatternKind::Leaf { subpatterns: subpatterns } } - ty::TyError => { // Avoid ICE (#50577) + ty::Error => { // Avoid ICE (#50577) return Pattern { span: pat.span, ty, kind: Box::new(PatternKind::Wild) }; } ref sty => span_bug!(pat.span, "unexpected type for tuple pattern: {:?}", sty), @@ -460,8 +460,8 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { PatKind::Binding(_, id, ident, ref sub) => { let var_ty = self.tables.node_id_to_type(pat.hir_id); let region = match var_ty.sty { - ty::TyRef(r, _, _) => Some(r), - ty::TyError => { // Avoid ICE + ty::Ref(r, _, _) => Some(r), + ty::Error => { // Avoid ICE return Pattern { span: pat.span, ty, kind: Box::new(PatternKind::Wild) }; } _ => None, @@ -484,7 +484,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { // A ref x pattern is the same node used for x, and as such it has // x's type, which is &T, where we want T (the type being matched). if let ty::BindByReference(_) = bm { - if let ty::TyRef(_, rty, _) = ty.sty { + if let ty::Ref(_, rty, _) = ty.sty { ty = rty; } else { bug!("`ref {}` has wrong type {}", ident, ty); @@ -504,8 +504,8 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { PatKind::TupleStruct(ref qpath, ref subpatterns, ddpos) => { let def = self.tables.qpath_def(qpath, pat.hir_id); let adt_def = match ty.sty { - ty::TyAdt(adt_def, _) => adt_def, - ty::TyError => { // Avoid ICE (#50585) + ty::Adt(adt_def, _) => adt_def, + ty::Error => { // Avoid ICE (#50585) return Pattern { span: pat.span, ty, kind: Box::new(PatternKind::Wild) }; } _ => span_bug!(pat.span, @@ -608,12 +608,12 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { self.flatten_nested_slice_patterns(prefix, slice, suffix); match ty.sty { - ty::TySlice(..) => { + ty::Slice(..) => { // matching a slice or fixed-length array PatternKind::Slice { prefix: prefix, slice: slice, suffix: suffix } } - ty::TyArray(_, len) => { + ty::Array(_, len) => { // fixed-length array let len = len.unwrap_usize(self.tcx); assert!(len >= prefix.len() as u64 + suffix.len() as u64); @@ -640,9 +640,9 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { let adt_def = self.tcx.adt_def(enum_id); if adt_def.is_enum() { let substs = match ty.sty { - ty::TyAdt(_, substs) | - ty::TyFnDef(_, substs) => substs, - ty::TyError => { // Avoid ICE (#50585) + ty::Adt(_, substs) | + ty::FnDef(_, substs) => substs, + ty::Error => { // Avoid ICE (#50585) return PatternKind::Wild; } _ => bug!("inappropriate type for def: {:?}", ty.sty), @@ -811,7 +811,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { }).collect::>() }; let kind = match cv.ty.sty { - ty::TyFloat(_) => { + ty::Float(_) => { let id = self.tcx.hir.hir_to_node_id(id); self.tcx.lint_node( ::rustc::lint::builtin::ILLEGAL_FLOATING_POINT_LITERAL_PATTERN, @@ -823,12 +823,12 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { value: cv, } }, - ty::TyAdt(adt_def, _) if adt_def.is_union() => { + ty::Adt(adt_def, _) if adt_def.is_union() => { // Matching on union fields is unsafe, we can't hide it in constants self.tcx.sess.span_err(span, "cannot use unions in constant patterns"); PatternKind::Wild } - ty::TyAdt(adt_def, _) if !self.tcx.has_attr(adt_def.did, "structural_match") => { + ty::Adt(adt_def, _) if !self.tcx.has_attr(adt_def.did, "structural_match") => { let msg = format!("to use a constant of type `{}` in a pattern, \ `{}` must be annotated with `#[derive(PartialEq, Eq)]`", self.tcx.item_path_str(adt_def.did), @@ -836,7 +836,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { self.tcx.sess.span_err(span, &msg); PatternKind::Wild }, - ty::TyAdt(adt_def, substs) if adt_def.is_enum() => { + ty::Adt(adt_def, substs) if adt_def.is_enum() => { let variant_index = const_variant_index( self.tcx, self.param_env, instance, cv ).expect("const_variant_index failed"); @@ -851,18 +851,18 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { subpatterns, } }, - ty::TyAdt(adt_def, _) => { + ty::Adt(adt_def, _) => { let struct_var = adt_def.non_enum_variant(); PatternKind::Leaf { subpatterns: adt_subpatterns(struct_var.fields.len(), None), } } - ty::TyTuple(fields) => { + ty::Tuple(fields) => { PatternKind::Leaf { subpatterns: adt_subpatterns(fields.len(), None), } } - ty::TyArray(_, n) => { + ty::Array(_, n) => { PatternKind::Array { prefix: (0..n.unwrap_usize(self.tcx)) .map(|i| adt_subpattern(i as usize, None)) @@ -1073,17 +1073,17 @@ pub fn compare_const_vals<'a, 'tcx>( if let (Some(a), Some(b)) = (a.to_bits(tcx, ty), b.to_bits(tcx, ty)) { use ::rustc_apfloat::Float; return match ty.value.sty { - ty::TyFloat(ast::FloatTy::F32) => { + ty::Float(ast::FloatTy::F32) => { let l = ::rustc_apfloat::ieee::Single::from_bits(a); let r = ::rustc_apfloat::ieee::Single::from_bits(b); l.partial_cmp(&r) }, - ty::TyFloat(ast::FloatTy::F64) => { + ty::Float(ast::FloatTy::F64) => { let l = ::rustc_apfloat::ieee::Double::from_bits(a); let r = ::rustc_apfloat::ieee::Double::from_bits(b); l.partial_cmp(&r) }, - ty::TyInt(_) => { + ty::Int(_) => { let layout = tcx.layout_of(ty).ok()?; assert!(layout.abi.is_signed()); let a = sign_extend(a, layout.size); @@ -1094,8 +1094,8 @@ pub fn compare_const_vals<'a, 'tcx>( } } - if let ty::TyRef(_, rty, _) = ty.value.sty { - if let ty::TyStr = rty.sty { + if let ty::Ref(_, rty, _) = ty.value.sty { + if let ty::Str = rty.sty { match (a.val, b.val) { ( ConstValue::ScalarPair( @@ -1170,11 +1170,11 @@ fn lit_to_const<'a, 'tcx>(lit: &'tcx ast::LitKind, Unsigned(UintTy), } let ity = match ty.sty { - ty::TyInt(IntTy::Isize) => Int::Signed(tcx.sess.target.isize_ty), - ty::TyInt(other) => Int::Signed(other), - ty::TyUint(UintTy::Usize) => Int::Unsigned(tcx.sess.target.usize_ty), - ty::TyUint(other) => Int::Unsigned(other), - ty::TyError => { // Avoid ICE (#51963) + ty::Int(IntTy::Isize) => Int::Signed(tcx.sess.target.isize_ty), + ty::Int(other) => Int::Signed(other), + ty::Uint(UintTy::Usize) => Int::Unsigned(tcx.sess.target.usize_ty), + ty::Uint(other) => Int::Unsigned(other), + ty::Error => { // Avoid ICE (#51963) return Err(LitToConstError::Propagated); } _ => bug!("literal integer type with bad type ({:?})", ty.sty), @@ -1211,7 +1211,7 @@ fn lit_to_const<'a, 'tcx>(lit: &'tcx ast::LitKind, } LitKind::FloatUnsuffixed(n) => { let fty = match ty.sty { - ty::TyFloat(fty) => fty, + ty::Float(fty) => fty, _ => bug!() }; parse_float(n, fty, neg).map_err(|_| LitToConstError::UnparseableFloat)? diff --git a/src/librustc_mir/interpret/cast.rs b/src/librustc_mir/interpret/cast.rs index b4d36afa0f80d..0c5dbf9a0f63e 100644 --- a/src/librustc_mir/interpret/cast.rs +++ b/src/librustc_mir/interpret/cast.rs @@ -15,9 +15,9 @@ use super::{EvalContext, Machine, PlaceTy, OpTy, Value}; impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { fn type_is_fat_ptr(&self, ty: Ty<'tcx>) -> bool { match ty.sty { - ty::TyRawPtr(ty::TypeAndMut { ty, .. }) | - ty::TyRef(_, ty, _) => !self.type_is_sized(ty), - ty::TyAdt(def, _) if def.is_box() => !self.type_is_sized(ty.boxed_ty()), + ty::RawPtr(ty::TypeAndMut { ty, .. }) | + ty::Ref(_, ty, _) => !self.type_is_sized(ty), + ty::Adt(def, _) if def.is_box() => !self.type_is_sized(ty.boxed_ty()), _ => false, } } @@ -80,7 +80,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { ReifyFnPointer => { // The src operand does not matter, just its type match src_layout.ty.sty { - ty::TyFnDef(def_id, substs) => { + ty::FnDef(def_id, substs) => { if self.tcx.has_attr(def_id, "rustc_args_required_const") { bug!("reifying a fn ptr that requires \ const arguments"); @@ -101,7 +101,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { UnsafeFnPointer => { let src = self.read_value(src)?; match dest.layout.ty.sty { - ty::TyFnPtr(_) => { + ty::FnPtr(_) => { // No change to value self.write_value(*src, dest)?; } @@ -112,7 +112,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { ClosureFnPointer => { // The src operand does not matter, just its type match src_layout.ty.sty { - ty::TyClosure(def_id, substs) => { + ty::Closure(def_id, substs) => { let substs = self.tcx.subst_and_normalize_erasing_regions( self.substs(), ty::ParamEnv::reveal_all(), @@ -141,7 +141,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { src_layout: TyLayout<'tcx>, dest_layout: TyLayout<'tcx>, ) -> EvalResult<'tcx, Scalar> { - use rustc::ty::TypeVariants::*; + use rustc::ty::TyKind::*; trace!("Casting {:?}: {:?} to {:?}", val, src_layout.ty, dest_layout.ty); match val { @@ -152,7 +152,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { "Unexpected value of size {} before casting", size); let res = match src_layout.ty.sty { - TyFloat(fty) => self.cast_from_float(bits, fty, dest_layout.ty)?, + Float(fty) => self.cast_from_float(bits, fty, dest_layout.ty)?, _ => self.cast_from_int(bits, src_layout, dest_layout)?, }; @@ -184,9 +184,9 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { v }; trace!("cast_from_int: {}, {}, {}", v, src_layout.ty, dest_layout.ty); - use rustc::ty::TypeVariants::*; + use rustc::ty::TyKind::*; match dest_layout.ty.sty { - TyInt(_) | TyUint(_) => { + Int(_) | Uint(_) => { let v = self.truncate(v, dest_layout); Ok(Scalar::Bits { bits: v, @@ -194,30 +194,30 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { }) } - TyFloat(FloatTy::F32) if signed => Ok(Scalar::Bits { + Float(FloatTy::F32) if signed => Ok(Scalar::Bits { bits: Single::from_i128(v as i128).value.to_bits(), size: 4, }), - TyFloat(FloatTy::F64) if signed => Ok(Scalar::Bits { + Float(FloatTy::F64) if signed => Ok(Scalar::Bits { bits: Double::from_i128(v as i128).value.to_bits(), size: 8, }), - TyFloat(FloatTy::F32) => Ok(Scalar::Bits { + Float(FloatTy::F32) => Ok(Scalar::Bits { bits: Single::from_u128(v).value.to_bits(), size: 4, }), - TyFloat(FloatTy::F64) => Ok(Scalar::Bits { + Float(FloatTy::F64) => Ok(Scalar::Bits { bits: Double::from_u128(v).value.to_bits(), size: 8, }), - TyChar => { + Char => { assert_eq!(v as u8 as u128, v); Ok(Scalar::Bits { bits: v, size: 4 }) }, // No alignment check needed for raw pointers. But we have to truncate to target ptr size. - TyRawPtr(_) => { + RawPtr(_) => { Ok(Scalar::Bits { bits: self.memory.truncate_to_ptr(v).0 as u128, size: self.memory.pointer_size().bytes() as u8, @@ -230,11 +230,11 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { } fn cast_from_float(&self, bits: u128, fty: FloatTy, dest_ty: Ty<'tcx>) -> EvalResult<'tcx, Scalar> { - use rustc::ty::TypeVariants::*; + use rustc::ty::TyKind::*; use rustc_apfloat::FloatConvert; match dest_ty.sty { // float -> uint - TyUint(t) => { + Uint(t) => { let width = t.bit_width().unwrap_or(self.memory.pointer_size().bits() as usize); let v = match fty { FloatTy::F32 => Single::from_bits(bits).to_u128(width).value, @@ -247,7 +247,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { }) }, // float -> int - TyInt(t) => { + Int(t) => { let width = t.bit_width().unwrap_or(self.memory.pointer_size().bits() as usize); let v = match fty { FloatTy::F32 => Single::from_bits(bits).to_i128(width).value, @@ -263,25 +263,25 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { }) }, // f64 -> f32 - TyFloat(FloatTy::F32) if fty == FloatTy::F64 => { + Float(FloatTy::F32) if fty == FloatTy::F64 => { Ok(Scalar::Bits { bits: Single::to_bits(Double::from_bits(bits).convert(&mut false).value), size: 4, }) }, // f32 -> f64 - TyFloat(FloatTy::F64) if fty == FloatTy::F32 => { + Float(FloatTy::F64) if fty == FloatTy::F32 => { Ok(Scalar::Bits { bits: Double::to_bits(Single::from_bits(bits).convert(&mut false).value), size: 8, }) }, // identity cast - TyFloat(FloatTy:: F64) => Ok(Scalar::Bits { + Float(FloatTy:: F64) => Ok(Scalar::Bits { bits, size: 8, }), - TyFloat(FloatTy:: F32) => Ok(Scalar::Bits { + Float(FloatTy:: F32) => Ok(Scalar::Bits { bits, size: 4, }), @@ -290,13 +290,13 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { } fn cast_from_ptr(&self, ptr: Pointer, ty: Ty<'tcx>) -> EvalResult<'tcx, Scalar> { - use rustc::ty::TypeVariants::*; + use rustc::ty::TyKind::*; match ty.sty { // Casting to a reference or fn pointer is not permitted by rustc, no need to support it here. - TyRawPtr(_) | - TyInt(IntTy::Isize) | - TyUint(UintTy::Usize) => Ok(ptr.into()), - TyInt(_) | TyUint(_) => err!(ReadPointerAsBytes), + RawPtr(_) | + Int(IntTy::Isize) | + Uint(UintTy::Usize) => Ok(ptr.into()), + Int(_) | Uint(_) => err!(ReadPointerAsBytes), _ => err!(Unimplemented(format!("ptr to {:?} cast", ty))), } } @@ -313,19 +313,19 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { let (src_pointee_ty, dest_pointee_ty) = self.tcx.struct_lockstep_tails(sty, dty); match (&src_pointee_ty.sty, &dest_pointee_ty.sty) { - (&ty::TyArray(_, length), &ty::TySlice(_)) => { + (&ty::Array(_, length), &ty::Slice(_)) => { let ptr = self.read_value(src)?.to_scalar_ptr()?; // u64 cast is from usize to u64, which is always good let val = Value::new_slice(ptr, length.unwrap_usize(self.tcx.tcx), self.tcx.tcx); self.write_value(val, dest) } - (&ty::TyDynamic(..), &ty::TyDynamic(..)) => { + (&ty::Dynamic(..), &ty::Dynamic(..)) => { // For now, upcasts are limited to changes in marker // traits, and hence never actually require an actual // change to the vtable. self.copy_op(src, dest) } - (_, &ty::TyDynamic(ref data, _)) => { + (_, &ty::Dynamic(ref data, _)) => { // Initial cast from sized to dyn trait let trait_ref = data.principal().unwrap().with_self_ty( *self.tcx, @@ -348,13 +348,13 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { dest: PlaceTy<'tcx>, ) -> EvalResult<'tcx> { match (&src.layout.ty.sty, &dest.layout.ty.sty) { - (&ty::TyRef(_, s, _), &ty::TyRef(_, d, _)) | - (&ty::TyRef(_, s, _), &ty::TyRawPtr(TypeAndMut { ty: d, .. })) | - (&ty::TyRawPtr(TypeAndMut { ty: s, .. }), - &ty::TyRawPtr(TypeAndMut { ty: d, .. })) => { + (&ty::Ref(_, s, _), &ty::Ref(_, d, _)) | + (&ty::Ref(_, s, _), &ty::RawPtr(TypeAndMut { ty: d, .. })) | + (&ty::RawPtr(TypeAndMut { ty: s, .. }), + &ty::RawPtr(TypeAndMut { ty: d, .. })) => { self.unsize_into_ptr(src, dest, s, d) } - (&ty::TyAdt(def_a, _), &ty::TyAdt(def_b, _)) => { + (&ty::Adt(def_a, _), &ty::Adt(def_b, _)) => { assert_eq!(def_a, def_b); if def_a.is_box() || def_b.is_box() { if !def_a.is_box() || !def_b.is_box() { diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index 33420b6150bb7..9a6f1199421d6 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -457,7 +457,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M let layout = mplace.layout; assert!(layout.is_unsized()); match layout.ty.sty { - ty::TyAdt(..) | ty::TyTuple(..) => { + ty::Adt(..) | ty::Tuple(..) => { // First get the size of all statically known fields. // Don't use type_of::sizing_type_of because that expects t to be sized, // and it also rounds up to alignment, which we want to avoid, @@ -506,7 +506,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M Ok((size.abi_align(align), align)) } - ty::TyDynamic(..) => { + ty::Dynamic(..) => { let vtable = match mplace.extra { PlaceExtra::Vtable(vtable) => vtable, _ => bug!("Expected vtable"), @@ -515,7 +515,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M self.read_size_and_align_from_vtable(vtable) } - ty::TySlice(_) | ty::TyStr => { + ty::Slice(_) | ty::Str => { let len = match mplace.extra { PlaceExtra::Length(len) => len, _ => bug!("Expected length"), diff --git a/src/librustc_mir/interpret/operator.rs b/src/librustc_mir/interpret/operator.rs index c5475f9a4c064..a8e5525b2e1c0 100644 --- a/src/librustc_mir/interpret/operator.rs +++ b/src/librustc_mir/interpret/operator.rs @@ -169,7 +169,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { } } - if let ty::TyFloat(fty) = left_layout.ty.sty { + if let ty::Float(fty) = left_layout.ty.sty { macro_rules! float_math { ($ty:path, $size:expr) => {{ let l = <$ty>::from_bits(l); @@ -267,12 +267,12 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { let result_bytes = match (un_op, &layout.ty.sty) { - (Not, ty::TyBool) => !val.to_bool()? as u128, + (Not, ty::Bool) => !val.to_bool()? as u128, (Not, _) => !bytes, - (Neg, ty::TyFloat(FloatTy::F32)) => Single::to_bits(-Single::from_bits(bytes)), - (Neg, ty::TyFloat(FloatTy::F64)) => Double::to_bits(-Double::from_bits(bytes)), + (Neg, ty::Float(FloatTy::F32)) => Single::to_bits(-Single::from_bits(bytes)), + (Neg, ty::Float(FloatTy::F64)) => Double::to_bits(-Double::from_bits(bytes)), (Neg, _) if bytes == (1 << (size.bits() - 1)) => return err!(OverflowNeg), (Neg, _) => (-(bytes as i128)) as u128, diff --git a/src/librustc_mir/interpret/place.rs b/src/librustc_mir/interpret/place.rs index 91182edc2f5b7..1795548d81c77 100644 --- a/src/librustc_mir/interpret/place.rs +++ b/src/librustc_mir/interpret/place.rs @@ -236,7 +236,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { let pointee_type = val.layout.ty.builtin_deref(true).unwrap().ty; let layout = self.layout_of(pointee_type)?; let mplace = match self.tcx.struct_tail(pointee_type).sty { - ty::TyDynamic(..) => { + ty::Dynamic(..) => { let (ptr, vtable) = val.to_scalar_dyn_trait()?; MemPlace { ptr, @@ -244,7 +244,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { extra: PlaceExtra::Vtable(vtable), } } - ty::TyStr | ty::TySlice(_) => { + ty::Str | ty::Slice(_) => { let (ptr, len) = val.to_scalar_slice(self)?; MemPlace { ptr, @@ -358,9 +358,9 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { // Compute extra and new layout let inner_len = len - to - from; let (extra, ty) = match base.layout.ty.sty { - ty::TyArray(inner, _) => + ty::Array(inner, _) => (PlaceExtra::None, self.tcx.mk_array(inner, inner_len)), - ty::TySlice(..) => + ty::Slice(..) => (PlaceExtra::Length(inner_len), base.layout.ty), _ => bug!("cannot subslice non-array type: `{:?}`", base.layout.ty), diff --git a/src/librustc_mir/interpret/terminator/drop.rs b/src/librustc_mir/interpret/terminator/drop.rs index e044df2d1c0f9..0bddd7147b998 100644 --- a/src/librustc_mir/interpret/terminator/drop.rs +++ b/src/librustc_mir/interpret/terminator/drop.rs @@ -20,7 +20,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { let place = self.force_allocation(place)?; let (instance, place) = match place.layout.ty.sty { - ty::TyDynamic(..) => { + ty::Dynamic(..) => { // Dropping a trait object. let vtable = match place.extra { PlaceExtra::Vtable(vtable) => vtable, diff --git a/src/librustc_mir/interpret/terminator/mod.rs b/src/librustc_mir/interpret/terminator/mod.rs index 82455cacac2d4..913b88fc8eb48 100644 --- a/src/librustc_mir/interpret/terminator/mod.rs +++ b/src/librustc_mir/interpret/terminator/mod.rs @@ -72,12 +72,12 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { let func = self.eval_operand(func, None)?; let (fn_def, sig) = match func.layout.ty.sty { - ty::TyFnPtr(sig) => { + ty::FnPtr(sig) => { let fn_ptr = self.read_scalar(func)?.to_ptr()?; let instance = self.memory.get_fn(fn_ptr)?; let instance_ty = instance.ty(*self.tcx); match instance_ty.sty { - ty::TyFnDef(..) => { + ty::FnDef(..) => { let real_sig = instance_ty.fn_sig(*self.tcx); let sig = self.tcx.normalize_erasing_late_bound_regions( ty::ParamEnv::reveal_all(), @@ -95,7 +95,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { } (instance, sig) } - ty::TyFnDef(def_id, substs) => ( + ty::FnDef(def_id, substs) => ( self.resolve(def_id, substs)?, func.layout.ty.fn_sig(*self.tcx), ), @@ -198,8 +198,8 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { // Permit changing the pointer type of raw pointers and references as well as // mutability of raw pointers. // TODO: Should not be allowed when fat pointers are involved. - (&ty::TyRawPtr(_), &ty::TyRawPtr(_)) => true, - (&ty::TyRef(_, _, _), &ty::TyRef(_, _, _)) => { + (&ty::RawPtr(_), &ty::RawPtr(_)) => true, + (&ty::Ref(_, _, _), &ty::Ref(_, _, _)) => { ty.is_mutable_pointer() == real_ty.is_mutable_pointer() } // rule out everything else @@ -233,7 +233,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { // Second argument must be a tuple matching the argument list of sig let snd_ty = real_sig.inputs_and_output[1]; match snd_ty.sty { - ty::TyTuple(tys) if sig.inputs().len() == tys.len() => + ty::Tuple(tys) if sig.inputs().len() == tys.len() => if sig.inputs().iter().zip(tys).all(|(ty, real_ty)| check_ty_compat(ty, real_ty)) { return Ok(true) }, @@ -339,7 +339,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { // unpack and write all other args let layout = args[1].layout; - if let ty::TyTuple(_) = layout.ty.sty { + if let ty::Tuple(_) = layout.ty.sty { if layout.is_zst() { // Nothing to do, no need to unpack zsts return Ok(()); diff --git a/src/librustc_mir/interpret/validity.rs b/src/librustc_mir/interpret/validity.rs index 8f0e819660541..a446a534624ba 100644 --- a/src/librustc_mir/interpret/validity.rs +++ b/src/librustc_mir/interpret/validity.rs @@ -139,7 +139,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { // char gets a special treatment, because its number space is not contiguous so `TyLayout` // has no special checks for chars match ty.sty { - ty::TyChar => { + ty::Char => { debug_assert_eq!(size.bytes(), 4); if ::std::char::from_u32(bits as u32).is_none() { return validation_failure!( @@ -323,23 +323,23 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { fn aggregate_field_path_elem(&self, ty: Ty<'tcx>, variant: usize, field: usize) -> PathElem { match ty.sty { // generators and closures. - ty::TyClosure(def_id, _) | ty::TyGenerator(def_id, _, _) => { + ty::Closure(def_id, _) | ty::Generator(def_id, _, _) => { let node_id = self.tcx.hir.as_local_node_id(def_id).unwrap(); let freevar = self.tcx.with_freevars(node_id, |fv| fv[field]); PathElem::ClosureVar(self.tcx.hir.name(freevar.var_id())) } // tuples - ty::TyTuple(_) => PathElem::TupleElem(field), + ty::Tuple(_) => PathElem::TupleElem(field), // enums - ty::TyAdt(def, ..) if def.is_enum() => { + ty::Adt(def, ..) if def.is_enum() => { let variant = &def.variants[variant]; PathElem::Field(variant.fields[field].ident.name) } // other ADTs - ty::TyAdt(def, _) => PathElem::Field(def.non_enum_variant().fields[field].ident.name), + ty::Adt(def, _) => PathElem::Field(def.non_enum_variant().fields[field].ident.name), // nothing else has an aggregate layout _ => bug!("aggregate_field_path_elem: got non-aggregate type {:?}", ty), diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index 230d6f0472edd..a1dbf9ddb0356 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -571,7 +571,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> { &source_ty, ); match source_ty.sty { - ty::TyClosure(def_id, substs) => { + ty::Closure(def_id, substs) => { let instance = monomorphize::resolve_closure( self.tcx, def_id, substs, ty::ClosureKind::FnOnce); if should_monomorphize_locally(self.tcx, &instance) { @@ -680,7 +680,7 @@ fn visit_fn_use<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, is_direct_call: bool, output: &mut Vec>) { - if let ty::TyFnDef(def_id, substs) = ty.sty { + if let ty::FnDef(def_id, substs) = ty.sty { let instance = ty::Instance::resolve(tcx, ty::ParamEnv::reveal_all(), def_id, @@ -838,8 +838,8 @@ fn find_vtable_types_for_unsizing<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } let tail = tcx.struct_tail(ty); match tail.sty { - ty::TyForeign(..) => false, - ty::TyStr | ty::TySlice(..) | ty::TyDynamic(..) => true, + ty::Foreign(..) => false, + ty::Str | ty::Slice(..) | ty::Dynamic(..) => true, _ => bug!("unexpected unsized tail: {:?}", tail.sty), } }; @@ -851,20 +851,20 @@ fn find_vtable_types_for_unsizing<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, }; match (&source_ty.sty, &target_ty.sty) { - (&ty::TyRef(_, a, _), - &ty::TyRef(_, b, _)) | - (&ty::TyRef(_, a, _), - &ty::TyRawPtr(ty::TypeAndMut { ty: b, .. })) | - (&ty::TyRawPtr(ty::TypeAndMut { ty: a, .. }), - &ty::TyRawPtr(ty::TypeAndMut { ty: b, .. })) => { + (&ty::Ref(_, a, _), + &ty::Ref(_, b, _)) | + (&ty::Ref(_, a, _), + &ty::RawPtr(ty::TypeAndMut { ty: b, .. })) | + (&ty::RawPtr(ty::TypeAndMut { ty: a, .. }), + &ty::RawPtr(ty::TypeAndMut { ty: b, .. })) => { ptr_vtable(a, b) } - (&ty::TyAdt(def_a, _), &ty::TyAdt(def_b, _)) if def_a.is_box() && def_b.is_box() => { + (&ty::Adt(def_a, _), &ty::Adt(def_b, _)) if def_a.is_box() && def_b.is_box() => { ptr_vtable(source_ty.boxed_ty(), target_ty.boxed_ty()) } - (&ty::TyAdt(source_adt_def, source_substs), - &ty::TyAdt(target_adt_def, target_substs)) => { + (&ty::Adt(source_adt_def, source_substs), + &ty::Adt(target_adt_def, target_substs)) => { assert_eq!(source_adt_def, target_adt_def); let kind = @@ -906,7 +906,7 @@ fn create_mono_items_for_vtable_methods<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, assert!(!trait_ty.needs_subst() && !trait_ty.has_escaping_regions() && !impl_ty.needs_subst() && !impl_ty.has_escaping_regions()); - if let ty::TyDynamic(ref trait_ty, ..) = trait_ty.sty { + if let ty::Dynamic(ref trait_ty, ..) = trait_ty.sty { if let Some(principal) = trait_ty.principal() { let poly_trait_ref = principal.with_self_ty(tcx, impl_ty); assert!(!poly_trait_ref.has_escaping_regions()); diff --git a/src/librustc_mir/monomorphize/item.rs b/src/librustc_mir/monomorphize/item.rs index f73c9d43699fc..3187a91e22597 100644 --- a/src/librustc_mir/monomorphize/item.rs +++ b/src/librustc_mir/monomorphize/item.rs @@ -257,29 +257,29 @@ impl<'a, 'tcx> DefPathBasedNames<'a, 'tcx> { pub fn push_type_name(&self, t: Ty<'tcx>, output: &mut String) { match t.sty { - ty::TyBool => output.push_str("bool"), - ty::TyChar => output.push_str("char"), - ty::TyStr => output.push_str("str"), - ty::TyNever => output.push_str("!"), - ty::TyInt(ast::IntTy::Isize) => output.push_str("isize"), - ty::TyInt(ast::IntTy::I8) => output.push_str("i8"), - ty::TyInt(ast::IntTy::I16) => output.push_str("i16"), - ty::TyInt(ast::IntTy::I32) => output.push_str("i32"), - ty::TyInt(ast::IntTy::I64) => output.push_str("i64"), - ty::TyInt(ast::IntTy::I128) => output.push_str("i128"), - ty::TyUint(ast::UintTy::Usize) => output.push_str("usize"), - ty::TyUint(ast::UintTy::U8) => output.push_str("u8"), - ty::TyUint(ast::UintTy::U16) => output.push_str("u16"), - ty::TyUint(ast::UintTy::U32) => output.push_str("u32"), - ty::TyUint(ast::UintTy::U64) => output.push_str("u64"), - ty::TyUint(ast::UintTy::U128) => output.push_str("u128"), - ty::TyFloat(ast::FloatTy::F32) => output.push_str("f32"), - ty::TyFloat(ast::FloatTy::F64) => output.push_str("f64"), - ty::TyAdt(adt_def, substs) => { + ty::Bool => output.push_str("bool"), + ty::Char => output.push_str("char"), + ty::Str => output.push_str("str"), + ty::Never => output.push_str("!"), + ty::Int(ast::IntTy::Isize) => output.push_str("isize"), + ty::Int(ast::IntTy::I8) => output.push_str("i8"), + ty::Int(ast::IntTy::I16) => output.push_str("i16"), + ty::Int(ast::IntTy::I32) => output.push_str("i32"), + ty::Int(ast::IntTy::I64) => output.push_str("i64"), + ty::Int(ast::IntTy::I128) => output.push_str("i128"), + ty::Uint(ast::UintTy::Usize) => output.push_str("usize"), + ty::Uint(ast::UintTy::U8) => output.push_str("u8"), + ty::Uint(ast::UintTy::U16) => output.push_str("u16"), + ty::Uint(ast::UintTy::U32) => output.push_str("u32"), + ty::Uint(ast::UintTy::U64) => output.push_str("u64"), + ty::Uint(ast::UintTy::U128) => output.push_str("u128"), + ty::Float(ast::FloatTy::F32) => output.push_str("f32"), + ty::Float(ast::FloatTy::F64) => output.push_str("f64"), + ty::Adt(adt_def, substs) => { self.push_def_path(adt_def.did, output); self.push_type_params(substs, iter::empty(), output); }, - ty::TyTuple(component_types) => { + ty::Tuple(component_types) => { output.push('('); for &component_type in component_types { self.push_type_name(component_type, output); @@ -291,7 +291,7 @@ impl<'a, 'tcx> DefPathBasedNames<'a, 'tcx> { } output.push(')'); }, - ty::TyRawPtr(ty::TypeAndMut { ty: inner_type, mutbl } ) => { + ty::RawPtr(ty::TypeAndMut { ty: inner_type, mutbl } ) => { output.push('*'); match mutbl { hir::MutImmutable => output.push_str("const "), @@ -300,7 +300,7 @@ impl<'a, 'tcx> DefPathBasedNames<'a, 'tcx> { self.push_type_name(inner_type, output); }, - ty::TyRef(_, inner_type, mutbl) => { + ty::Ref(_, inner_type, mutbl) => { output.push('&'); if mutbl == hir::MutMutable { output.push_str("mut "); @@ -308,18 +308,18 @@ impl<'a, 'tcx> DefPathBasedNames<'a, 'tcx> { self.push_type_name(inner_type, output); }, - ty::TyArray(inner_type, len) => { + ty::Array(inner_type, len) => { output.push('['); self.push_type_name(inner_type, output); write!(output, "; {}", len.unwrap_usize(self.tcx)).unwrap(); output.push(']'); }, - ty::TySlice(inner_type) => { + ty::Slice(inner_type) => { output.push('['); self.push_type_name(inner_type, output); output.push(']'); }, - ty::TyDynamic(ref trait_data, ..) => { + ty::Dynamic(ref trait_data, ..) => { if let Some(principal) = trait_data.principal() { self.push_def_path(principal.def_id(), output); self.push_type_params(principal.skip_binder().substs, @@ -327,9 +327,9 @@ impl<'a, 'tcx> DefPathBasedNames<'a, 'tcx> { output); } }, - ty::TyForeign(did) => self.push_def_path(did, output), - ty::TyFnDef(..) | - ty::TyFnPtr(_) => { + ty::Foreign(did) => self.push_def_path(did, output), + ty::FnDef(..) | + ty::FnPtr(_) => { let sig = t.fn_sig(self.tcx); if sig.unsafety() == hir::Unsafety::Unsafe { output.push_str("unsafe "); @@ -373,19 +373,19 @@ impl<'a, 'tcx> DefPathBasedNames<'a, 'tcx> { self.push_type_name(sig.output(), output); } }, - ty::TyGenerator(def_id, GeneratorSubsts { ref substs }, _) | - ty::TyClosure(def_id, ClosureSubsts { ref substs }) => { + ty::Generator(def_id, GeneratorSubsts { ref substs }, _) | + ty::Closure(def_id, ClosureSubsts { ref substs }) => { self.push_def_path(def_id, output); let generics = self.tcx.generics_of(self.tcx.closure_base_def_id(def_id)); let substs = substs.truncate_to(self.tcx, generics); self.push_type_params(substs, iter::empty(), output); } - ty::TyError | - ty::TyInfer(_) | - ty::TyProjection(..) | - ty::TyParam(_) | - ty::TyGeneratorWitness(_) | - ty::TyAnon(..) => { + ty::Error | + ty::Infer(_) | + ty::Projection(..) | + ty::Param(_) | + ty::GeneratorWitness(_) | + ty::Anon(..) => { bug!("DefPathBasedNames: Trying to create type name for \ unexpected type: {:?}", t); } diff --git a/src/librustc_mir/shim.rs b/src/librustc_mir/shim.rs index 7bfbda8b786e3..765a47e729e68 100644 --- a/src/librustc_mir/shim.rs +++ b/src/librustc_mir/shim.rs @@ -165,7 +165,7 @@ fn build_drop_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, debug!("build_drop_shim(def_id={:?}, ty={:?})", def_id, ty); // Check if this is a generator, if so, return the drop glue for it - if let Some(&ty::TyS { sty: ty::TyGenerator(gen_def_id, substs, _), .. }) = ty { + if let Some(&ty::TyS { sty: ty::Generator(gen_def_id, substs, _), .. }) = ty { let mir = &**tcx.optimized_mir(gen_def_id).generator_drop.as_ref().unwrap(); return mir.subst(tcx, substs.substs); } @@ -301,17 +301,17 @@ fn build_clone_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, match self_ty.sty { _ if is_copy => builder.copy_shim(), - ty::TyArray(ty, len) => { + ty::Array(ty, len) => { let len = len.unwrap_usize(tcx); builder.array_shim(dest, src, ty, len) } - ty::TyClosure(def_id, substs) => { + ty::Closure(def_id, substs) => { builder.tuple_like_shim( dest, src, substs.upvar_tys(def_id, tcx) ) } - ty::TyTuple(tys) => builder.tuple_like_shim(dest, src, tys.iter().cloned()), + ty::Tuple(tys) => builder.tuple_like_shim(dest, src, tys.iter().cloned()), _ => { bug!("clone shim for `{:?}` which is not `Copy` and is not an aggregate", self_ty) } @@ -821,7 +821,7 @@ pub fn build_adt_ctor<'a, 'gcx, 'tcx>(infcx: &infer::InferCtxt<'a, 'gcx, 'tcx>, let sig = gcx.normalize_erasing_regions(param_env, sig); let (adt_def, substs) = match sig.output().sty { - ty::TyAdt(adt_def, substs) => (adt_def, substs), + ty::Adt(adt_def, substs) => (adt_def, substs), _ => bug!("unexpected type for ADT ctor {:?}", sig.output()) }; diff --git a/src/librustc_mir/transform/add_validation.rs b/src/librustc_mir/transform/add_validation.rs index 4f7f45f173f73..9061b34ae4445 100644 --- a/src/librustc_mir/transform/add_validation.rs +++ b/src/librustc_mir/transform/add_validation.rs @@ -45,7 +45,7 @@ fn place_context<'a, 'tcx, D>( // A Deref projection may restrict the context, this depends on the type // being deref'd. let context = match ty.sty { - ty::TyRef(re, _, mutbl) => { + ty::Ref(re, _, mutbl) => { let re = match re { &RegionKind::ReScope(ce) => Some(ce), &RegionKind::ReErased => @@ -54,12 +54,12 @@ fn place_context<'a, 'tcx, D>( }; (re, mutbl) } - ty::TyRawPtr(_) => + ty::RawPtr(_) => // There is no guarantee behind even a mutable raw pointer, // no write locks are acquired there, so we also don't want to // release any. (None, hir::MutImmutable), - ty::TyAdt(adt, _) if adt.is_box() => (None, hir::MutMutable), + ty::Adt(adt, _) if adt.is_box() => (None, hir::MutMutable), _ => bug!("Deref on a non-pointer type {:?}", ty), }; // "Intersect" this restriction with proj.base. diff --git a/src/librustc_mir/transform/check_unsafety.rs b/src/librustc_mir/transform/check_unsafety.rs index 80e484d595714..5d284981c70af 100644 --- a/src/librustc_mir/transform/check_unsafety.rs +++ b/src/librustc_mir/transform/check_unsafety.rs @@ -179,13 +179,13 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> { } let base_ty = base.ty(self.mir, self.tcx).to_ty(self.tcx); match base_ty.sty { - ty::TyRawPtr(..) => { + ty::RawPtr(..) => { self.require_unsafe("dereference of raw pointer", "raw pointers may be NULL, dangling or unaligned; they can violate \ aliasing rules and cause data races: all of these are undefined \ behavior") } - ty::TyAdt(adt, _) => { + ty::Adt(adt, _) => { if adt.is_union() { if context == PlaceContext::Store || context == PlaceContext::AsmOutput || diff --git a/src/librustc_mir/transform/generator.rs b/src/librustc_mir/transform/generator.rs index a3647edd155d3..4a9b6b7f6e833 100644 --- a/src/librustc_mir/transform/generator.rs +++ b/src/librustc_mir/transform/generator.rs @@ -493,7 +493,7 @@ fn compute_layout<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, // MIR types let allowed_upvars = tcx.erase_regions(&upvars); let allowed = match interior.sty { - ty::TyGeneratorWitness(s) => tcx.erase_late_bound_regions(&s), + ty::GeneratorWitness(s) => tcx.erase_late_bound_regions(&s), _ => bug!(), }; @@ -863,7 +863,7 @@ impl MirPass for StateTransform { // Get the interior types and substs which typeck computed let (upvars, interior, movable) = match gen_ty.sty { - ty::TyGenerator(_, substs, movability) => { + ty::Generator(_, substs, movability) => { (substs.upvar_tys(def_id, tcx).collect(), substs.witness(def_id, tcx), movability == hir::GeneratorMovability::Movable) diff --git a/src/librustc_mir/transform/inline.rs b/src/librustc_mir/transform/inline.rs index 5062775fec168..31e437ce2281a 100644 --- a/src/librustc_mir/transform/inline.rs +++ b/src/librustc_mir/transform/inline.rs @@ -95,7 +95,7 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> { let terminator = bb_data.terminator(); if let TerminatorKind::Call { func: Operand::Constant(ref f), .. } = terminator.kind { - if let ty::TyFnDef(callee_def_id, substs) = f.ty.sty { + if let ty::FnDef(callee_def_id, substs) = f.ty.sty { if let Some(instance) = Instance::resolve(self.tcx, param_env, callee_def_id, @@ -158,7 +158,7 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> { let terminator = bb_data.terminator(); if let TerminatorKind::Call { func: Operand::Constant(ref f), .. } = terminator.kind { - if let ty::TyFnDef(callee_def_id, substs) = f.ty.sty { + if let ty::FnDef(callee_def_id, substs) = f.ty.sty { // Don't inline the same function multiple times. if callsite.callee != callee_def_id { callsites.push_back(CallSite { @@ -314,7 +314,7 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> { } TerminatorKind::Call {func: Operand::Constant(ref f), .. } => { - if let ty::TyFnDef(def_id, _) = f.ty.sty { + if let ty::FnDef(def_id, _) = f.ty.sty { // Don't give intrinsics the extra penalty for calls let f = tcx.fn_sig(def_id); if f.abi() == Abi::RustIntrinsic || f.abi() == Abi::PlatformIntrinsic { @@ -538,7 +538,7 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> { assert!(args.next().is_none()); let tuple = Place::Local(tuple); - let tuple_tys = if let ty::TyTuple(s) = tuple.ty(caller_mir, tcx).to_ty(tcx).sty { + let tuple_tys = if let ty::Tuple(s) = tuple.ty(caller_mir, tcx).to_ty(tcx).sty { s } else { bug!("Closure arguments are not passed as a tuple"); diff --git a/src/librustc_mir/transform/instcombine.rs b/src/librustc_mir/transform/instcombine.rs index 6e06beb30419d..4cf4a8f23a443 100644 --- a/src/librustc_mir/transform/instcombine.rs +++ b/src/librustc_mir/transform/instcombine.rs @@ -12,7 +12,7 @@ use rustc::mir::{Constant, Location, Place, Mir, Operand, ProjectionElem, Rvalue, Local}; use rustc::mir::visit::{MutVisitor, Visitor}; -use rustc::ty::{TyCtxt, TypeVariants}; +use rustc::ty::{TyCtxt, TyKind}; use rustc::util::nodemap::{FxHashMap, FxHashSet}; use rustc_data_structures::indexed_vec::Idx; use std::mem; @@ -100,7 +100,7 @@ impl<'b, 'a, 'tcx> Visitor<'tcx> for OptimizationFinder<'b, 'a, 'tcx> { if let Rvalue::Len(ref place) = *rvalue { let place_ty = place.ty(&self.mir.local_decls, self.tcx).to_ty(self.tcx); - if let TypeVariants::TyArray(_, len) = place_ty.sty { + if let TyKind::Array(_, len) = place_ty.sty { let span = self.mir.source_info(location).span; let ty = self.tcx.types.usize; let constant = Constant { span, ty, literal: len }; diff --git a/src/librustc_mir/transform/lower_128bit.rs b/src/librustc_mir/transform/lower_128bit.rs index 83cd7bf549d55..8ed5600400b51 100644 --- a/src/librustc_mir/transform/lower_128bit.rs +++ b/src/librustc_mir/transform/lower_128bit.rs @@ -13,7 +13,7 @@ use rustc::hir::def_id::DefId; use rustc::middle::lang_items::LangItem; use rustc::mir::*; -use rustc::ty::{Slice, Ty, TyCtxt, TypeVariants}; +use rustc::ty::{List, Ty, TyCtxt, TyKind}; use rustc_data_structures::indexed_vec::{Idx}; use transform::{MirPass, MirSource}; use syntax; @@ -114,7 +114,7 @@ impl Lower128Bit { source_info, kind: TerminatorKind::Call { func: Operand::function_handle(tcx, call_did, - Slice::empty(), source_info.span), + List::empty(), source_info.span), args: vec![lhs, rhs], destination: Some((place, bb)), cleanup: None, @@ -190,8 +190,8 @@ impl RhsKind { fn sign_of_128bit(ty: Ty) -> Option { match ty.sty { - TypeVariants::TyInt(syntax::ast::IntTy::I128) => Some(true), - TypeVariants::TyUint(syntax::ast::UintTy::U128) => Some(false), + TyKind::Int(syntax::ast::IntTy::I128) => Some(true), + TyKind::Uint(syntax::ast::UintTy::U128) => Some(false), _ => None, } } diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index d876ee77e76cf..a56399eecd38e 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -495,7 +495,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { this.add(Qualif::NOT_CONST); } else { let base_ty = proj.base.ty(this.mir, this.tcx).to_ty(this.tcx); - if let ty::TyRawPtr(_) = base_ty.sty { + if let ty::RawPtr(_) = base_ty.sty { if !this.tcx.sess.features_untracked().const_raw_ptr_deref { emit_feature_err( &this.tcx.sess.parse_sess, "const_raw_ptr_deref", @@ -591,7 +591,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { if let Place::Projection(ref proj) = *place { if let ProjectionElem::Deref = proj.elem { let base_ty = proj.base.ty(self.mir, self.tcx).to_ty(self.tcx); - if let ty::TyRef(..) = base_ty.sty { + if let ty::Ref(..) = base_ty.sty { is_reborrow = true; } } @@ -638,10 +638,10 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { if self.mode == Mode::StaticMut { // Inside a `static mut`, &mut [...] is also allowed. match ty.sty { - ty::TyArray(..) | ty::TySlice(_) => forbidden_mut = false, + ty::Array(..) | ty::Slice(_) => forbidden_mut = false, _ => {} } - } else if let ty::TyArray(_, len) = ty.sty { + } else if let ty::Array(_, len) = ty.sty { // FIXME(eddyb) the `self.mode == Mode::Fn` condition // seems unnecessary, given that this is merely a ZST. if len.unwrap_usize(self.tcx) == 0 && self.mode == Mode::Fn { @@ -745,7 +745,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { } Rvalue::BinaryOp(op, ref lhs, _) => { - if let ty::TyRawPtr(_) = lhs.ty(self.mir, self.tcx).sty { + if let ty::RawPtr(_) = lhs.ty(self.mir, self.tcx).sty { assert!(op == BinOp::Eq || op == BinOp::Ne || op == BinOp::Le || op == BinOp::Lt || op == BinOp::Ge || op == BinOp::Gt || @@ -809,7 +809,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { let fn_ty = func.ty(self.mir, self.tcx); let mut callee_def_id = None; let (mut is_shuffle, mut is_const_fn) = (false, None); - if let ty::TyFnDef(def_id, _) = fn_ty.sty { + if let ty::FnDef(def_id, _) = fn_ty.sty { callee_def_id = Some(def_id); match self.tcx.fn_sig(def_id).abi() { Abi::RustIntrinsic | diff --git a/src/librustc_mir/transform/rustc_peek.rs b/src/librustc_mir/transform/rustc_peek.rs index 776d7888459f7..2147cc2a41a07 100644 --- a/src/librustc_mir/transform/rustc_peek.rs +++ b/src/librustc_mir/transform/rustc_peek.rs @@ -229,7 +229,7 @@ fn is_rustc_peek<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, if let Some(mir::Terminator { ref kind, source_info, .. }) = *terminator { if let mir::TerminatorKind::Call { func: ref oper, ref args, .. } = *kind { if let mir::Operand::Constant(ref func) = *oper { - if let ty::TyFnDef(def_id, _) = func.ty.sty { + if let ty::FnDef(def_id, _) = func.ty.sty { let abi = tcx.fn_sig(def_id).abi(); let name = tcx.item_name(def_id); if abi == Abi::RustIntrinsic && name == "rustc_peek" { diff --git a/src/librustc_mir/transform/uniform_array_move_out.rs b/src/librustc_mir/transform/uniform_array_move_out.rs index 4e9e085ca08a3..78464b2a104ec 100644 --- a/src/librustc_mir/transform/uniform_array_move_out.rs +++ b/src/librustc_mir/transform/uniform_array_move_out.rs @@ -80,7 +80,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UniformArrayMoveOutVisitor<'a, 'tcx> { // no need to transformation } else { let place_ty = proj.base.ty(self.mir, self.tcx).to_ty(self.tcx); - if let ty::TyArray(item_ty, const_size) = place_ty.sty { + if let ty::Array(item_ty, const_size) = place_ty.sty { if let Some(size) = const_size.assert_usize(self.tcx) { assert!(size <= u32::max_value() as u64, "uniform array move out doesn't supported @@ -202,7 +202,7 @@ impl MirPass for RestoreSubsliceArrayMoveOut { let opt_src_place = items.first().and_then(|x| *x).map(|x| x.2); let opt_size = opt_src_place.and_then(|src_place| { let src_ty = src_place.ty(mir, tcx).to_ty(tcx); - if let ty::TyArray(_, ref size_o) = src_ty.sty { + if let ty::Array(_, ref size_o) = src_ty.sty { size_o.assert_usize(tcx) } else { None diff --git a/src/librustc_mir/util/alignment.rs b/src/librustc_mir/util/alignment.rs index d1410210bda96..8717bd08ae4a5 100644 --- a/src/librustc_mir/util/alignment.rs +++ b/src/librustc_mir/util/alignment.rs @@ -59,7 +59,7 @@ fn is_within_packed<'a, 'tcx, L>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ProjectionElem::Field(..) => { let ty = base.ty(local_decls, tcx).to_ty(tcx); match ty.sty { - ty::TyAdt(def, _) if def.repr.packed() => { + ty::Adt(def, _) if def.repr.packed() => { return true } _ => {} diff --git a/src/librustc_mir/util/borrowck_errors.rs b/src/librustc_mir/util/borrowck_errors.rs index 7be6241b3f91e..1c5e1e406911a 100644 --- a/src/librustc_mir/util/borrowck_errors.rs +++ b/src/librustc_mir/util/borrowck_errors.rs @@ -425,8 +425,8 @@ pub trait BorrowckErrors<'cx>: Sized + Copy { o: Origin, ) -> DiagnosticBuilder<'cx> { let type_name = match (&ty.sty, is_index) { - (&ty::TyArray(_, _), Some(true)) | (&ty::TyArray(_, _), None) => "array", - (&ty::TySlice(_), _) => "slice", + (&ty::Array(_, _), Some(true)) | (&ty::Array(_, _), None) => "array", + (&ty::Slice(_), _) => "slice", _ => span_bug!(move_from_span, "this path should not cause illegal move"), }; let mut err = struct_span_err!( diff --git a/src/librustc_mir/util/elaborate_drops.rs b/src/librustc_mir/util/elaborate_drops.rs index bbffeec631abd..33e0554715f80 100644 --- a/src/librustc_mir/util/elaborate_drops.rs +++ b/src/librustc_mir/util/elaborate_drops.rs @@ -780,7 +780,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> fn open_drop<'a>(&mut self) -> BasicBlock { let ty = self.place_ty(self.place); match ty.sty { - ty::TyClosure(def_id, substs) => { + ty::Closure(def_id, substs) => { let tys : Vec<_> = substs.upvar_tys(def_id, self.tcx()).collect(); self.open_drop_for_tuple(&tys) } @@ -790,30 +790,30 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> // This should only happen for the self argument on the resume function. // It effetively only contains upvars until the generator transformation runs. // See librustc_mir/transform/generator.rs for more details. - ty::TyGenerator(def_id, substs, _) => { + ty::Generator(def_id, substs, _) => { let tys : Vec<_> = substs.upvar_tys(def_id, self.tcx()).collect(); self.open_drop_for_tuple(&tys) } - ty::TyTuple(tys) => { + ty::Tuple(tys) => { self.open_drop_for_tuple(tys) } - ty::TyAdt(def, substs) => { + ty::Adt(def, substs) => { if def.is_box() { self.open_drop_for_box(def, substs) } else { self.open_drop_for_adt(def, substs) } } - ty::TyDynamic(..) => { + ty::Dynamic(..) => { let unwind = self.unwind; // FIXME(#43234) let succ = self.succ; self.complete_drop(Some(DropFlagMode::Deep), succ, unwind) } - ty::TyArray(ety, size) => { + ty::Array(ety, size) => { let size = size.assert_usize(self.tcx()); self.open_drop_for_array(ety, size) }, - ty::TySlice(ety) => self.open_drop_for_array(ety, None), + ty::Slice(ety) => self.open_drop_for_array(ety, None), _ => bug!("open drop from non-ADT `{:?}`", ty) } diff --git a/src/librustc_passes/rvalue_promotion.rs b/src/librustc_passes/rvalue_promotion.rs index 114fd8754a21f..fca1c7f27ab37 100644 --- a/src/librustc_passes/rvalue_promotion.rs +++ b/src/librustc_passes/rvalue_promotion.rs @@ -328,7 +328,7 @@ fn check_expr_kind<'a, 'tcx>( e: &'tcx hir::Expr, node_ty: Ty<'tcx>) -> Promotability { let ty_result = match node_ty.sty { - ty::TyAdt(def, _) if def.has_dtor(v.tcx) => { + ty::Adt(def, _) if def.has_dtor(v.tcx) => { NotPromotable } _ => Promotable @@ -356,7 +356,7 @@ fn check_expr_kind<'a, 'tcx>( return NotPromotable; } match v.tables.node_id_to_type(lhs.hir_id).sty { - ty::TyRawPtr(_) => { + ty::RawPtr(_) => { assert!(op.node == hir::BinOpKind::Eq || op.node == hir::BinOpKind::Ne || op.node == hir::BinOpKind::Le || op.node == hir::BinOpKind::Lt || op.node == hir::BinOpKind::Ge || op.node == hir::BinOpKind::Gt); @@ -494,7 +494,7 @@ fn check_expr_kind<'a, 'tcx>( Some(ref expr) => { struct_result = struct_result & v.check_expr(&expr); }, None => {}, } - if let ty::TyAdt(adt, ..) = v.tables.expr_ty(e).sty { + if let ty::Adt(adt, ..) = v.tables.expr_ty(e).sty { // unsafe_cell_type doesn't necessarily exist with no_core if Some(adt.did) == v.tcx.lang_items().unsafe_cell_type() { return NotPromotable; diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index d9c3fc221dce1..dd536d673cf4d 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -89,11 +89,11 @@ struct ReachEverythingInTheInterfaceVisitor<'b, 'a: 'b, 'tcx: 'a> { impl<'a, 'tcx> EmbargoVisitor<'a, 'tcx> { fn item_ty_level(&self, item_def_id: DefId) -> Option { let ty_def_id = match self.tcx.type_of(item_def_id).sty { - ty::TyAdt(adt, _) => adt.did, - ty::TyForeign(did) => did, - ty::TyDynamic(ref obj, ..) if obj.principal().is_some() => + ty::Adt(adt, _) => adt.did, + ty::Foreign(did) => did, + ty::Dynamic(ref obj, ..) if obj.principal().is_some() => obj.principal().unwrap().def_id(), - ty::TyProjection(ref proj) => proj.trait_ref(self.tcx).def_id, + ty::Projection(ref proj) => proj.trait_ref(self.tcx).def_id, _ => return Some(AccessLevel::Public) }; if let Some(node_id) = self.tcx.hir.as_local_node_id(ty_def_id) { @@ -443,7 +443,7 @@ impl<'b, 'a, 'tcx> ReachEverythingInTheInterfaceVisitor<'b, 'a, 'tcx> { fn ty(&mut self) -> &mut Self { let ty = self.ev.tcx.type_of(self.item_def_id); ty.visit_with(self); - if let ty::TyFnDef(def_id, _) = ty.sty { + if let ty::FnDef(def_id, _) = ty.sty { if def_id == self.item_def_id { self.ev.tcx.fn_sig(def_id).visit_with(self); } @@ -470,14 +470,14 @@ impl<'b, 'a, 'tcx> ReachEverythingInTheInterfaceVisitor<'b, 'a, 'tcx> { impl<'b, 'a, 'tcx> TypeVisitor<'tcx> for ReachEverythingInTheInterfaceVisitor<'b, 'a, 'tcx> { fn visit_ty(&mut self, ty: Ty<'tcx>) -> bool { let ty_def_id = match ty.sty { - ty::TyAdt(adt, _) => Some(adt.did), - ty::TyForeign(did) => Some(did), - ty::TyDynamic(ref obj, ..) => obj.principal().map(|p| p.def_id()), - ty::TyProjection(ref proj) => Some(proj.item_def_id), - ty::TyFnDef(def_id, ..) | - ty::TyClosure(def_id, ..) | - ty::TyGenerator(def_id, ..) | - ty::TyAnon(def_id, _) => Some(def_id), + ty::Adt(adt, _) => Some(adt.did), + ty::Foreign(did) => Some(did), + ty::Dynamic(ref obj, ..) => obj.principal().map(|p| p.def_id()), + ty::Projection(ref proj) => Some(proj.item_def_id), + ty::FnDef(def_id, ..) | + ty::Closure(def_id, ..) | + ty::Generator(def_id, ..) | + ty::Anon(def_id, _) => Some(def_id), _ => None }; @@ -896,15 +896,15 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> { impl<'a, 'tcx> TypeVisitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> { fn visit_ty(&mut self, ty: Ty<'tcx>) -> bool { match ty.sty { - ty::TyAdt(&ty::AdtDef { did: def_id, .. }, ..) | - ty::TyFnDef(def_id, ..) | - ty::TyForeign(def_id) => { + ty::Adt(&ty::AdtDef { did: def_id, .. }, ..) | + ty::FnDef(def_id, ..) | + ty::Foreign(def_id) => { if !self.item_is_accessible(def_id) { let msg = format!("type `{}` is private", ty); self.tcx.sess.span_err(self.span, &msg); return true; } - if let ty::TyFnDef(..) = ty.sty { + if let ty::FnDef(..) = ty.sty { if self.tcx.fn_sig(def_id).visit_with(self) { return true; } @@ -919,7 +919,7 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> { } } } - ty::TyDynamic(ref predicates, ..) => { + ty::Dynamic(ref predicates, ..) => { let is_private = predicates.skip_binder().iter().any(|predicate| { let def_id = match *predicate { ty::ExistentialPredicate::Trait(trait_ref) => trait_ref.def_id, @@ -935,13 +935,13 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> { return true; } } - ty::TyProjection(ref proj) => { + ty::Projection(ref proj) => { let tcx = self.tcx; if self.check_trait_ref(proj.trait_ref(tcx)) { return true; } } - ty::TyAnon(def_id, ..) => { + ty::Anon(def_id, ..) => { for predicate in &self.tcx.predicates_of(def_id).predicates { let trait_ref = match *predicate { ty::Predicate::Trait(ref poly_trait_predicate) => { @@ -964,9 +964,9 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> { return true; } for subst in trait_ref.substs.iter() { - // Skip repeated `TyAnon`s to avoid infinite recursion. + // Skip repeated `Anon`s to avoid infinite recursion. if let UnpackedKind::Type(ty) = subst.unpack() { - if let ty::TyAnon(def_id, ..) = ty.sty { + if let ty::Anon(def_id, ..) = ty.sty { if !self.visited_anon_tys.insert(def_id) { continue; } @@ -1388,7 +1388,7 @@ impl<'a, 'tcx: 'a> SearchInterfaceForPrivateItemsVisitor<'a, 'tcx> { fn ty(&mut self) -> &mut Self { let ty = self.tcx.type_of(self.item_def_id); ty.visit_with(self); - if let ty::TyFnDef(def_id, _) = ty.sty { + if let ty::FnDef(def_id, _) = ty.sty { if def_id == self.item_def_id { self.tcx.fn_sig(def_id).visit_with(self); } @@ -1434,10 +1434,10 @@ impl<'a, 'tcx: 'a> SearchInterfaceForPrivateItemsVisitor<'a, 'tcx> { impl<'a, 'tcx: 'a> TypeVisitor<'tcx> for SearchInterfaceForPrivateItemsVisitor<'a, 'tcx> { fn visit_ty(&mut self, ty: Ty<'tcx>) -> bool { let ty_def_id = match ty.sty { - ty::TyAdt(adt, _) => Some(adt.did), - ty::TyForeign(did) => Some(did), - ty::TyDynamic(ref obj, ..) => obj.principal().map(|p| p.def_id()), - ty::TyProjection(ref proj) => { + ty::Adt(adt, _) => Some(adt.did), + ty::Foreign(did) => Some(did), + ty::Dynamic(ref obj, ..) => obj.principal().map(|p| p.def_id()), + ty::Projection(ref proj) => { if self.required_visibility == ty::Visibility::Invisible { // Conservatively approximate the whole type alias as public without // recursing into its components when determining impl publicity. diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index 19dc35f854eed..80f6c263e1999 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -656,7 +656,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> { (Def::Static(self.definitions.local_def_id(item.id), m), ValueNS) } ForeignItemKind::Ty => { - (Def::TyForeign(self.definitions.local_def_id(item.id)), TypeNS) + (Def::ForeignTy(self.definitions.local_def_id(item.id)), TypeNS) } ForeignItemKind::Macro(_) => unreachable!(), }; @@ -692,7 +692,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> { span); self.define(parent, ident, TypeNS, (module, vis, DUMMY_SP, expansion)); } - Def::Variant(..) | Def::TyAlias(..) | Def::TyForeign(..) => { + Def::Variant(..) | Def::TyAlias(..) | Def::ForeignTy(..) => { self.define(parent, ident, TypeNS, (def, vis, DUMMY_SP, expansion)); } Def::Fn(..) | Def::Static(..) | Def::Const(..) | Def::VariantCtor(..) => { diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 004a9a77dd98f..3241459f64fd8 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -35,7 +35,7 @@ use self::TypeParameters::*; use self::RibKind::*; use rustc::hir::map::{Definitions, DefCollector}; -use rustc::hir::{self, PrimTy, TyBool, TyChar, TyFloat, TyInt, TyUint, TyStr}; +use rustc::hir::{self, PrimTy, Bool, Char, Float, Int, Uint, Str}; use rustc::middle::cstore::CrateStore; use rustc::session::Session; use rustc::lint; @@ -539,7 +539,7 @@ impl<'a> PathSource<'a> { Def::Trait(..) | Def::TyAlias(..) | Def::AssociatedTy(..) | Def::PrimTy(..) | Def::TyParam(..) | Def::SelfTy(..) | Def::Existential(..) | - Def::TyForeign(..) => true, + Def::ForeignTy(..) => true, _ => false, }, PathSource::Trait(AliasPossibility::No) => match def { @@ -1280,23 +1280,23 @@ impl PrimitiveTypeTable { fn new() -> PrimitiveTypeTable { let mut table = PrimitiveTypeTable { primitive_types: FxHashMap() }; - table.intern("bool", TyBool); - table.intern("char", TyChar); - table.intern("f32", TyFloat(FloatTy::F32)); - table.intern("f64", TyFloat(FloatTy::F64)); - table.intern("isize", TyInt(IntTy::Isize)); - table.intern("i8", TyInt(IntTy::I8)); - table.intern("i16", TyInt(IntTy::I16)); - table.intern("i32", TyInt(IntTy::I32)); - table.intern("i64", TyInt(IntTy::I64)); - table.intern("i128", TyInt(IntTy::I128)); - table.intern("str", TyStr); - table.intern("usize", TyUint(UintTy::Usize)); - table.intern("u8", TyUint(UintTy::U8)); - table.intern("u16", TyUint(UintTy::U16)); - table.intern("u32", TyUint(UintTy::U32)); - table.intern("u64", TyUint(UintTy::U64)); - table.intern("u128", TyUint(UintTy::U128)); + table.intern("bool", Bool); + table.intern("char", Char); + table.intern("f32", Float(FloatTy::F32)); + table.intern("f64", Float(FloatTy::F64)); + table.intern("isize", Int(IntTy::Isize)); + table.intern("i8", Int(IntTy::I8)); + table.intern("i16", Int(IntTy::I16)); + table.intern("i32", Int(IntTy::I32)); + table.intern("i64", Int(IntTy::I64)); + table.intern("i128", Int(IntTy::I128)); + table.intern("str", Str); + table.intern("usize", Uint(UintTy::Usize)); + table.intern("u8", Uint(UintTy::U8)); + table.intern("u16", Uint(UintTy::U16)); + table.intern("u32", Uint(UintTy::U32)); + table.intern("u64", Uint(UintTy::U64)); + table.intern("u128", Uint(UintTy::U128)); table } @@ -3900,7 +3900,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { } } // Add primitive types to the mix - if filter_fn(Def::PrimTy(TyBool)) { + if filter_fn(Def::PrimTy(Bool)) { names.extend( self.primitive_type_table.primitive_types.iter().map(|(name, _)| name) ) diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index b2d78850cbab9..9facd39ebea21 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -534,7 +534,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { pub fn get_expr_data(&self, expr: &ast::Expr) -> Option { let hir_node = self.tcx.hir.expect_expr(expr.id); let ty = self.tables.expr_ty_adjusted_opt(&hir_node); - if ty.is_none() || ty.unwrap().sty == ty::TyError { + if ty.is_none() || ty.unwrap().sty == ty::Error { return None; } match expr.node { @@ -551,7 +551,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { } }; match self.tables.expr_ty_adjusted(&hir_node).sty { - ty::TyAdt(def, _) if !def.is_enum() => { + ty::Adt(def, _) if !def.is_enum() => { let variant = &def.non_enum_variant(); let index = self.tcx.find_field_index(ident, variant).unwrap(); let sub_span = self.span_utils.span_for_last_ident(expr.span); @@ -563,7 +563,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { ref_id: id_from_def_id(variant.fields[index].did), })); } - ty::TyTuple(..) => None, + ty::Tuple(..) => None, _ => { debug!("Expected struct or union type, found {:?}", ty); None @@ -572,7 +572,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { } ast::ExprKind::Struct(ref path, ..) => { match self.tables.expr_ty_adjusted(&hir_node).sty { - ty::TyAdt(def, _) if !def.is_enum() => { + ty::Adt(def, _) if !def.is_enum() => { let sub_span = self.span_utils.span_for_last_ident(path.span); filter!(self.span_utils, sub_span, path.span, None); let span = self.span_from_span(sub_span.unwrap()); @@ -674,7 +674,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { hir::QPath::Resolved(_, ref path) => path.def, hir::QPath::TypeRelative(..) => { let ty = hir_ty_to_ty(self.tcx, ty); - if let ty::TyProjection(proj) = ty.sty { + if let ty::Projection(proj) = ty.sty { return HirDef::AssociatedTy(proj.item_def_id); } HirDef::Err @@ -747,7 +747,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { HirDef::Union(def_id) | HirDef::Enum(def_id) | HirDef::TyAlias(def_id) | - HirDef::TyForeign(def_id) | + HirDef::ForeignTy(def_id) | HirDef::TraitAlias(def_id) | HirDef::AssociatedExistential(def_id) | HirDef::AssociatedTy(def_id) | diff --git a/src/librustc_traits/chalk_context.rs b/src/librustc_traits/chalk_context.rs index b0f0b105f3ecb..4227144e204fb 100644 --- a/src/librustc_traits/chalk_context.rs +++ b/src/librustc_traits/chalk_context.rs @@ -237,7 +237,7 @@ impl context::ContextOps> for ChalkContext<'cx, 'gcx> { // _ => false, // }, // Kind::Type(ty) => match ty.sty { -// ty::TyInfer(ty::InferTy::CanonicalTy(cvar1)) => cvar == cvar1, +// ty::Infer(ty::InferTy::CanonicalTy(cvar1)) => cvar == cvar1, // _ => false, // }, // }) diff --git a/src/librustc_traits/dropck_outlives.rs b/src/librustc_traits/dropck_outlives.rs index 973580bcbe904..a27a447ad4b09 100644 --- a/src/librustc_traits/dropck_outlives.rs +++ b/src/librustc_traits/dropck_outlives.rs @@ -119,11 +119,11 @@ fn dropck_outlives<'tcx>( match ty.sty { // All parameters live for the duration of the // function. - ty::TyParam(..) => {} + ty::Param(..) => {} // A projection that we couldn't resolve - it // might have a destructor. - ty::TyProjection(..) | ty::TyAnon(..) => { + ty::Projection(..) | ty::Anon(..) => { result.kinds.push(ty.into()); } @@ -173,39 +173,39 @@ fn dtorck_constraint_for_ty<'a, 'gcx, 'tcx>( } let result = match ty.sty { - ty::TyBool - | ty::TyChar - | ty::TyInt(_) - | ty::TyUint(_) - | ty::TyFloat(_) - | ty::TyStr - | ty::TyNever - | ty::TyForeign(..) - | ty::TyRawPtr(..) - | ty::TyRef(..) - | ty::TyFnDef(..) - | ty::TyFnPtr(_) - | ty::TyGeneratorWitness(..) => { + ty::Bool + | ty::Char + | ty::Int(_) + | ty::Uint(_) + | ty::Float(_) + | ty::Str + | ty::Never + | ty::Foreign(..) + | ty::RawPtr(..) + | ty::Ref(..) + | ty::FnDef(..) + | ty::FnPtr(_) + | ty::GeneratorWitness(..) => { // these types never have a destructor Ok(DtorckConstraint::empty()) } - ty::TyArray(ety, _) | ty::TySlice(ety) => { + ty::Array(ety, _) | ty::Slice(ety) => { // single-element containers, behave like their element dtorck_constraint_for_ty(tcx, span, for_ty, depth + 1, ety) } - ty::TyTuple(tys) => tys + ty::Tuple(tys) => tys .iter() .map(|ty| dtorck_constraint_for_ty(tcx, span, for_ty, depth + 1, ty)) .collect(), - ty::TyClosure(def_id, substs) => substs + ty::Closure(def_id, substs) => substs .upvar_tys(def_id, tcx) .map(|ty| dtorck_constraint_for_ty(tcx, span, for_ty, depth + 1, ty)) .collect(), - ty::TyGenerator(def_id, substs, _movability) => { + ty::Generator(def_id, substs, _movability) => { // rust-lang/rust#49918: types can be constructed, stored // in the interior, and sit idle when generator yields // (and is subsequently dropped). @@ -216,7 +216,7 @@ fn dtorck_constraint_for_ty<'a, 'gcx, 'tcx>( // its interior). // // However, the interior's representation uses things like - // TyGeneratorWitness that explicitly assume they are not + // GeneratorWitness that explicitly assume they are not // traversed in such a manner. So instead, we will // simplify things for now by treating all generators as // if they were like trait objects, where its upvars must @@ -242,7 +242,7 @@ fn dtorck_constraint_for_ty<'a, 'gcx, 'tcx>( Ok(constraint) } - ty::TyAdt(def, substs) => { + ty::Adt(def, substs) => { let DtorckConstraint { dtorck_types, outlives, @@ -259,20 +259,20 @@ fn dtorck_constraint_for_ty<'a, 'gcx, 'tcx>( // Objects must be alive in order for their destructor // to be called. - ty::TyDynamic(..) => Ok(DtorckConstraint { + ty::Dynamic(..) => Ok(DtorckConstraint { outlives: vec![ty.into()], dtorck_types: vec![], overflows: vec![], }), // Types that can't be resolved. Pass them forward. - ty::TyProjection(..) | ty::TyAnon(..) | ty::TyParam(..) => Ok(DtorckConstraint { + ty::Projection(..) | ty::Anon(..) | ty::Param(..) => Ok(DtorckConstraint { outlives: vec![], dtorck_types: vec![ty], overflows: vec![], }), - ty::TyInfer(..) | ty::TyError => { + ty::Infer(..) | ty::Error => { // By the time this code runs, all type variables ought to // be fully resolved. Err(NoSolution) diff --git a/src/librustc_traits/lowering.rs b/src/librustc_traits/lowering.rs index a3c24f8af22fc..9fd3b318ec140 100644 --- a/src/librustc_traits/lowering.rs +++ b/src/librustc_traits/lowering.rs @@ -17,7 +17,7 @@ use rustc::traits::{ WhereClause, }; use rustc::ty::query::Providers; -use rustc::ty::{self, Slice, TyCtxt}; +use rustc::ty::{self, List, TyCtxt}; use rustc_data_structures::fx::FxHashSet; use std::mem; use syntax::ast; @@ -162,7 +162,7 @@ crate fn program_clauses_for<'a, 'tcx>( DefPathData::AssocTypeInImpl(..) => program_clauses_for_associated_type_value(tcx, def_id), DefPathData::AssocTypeInTrait(..) => program_clauses_for_associated_type_def(tcx, def_id), DefPathData::TypeNs(..) => program_clauses_for_type_def(tcx, def_id), - _ => Slice::empty(), + _ => List::empty(), } } @@ -319,7 +319,7 @@ fn program_clauses_for_trait<'a, 'tcx>( fn program_clauses_for_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Clauses<'tcx> { if let ImplPolarity::Negative = tcx.impl_polarity(def_id) { - return Slice::empty(); + return List::empty(); } // Rule Implemented-From-Impl (see rustc guide) diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index ccdb751bc4eed..a528c8e9b4f96 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -108,7 +108,7 @@ struct GenericArgMismatchErrorCode { /// Dummy type used for the `Self` of a `TraitRef` created for converting /// a trait object, and which gets removed in `ExistentialTraitRef`. /// This type must not appear anywhere in other converted types. -const TRAIT_OBJECT_DUMMY_SELF: ty::TypeVariants<'static> = ty::TyInfer(ty::FreshTy(0)); +const TRAIT_OBJECT_DUMMY_SELF: ty::TyKind<'static> = ty::Infer(ty::FreshTy(0)); impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o { pub fn ast_region_to_region(&self, @@ -1239,8 +1239,8 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o { Err(ErrorReported) => return (tcx.types.err, Def::Err), } } - (&ty::TyParam(_), Def::SelfTy(Some(param_did), None)) | - (&ty::TyParam(_), Def::TyParam(param_did)) => { + (&ty::Param(_), Def::SelfTy(Some(param_did), None)) | + (&ty::Param(_), Def::TyParam(param_did)) => { match self.find_bound_for_assoc_item(param_did, assoc_name, span) { Ok(bound) => bound, Err(ErrorReported) => return (tcx.types.err, Def::Err), @@ -1387,7 +1387,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o { ) } Def::Enum(did) | Def::TyAlias(did) | Def::Struct(did) | - Def::Union(did) | Def::TyForeign(did) => { + Def::Union(did) | Def::ForeignTy(did) => { assert_eq!(opt_self_ty, None); self.prohibit_generics(path.segments.split_last().unwrap().1); self.ast_path_to_ty(span, did, path.segments.last().unwrap()) @@ -1438,12 +1438,12 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o { assert_eq!(opt_self_ty, None); self.prohibit_generics(&path.segments); match prim_ty { - hir::TyBool => tcx.types.bool, - hir::TyChar => tcx.types.char, - hir::TyInt(it) => tcx.mk_mach_int(it), - hir::TyUint(uit) => tcx.mk_mach_uint(uit), - hir::TyFloat(ft) => tcx.mk_mach_float(ft), - hir::TyStr => tcx.mk_str() + hir::Bool => tcx.types.bool, + hir::Char => tcx.types.char, + hir::Int(it) => tcx.mk_mach_int(it), + hir::Uint(uit) => tcx.mk_mach_uint(uit), + hir::Float(ft) => tcx.mk_mach_float(ft), + hir::Str => tcx.mk_str() } } Def::Err => { @@ -1474,7 +1474,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o { } hir::TyKind::Rptr(ref region, ref mt) => { let r = self.ast_region_to_region(region, None); - debug!("TyRef r={:?}", r); + debug!("Ref r={:?}", r); let t = self.ast_ty_to_ty(&mt.ty); tcx.mk_ref(r, ty::TypeAndMut {ty: t, mutbl: mt.mutbl}) } @@ -1513,7 +1513,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o { let length_def_id = tcx.hir.local_def_id(length.id); let substs = Substs::identity_for_item(tcx, length_def_id); let length = ty::Const::unevaluated(tcx, length_def_id, substs, tcx.types.usize); - let array_ty = tcx.mk_ty(ty::TyArray(self.ast_ty_to_ty(&ty), length)); + let array_ty = tcx.mk_ty(ty::Array(self.ast_ty_to_ty(&ty), length)); self.normalize_ty(ast_ty.span, array_ty) } hir::TyKind::Typeof(ref _e) => { @@ -1525,7 +1525,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o { tcx.types.err } hir::TyKind::Infer => { - // TyInfer also appears as the type of arguments or return + // Infer also appears as the type of arguments or return // values in a ExprKind::Closure, or as // the type of local variables. Both of these cases are // handled specially and will not descend into this routine. @@ -1666,7 +1666,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o { /// we return `None`. fn compute_object_lifetime_bound(&self, span: Span, - existential_predicates: ty::Binder<&'tcx ty::Slice>>) + existential_predicates: ty::Binder<&'tcx ty::List>>) -> Option> // if None, use the default { let tcx = self.tcx(); diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index c14a07b7cf5d0..ae68584f2446f 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -53,7 +53,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { PatKind::Lit(ref lt) => { let ty = self.check_expr(lt); match ty.sty { - ty::TypeVariants::TyRef(..) => false, + ty::Ref(..) => false, _ => true, } } @@ -74,7 +74,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // Peel off as many `&` or `&mut` from the discriminant as possible. For example, // for `match &&&mut Some(5)` the loop runs three times, aborting when it reaches - // the `Some(5)` which is not of type TyRef. + // the `Some(5)` which is not of type Ref. // // For each ampersand peeled off, update the binding mode and push the original // type into the adjustments vector. @@ -84,8 +84,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { expected = loop { debug!("inspecting {:?} with type {:?}", exp_ty, exp_ty.sty); match exp_ty.sty { - ty::TypeVariants::TyRef(_, inner_ty, inner_mutability) => { - debug!("current discriminant is TyRef, inserting implicit deref"); + ty::Ref(_, inner_ty, inner_mutability) => { + debug!("current discriminant is Ref, inserting implicit deref"); // Preserve the reference type. We'll need it later during HAIR lowering. pat_adjustments.push(exp_ty); @@ -150,8 +150,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if let hir::ExprKind::Lit(ref lt) = lt.node { if let ast::LitKind::ByteStr(_) = lt.node { let expected_ty = self.structurally_resolved_type(pat.span, expected); - if let ty::TyRef(_, r_ty, _) = expected_ty.sty { - if let ty::TySlice(_) = r_ty.sty { + if let ty::Ref(_, r_ty, _) = expected_ty.sty { + if let ty::Slice(_) = r_ty.sty { pat_ty = tcx.mk_imm_ref(tcx.types.re_static, tcx.mk_slice(tcx.types.u8)) } @@ -285,7 +285,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let mut expected_len = elements.len(); if ddpos.is_some() { // Require known type only when `..` is present - if let ty::TyTuple(ref tys) = + if let ty::Tuple(ref tys) = self.structurally_resolved_type(pat.span, expected).sty { expected_len = tys.len(); } @@ -297,7 +297,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // from all tuple elements isn't trivial. TypeVariableOrigin::TypeInference(pat.span))); let element_tys = tcx.mk_type_list(element_tys_iter); - let pat_ty = tcx.mk_ty(ty::TyTuple(element_tys)); + let pat_ty = tcx.mk_ty(ty::Tuple(element_tys)); self.demand_eqtype(pat.span, expected, pat_ty); for (i, elem) in elements.iter().enumerate_and_adjust(max_len, ddpos) { self.check_pat_walk(elem, &element_tys[i], def_bm, true); @@ -333,7 +333,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // hack detailed in (*) below. debug!("check_pat_walk: expected={:?}", expected); let (rptr_ty, inner_ty) = match expected.sty { - ty::TyRef(_, r_ty, r_mutbl) if r_mutbl == mutbl => { + ty::Ref(_, r_ty, r_mutbl) if r_mutbl == mutbl => { (expected, r_ty) } _ => { @@ -375,7 +375,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { PatKind::Slice(ref before, ref slice, ref after) => { let expected_ty = self.structurally_resolved_type(pat.span, expected); let (inner_ty, slice_ty) = match expected_ty.sty { - ty::TyArray(inner_ty, size) => { + ty::Array(inner_ty, size) => { let size = size.unwrap_usize(tcx); let min_len = before.len() as u64 + after.len() as u64; if slice.is_none() { @@ -400,16 +400,16 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { (inner_ty, tcx.types.err) } } - ty::TySlice(inner_ty) => (inner_ty, expected_ty), + ty::Slice(inner_ty) => (inner_ty, expected_ty), _ => { if !expected_ty.references_error() { let mut err = struct_span_err!( tcx.sess, pat.span, E0529, "expected an array or slice, found `{}`", expected_ty); - if let ty::TyRef(_, ty, _) = expected_ty.sty { + if let ty::Ref(_, ty, _) = expected_ty.sty { match ty.sty { - ty::TyArray(..) | ty::TySlice(..) => { + ty::Array(..) | ty::Slice(..) => { err.help("the semantics of slice patterns changed \ recently; see issue #23121"); } @@ -493,7 +493,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { pub fn check_dereferencable(&self, span: Span, expected: Ty<'tcx>, inner: &hir::Pat) -> bool { if let PatKind::Binding(..) = inner.node { if let Some(mt) = self.shallow_resolve(expected).builtin_deref(true) { - if let ty::TyDynamic(..) = mt.ty.sty { + if let ty::Dynamic(..) = mt.ty.sty { // This is "x = SomeTrait" being reduced from // "let &x = &SomeTrait" or "let box x = Box", an error. let type_str = self.ty_to_string(expected); @@ -818,7 +818,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); if subpats.len() == variant.fields.len() || subpats.len() < variant.fields.len() && ddpos.is_some() { let substs = match pat_ty.sty { - ty::TyAdt(_, substs) => substs, + ty::Adt(_, substs) => substs, ref ty => bug!("unexpected pattern type {:?}", ty), }; for (i, subpat) in subpats.iter().enumerate_and_adjust(variant.fields.len(), ddpos) { @@ -854,7 +854,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); let tcx = self.tcx; let (substs, adt) = match adt_ty.sty { - ty::TyAdt(adt, substs) => (substs, adt), + ty::Adt(adt, substs) => (substs, adt), _ => span_bug!(span, "struct pattern is not an ADT") }; let kind_name = adt.variant_descr(); diff --git a/src/librustc_typeck/check/autoderef.rs b/src/librustc_typeck/check/autoderef.rs index 09562614982b8..743a2390ec43d 100644 --- a/src/librustc_typeck/check/autoderef.rs +++ b/src/librustc_typeck/check/autoderef.rs @@ -177,7 +177,7 @@ impl<'a, 'gcx, 'tcx> Autoderef<'a, 'gcx, 'tcx> { self.fcx.try_overloaded_deref(self.span, source, needs) .and_then(|InferOk { value: method, obligations: o }| { obligations.extend(o); - if let ty::TyRef(region, _, mutbl) = method.sig.output().sty { + if let ty::Ref(region, _, mutbl) = method.sig.output().sty { Some(OverloadedDeref { region, mutbl, diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs index ec127d26ab307..462bde2ab4f13 100644 --- a/src/librustc_typeck/check/callee.rs +++ b/src/librustc_typeck/check/callee.rs @@ -95,13 +95,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // If the callee is a bare function or a closure, then we're all set. match adjusted_ty.sty { - ty::TyFnDef(..) | ty::TyFnPtr(_) => { + ty::FnDef(..) | ty::FnPtr(_) => { let adjustments = autoderef.adjust_steps(Needs::None); self.apply_adjustments(callee_expr, adjustments); return Some(CallStep::Builtin(adjusted_ty)); } - ty::TyClosure(def_id, substs) => { + ty::Closure(def_id, substs) => { assert_eq!(def_id.krate, LOCAL_CRATE); // Check whether this is a call to a closure where we @@ -135,7 +135,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // over the top. The simplest fix by far is to just ignore // this case and deref again, so we wind up with // `FnMut::call_mut(&mut *x, ())`. - ty::TyRef(..) if autoderef.step_count() == 0 => { + ty::Ref(..) if autoderef.step_count() == 0 => { return None; } @@ -175,7 +175,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let method = self.register_infer_ok_obligations(ok); let mut autoref = None; if borrow { - if let ty::TyRef(region, _, mutbl) = method.sig.inputs()[0].sty { + if let ty::Ref(region, _, mutbl) = method.sig.inputs()[0].sty { let mutbl = match mutbl { hir::MutImmutable => AutoBorrowMutability::Immutable, hir::MutMutable => AutoBorrowMutability::Mutable { @@ -206,13 +206,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { expected: Expectation<'tcx>) -> Ty<'tcx> { let (fn_sig, def_span) = match callee_ty.sty { - ty::TyFnDef(def_id, _) => { + ty::FnDef(def_id, _) => { (callee_ty.fn_sig(self.tcx), self.tcx.hir.span_if_local(def_id)) } - ty::TyFnPtr(sig) => (sig, None), + ty::FnPtr(sig) => (sig, None), ref t => { let mut unit_variant = None; - if let &ty::TyAdt(adt_def, ..) = t { + if let &ty::Adt(adt_def, ..) = t { if adt_def.is_enum() { if let hir::ExprKind::Call(ref expr, _) = call_expr.node { unit_variant = Some(self.tcx.hir.node_to_pretty_string(expr.id)) diff --git a/src/librustc_typeck/check/cast.rs b/src/librustc_typeck/check/cast.rs index 29d2fe2c7b63e..52e5e57f74759 100644 --- a/src/librustc_typeck/check/cast.rs +++ b/src/librustc_typeck/check/cast.rs @@ -103,10 +103,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } Ok(match t.sty { - ty::TySlice(_) | ty::TyStr => Some(PointerKind::Length), - ty::TyDynamic(ref tty, ..) => + ty::Slice(_) | ty::Str => Some(PointerKind::Length), + ty::Dynamic(ref tty, ..) => Some(PointerKind::Vtable(tty.principal().map(|p| p.def_id()))), - ty::TyAdt(def, substs) if def.is_struct() => { + ty::Adt(def, substs) if def.is_struct() => { match def.non_enum_variant().fields.last() { None => Some(PointerKind::Thin), Some(f) => { @@ -115,25 +115,25 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } } } - ty::TyTuple(fields) => match fields.last() { + ty::Tuple(fields) => match fields.last() { None => Some(PointerKind::Thin), Some(f) => self.pointer_kind(f, span)? }, // Pointers to foreign types are thin, despite being unsized - ty::TyForeign(..) => Some(PointerKind::Thin), + ty::Foreign(..) => Some(PointerKind::Thin), // We should really try to normalize here. - ty::TyProjection(ref pi) => Some(PointerKind::OfProjection(pi)), - ty::TyAnon(def_id, substs) => Some(PointerKind::OfAnon(def_id, substs)), - ty::TyParam(ref p) => Some(PointerKind::OfParam(p)), + ty::Projection(ref pi) => Some(PointerKind::OfProjection(pi)), + ty::Anon(def_id, substs) => Some(PointerKind::OfAnon(def_id, substs)), + ty::Param(ref p) => Some(PointerKind::OfParam(p)), // Insufficient type information. - ty::TyInfer(_) => None, + ty::Infer(_) => None, - ty::TyBool | ty::TyChar | ty::TyInt(..) | ty::TyUint(..) | - ty::TyFloat(_) | ty::TyArray(..) | ty::TyGeneratorWitness(..) | - ty::TyRawPtr(_) | ty::TyRef(..) | ty::TyFnDef(..) | - ty::TyFnPtr(..) | ty::TyClosure(..) | ty::TyGenerator(..) | - ty::TyAdt(..) | ty::TyNever | ty::TyError => { + ty::Bool | ty::Char | ty::Int(..) | ty::Uint(..) | + ty::Float(_) | ty::Array(..) | ty::GeneratorWitness(..) | + ty::RawPtr(_) | ty::Ref(..) | ty::FnDef(..) | + ty::FnPtr(..) | ty::Closure(..) | ty::Generator(..) | + ty::Adt(..) | ty::Never | ty::Error => { self.tcx.sess.delay_span_bug( span, &format!("`{:?}` should be sized but is not?", t)); return Err(ErrorReported); @@ -199,7 +199,7 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> { // cases now. We do a more thorough check at the end, once // inference is more completely known. match cast_ty.sty { - ty::TyDynamic(..) | ty::TySlice(..) => { + ty::Dynamic(..) | ty::Slice(..) => { check.report_cast_to_unsized_type(fcx); Err(ErrorReported) } @@ -319,7 +319,7 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> { fcx.resolve_type_vars_if_possible(&self.expr_ty), tstr); match self.expr_ty.sty { - ty::TyRef(_, _, mt) => { + ty::Ref(_, _, mt) => { let mtstr = match mt { hir::MutMutable => "mut ", hir::MutImmutable => "", @@ -343,7 +343,7 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> { tstr); } } - ty::TyAdt(def, ..) if def.is_box() => { + ty::Adt(def, ..) if def.is_box() => { match fcx.tcx.sess.source_map().span_to_snippet(self.cast_span) { Ok(s) => { err.span_suggestion(self.cast_span, @@ -429,7 +429,7 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> { (Some(t_from), Some(t_cast)) => (t_from, t_cast), // Function item types may need to be reified before casts. (None, Some(t_cast)) => { - if let ty::TyFnDef(..) = self.expr_ty.sty { + if let ty::FnDef(..) = self.expr_ty.sty { // Attempt a coercion to a fn pointer type. let f = self.expr_ty.fn_sig(fcx.tcx); let res = fcx.try_coerce(self.expr, @@ -477,12 +477,12 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> { (RPtr(p), Int(_)) | (RPtr(p), Float) => { match p.ty.sty { - ty::TypeVariants::TyInt(_) | - ty::TypeVariants::TyUint(_) | - ty::TypeVariants::TyFloat(_) => { + ty::Int(_) | + ty::Uint(_) | + ty::Float(_) => { Err(CastError::NeedDeref) } - ty::TypeVariants::TyInfer(t) => { + ty::Infer(t) => { match t { ty::InferTy::IntVar(_) | ty::InferTy::FloatVar(_) => Err(CastError::NeedDeref), @@ -583,7 +583,7 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> { // array-ptr-cast. if m_expr.mutbl == hir::MutImmutable && m_cast.mutbl == hir::MutImmutable { - if let ty::TyArray(ety, _) = m_expr.ty.sty { + if let ty::Array(ety, _) = m_expr.ty.sty { // Due to the limitations of LLVM global constants, // region pointers end up pointing at copies of // vector elements instead of the original values. diff --git a/src/librustc_typeck/check/closure.rs b/src/librustc_typeck/check/closure.rs index 242b69294a5bc..a283e032e0e02 100644 --- a/src/librustc_typeck/check/closure.rs +++ b/src/librustc_typeck/check/closure.rs @@ -190,7 +190,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { ); match expected_ty.sty { - ty::TyDynamic(ref object_type, ..) => { + ty::Dynamic(ref object_type, ..) => { let sig = object_type .projection_bounds() .filter_map(|pb| { @@ -203,8 +203,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { .and_then(|p| self.tcx.lang_items().fn_trait_kind(p.def_id())); (sig, kind) } - ty::TyInfer(ty::TyVar(vid)) => self.deduce_expectations_from_obligations(vid), - ty::TyFnPtr(sig) => { + ty::Infer(ty::TyVar(vid)) => self.deduce_expectations_from_obligations(vid), + ty::FnPtr(sig) => { let expected_sig = ExpectedSig { cause_span: None, sig: sig.skip_binder().clone(), @@ -269,9 +269,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // NB: This predicate is created by breaking down a // `ClosureType: FnFoo()` predicate, where - // `ClosureType` represents some `TyClosure`. It can't + // `ClosureType` represents some `Closure`. It can't // possibly be referring to the current closure, - // because we haven't produced the `TyClosure` for + // because we haven't produced the `Closure` for // this closure yet; this is exactly why the other // code is looking for a self type of a unresolved // inference variable. @@ -317,7 +317,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { ); let input_tys = match arg_param_ty.sty { - ty::TyTuple(tys) => tys.into_iter(), + ty::Tuple(tys) => tys.into_iter(), _ => { return None; } @@ -353,7 +353,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { trait_ref, self_ty ); match self_ty.sty { - ty::TyInfer(ty::TyVar(v)) if expected_vid == v => Some(trait_ref), + ty::Infer(ty::TyVar(v)) if expected_vid == v => Some(trait_ref), _ => None, } } diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs index e3b0b8cccf31c..763adb007c3a4 100644 --- a/src/librustc_typeck/check/coercion.rs +++ b/src/librustc_typeck/check/coercion.rs @@ -210,11 +210,11 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> { // Note: does not attempt to resolve type variables we encounter. // See above for details. match b.sty { - ty::TyRawPtr(mt_b) => { + ty::RawPtr(mt_b) => { return self.coerce_unsafe_ptr(a, b, mt_b.mutbl); } - ty::TyRef(r_b, ty, mutbl) => { + ty::Ref(r_b, ty, mutbl) => { let mt_b = ty::TypeAndMut { ty, mutbl }; return self.coerce_borrowed_pointer(a, b, r_b, mt_b); } @@ -223,7 +223,7 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> { } match a.sty { - ty::TyFnDef(..) => { + ty::FnDef(..) => { // Function items are coercible to any closure // type; function pointers are not (that would // require double indirection). @@ -231,12 +231,12 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> { // items to drop the unsafe qualifier. self.coerce_from_fn_item(a, b) } - ty::TyFnPtr(a_f) => { + ty::FnPtr(a_f) => { // We permit coercion of fn pointers to drop the // unsafe qualifier. self.coerce_from_fn_pointer(a, a_f, b) } - ty::TyClosure(def_id_a, substs_a) => { + ty::Closure(def_id_a, substs_a) => { // Non-capturing closures are coercible to // function pointers self.coerce_closure_to_fn(a, def_id_a, substs_a, b) @@ -267,7 +267,7 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> { // yield. let (r_a, mt_a) = match a.sty { - ty::TyRef(r_a, ty, mutbl) => { + ty::Ref(r_a, ty, mutbl) => { let mt_a = ty::TypeAndMut { ty, mutbl }; coerce_mutbls(mt_a.mutbl, mt_b.mutbl)?; (r_a, mt_a) @@ -429,7 +429,7 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> { // Now apply the autoref. We have to extract the region out of // the final ref type we got. let r_borrow = match ty.sty { - ty::TyRef(r_borrow, _, _) => r_borrow, + ty::Ref(r_borrow, _, _) => r_borrow, _ => span_bug!(span, "expected a ref type, got {:?}", ty), }; let mutbl = match mt_b.mutbl { @@ -473,7 +473,7 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> { // Handle reborrows before selecting `Source: CoerceUnsized`. let reborrow = match (&source.sty, &target.sty) { - (&ty::TyRef(_, ty_a, mutbl_a), &ty::TyRef(_, _, mutbl_b)) => { + (&ty::Ref(_, ty_a, mutbl_a), &ty::Ref(_, _, mutbl_b)) => { coerce_mutbls(mutbl_a, mutbl_b)?; let coercion = Coercion(self.cause.span); @@ -498,7 +498,7 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> { }) })) } - (&ty::TyRef(_, ty_a, mt_a), &ty::TyRawPtr(ty::TypeAndMut { mutbl: mt_b, .. })) => { + (&ty::Ref(_, ty_a, mt_a), &ty::RawPtr(ty::TypeAndMut { mutbl: mt_b, .. })) => { coerce_mutbls(mt_a, mt_b)?; Some((Adjustment { @@ -562,7 +562,7 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> { ty::Predicate::Trait(ref tr) if traits.contains(&tr.def_id()) => { if unsize_did == tr.def_id() { let sty = &tr.skip_binder().input_types().nth(1).unwrap().sty; - if let ty::TyTuple(..) = sty { + if let ty::Tuple(..) = sty { debug!("coerce_unsized: found unsized tuple coercion"); has_unsized_tuple_coercion = true; } @@ -619,7 +619,7 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> { where F: FnOnce(Ty<'tcx>) -> Vec>, G: FnOnce(Ty<'tcx>) -> Vec> { - if let ty::TyFnPtr(fn_ty_b) = b.sty { + if let ty::FnPtr(fn_ty_b) = b.sty { match (fn_ty_a.unsafety(), fn_ty_b.unsafety()) { (hir::Unsafety::Normal, hir::Unsafety::Unsafe) => { let unsafe_a = self.tcx.safe_to_unsafe_fn_ty(fn_ty_a); @@ -659,7 +659,7 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> { debug!("coerce_from_fn_item(a={:?}, b={:?})", a, b); match b.sty { - ty::TyFnPtr(_) => { + ty::FnPtr(_) => { let a_sig = a.fn_sig(self.tcx); let InferOk { value: a_sig, mut obligations } = self.normalize_associated_types_in_as_infer_ok(self.cause.span, &a_sig); @@ -699,7 +699,7 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> { let node_id_a = self.tcx.hir.as_local_node_id(def_id_a).unwrap(); match b.sty { - ty::TyFnPtr(_) if self.tcx.with_freevars(node_id_a, |v| v.is_empty()) => { + ty::FnPtr(_) if self.tcx.with_freevars(node_id_a, |v| v.is_empty()) => { // We coerce the closure, which has fn type // `extern "rust-call" fn((arg0,arg1,...)) -> _` // to @@ -722,8 +722,8 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> { debug!("coerce_unsafe_ptr(a={:?}, b={:?})", a, b); let (is_ref, mt_a) = match a.sty { - ty::TyRef(_, ty, mutbl) => (true, ty::TypeAndMut { ty, mutbl }), - ty::TyRawPtr(mt) => (false, mt), + ty::Ref(_, ty, mutbl) => (true, ty::TypeAndMut { ty, mutbl }), + ty::RawPtr(mt) => (false, mt), _ => { return self.unify_and(a, b, identity); } @@ -811,7 +811,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // Special-case that coercion alone cannot handle: // Two function item types of differing IDs or Substs. - if let (&ty::TyFnDef(..), &ty::TyFnDef(..)) = (&prev_ty.sty, &new_ty.sty) { + if let (&ty::FnDef(..), &ty::FnDef(..)) = (&prev_ty.sty, &new_ty.sty) { // Don't reify if the function types have a LUB, i.e. they // are the same function and their parameters have a LUB. let lub_ty = self.commit_if_ok(|_| { @@ -881,7 +881,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(_, mutbl_adj)), .. } ] => { match self.node_ty(expr.hir_id).sty { - ty::TyRef(_, _, mt_orig) => { + ty::Ref(_, _, mt_orig) => { let mutbl_adj: hir::Mutability = mutbl_adj.into(); // Reborrow that we can safely ignore, because // the next adjustment can only be a Deref diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs index 00cc36ecd428c..7dc57c710bf26 100644 --- a/src/librustc_typeck/check/demand.rs +++ b/src/librustc_typeck/check/demand.rs @@ -114,7 +114,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // If the expected type is an enum with any variants whose sole // field is of the found type, suggest such variants. See Issue // #42764. - if let ty::TyAdt(expected_adt, substs) = expected.sty { + if let ty::Adt(expected_adt, substs) = expected.sty { let mut compatible_variants = vec![]; for variant in &expected_adt.variants { if variant.fields.len() == 1 { @@ -259,9 +259,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } match (&expected.sty, &checked_ty.sty) { - (&ty::TyRef(_, exp, _), &ty::TyRef(_, check, _)) => match (&exp.sty, &check.sty) { - (&ty::TyStr, &ty::TyArray(arr, _)) | - (&ty::TyStr, &ty::TySlice(arr)) if arr == self.tcx.types.u8 => { + (&ty::Ref(_, exp, _), &ty::Ref(_, check, _)) => match (&exp.sty, &check.sty) { + (&ty::Str, &ty::Array(arr, _)) | + (&ty::Str, &ty::Slice(arr)) if arr == self.tcx.types.u8 => { if let hir::ExprKind::Lit(_) = expr.node { if let Ok(src) = cm.span_to_snippet(sp) { if src.starts_with("b\"") { @@ -272,8 +272,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } } }, - (&ty::TyArray(arr, _), &ty::TyStr) | - (&ty::TySlice(arr), &ty::TyStr) if arr == self.tcx.types.u8 => { + (&ty::Array(arr, _), &ty::Str) | + (&ty::Slice(arr), &ty::Str) if arr == self.tcx.types.u8 => { if let hir::ExprKind::Lit(_) = expr.node { if let Ok(src) = cm.span_to_snippet(sp) { if src.starts_with("\"") { @@ -286,7 +286,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } _ => {} }, - (&ty::TyRef(_, _, mutability), _) => { + (&ty::Ref(_, _, mutability), _) => { // Check if it can work when put into a ref. For example: // // ``` @@ -325,7 +325,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } } } - (_, &ty::TyRef(_, checked, _)) => { + (_, &ty::Ref(_, checked, _)) => { // We have `&T`, check if what was expected was `T`. If so, // we may want to suggest adding a `*`, or removing // a `&`. @@ -418,7 +418,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if needs_paren { ")" } else { "" }); match (&expected_ty.sty, &checked_ty.sty) { - (&ty::TyInt(ref exp), &ty::TyInt(ref found)) => { + (&ty::Int(ref exp), &ty::Int(ref found)) => { match (found.bit_width(), exp.bit_width()) { (Some(found), Some(exp)) if found > exp => { if can_cast { @@ -444,7 +444,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } true } - (&ty::TyUint(ref exp), &ty::TyUint(ref found)) => { + (&ty::Uint(ref exp), &ty::Uint(ref found)) => { match (found.bit_width(), exp.bit_width()) { (Some(found), Some(exp)) if found > exp => { if can_cast { @@ -470,7 +470,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } true } - (&ty::TyInt(ref exp), &ty::TyUint(ref found)) => { + (&ty::Int(ref exp), &ty::Uint(ref found)) => { if can_cast { match (found.bit_width(), exp.bit_width()) { (Some(found), Some(exp)) if found > exp - 1 => { @@ -506,7 +506,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } true } - (&ty::TyUint(ref exp), &ty::TyInt(ref found)) => { + (&ty::Uint(ref exp), &ty::Int(ref found)) => { if can_cast { match (found.bit_width(), exp.bit_width()) { (Some(found), Some(exp)) if found - 1 > exp => { @@ -542,7 +542,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } true } - (&ty::TyFloat(ref exp), &ty::TyFloat(ref found)) => { + (&ty::Float(ref exp), &ty::Float(ref found)) => { if found.bit_width() < exp.bit_width() { err.span_suggestion(expr.span, &format!("{} in a lossless way", @@ -556,7 +556,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } true } - (&ty::TyUint(_), &ty::TyFloat(_)) | (&ty::TyInt(_), &ty::TyFloat(_)) => { + (&ty::Uint(_), &ty::Float(_)) | (&ty::Int(_), &ty::Float(_)) => { if can_cast { err.span_suggestion(expr.span, &format!("{}, rounding the float towards zero", @@ -568,7 +568,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } true } - (&ty::TyFloat(ref exp), &ty::TyUint(ref found)) => { + (&ty::Float(ref exp), &ty::Uint(ref found)) => { // if `found` is `None` (meaning found is `usize`), don't suggest `.into()` if exp.bit_width() > found.bit_width().unwrap_or(256) { err.span_suggestion(expr.span, @@ -586,7 +586,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } true } - (&ty::TyFloat(ref exp), &ty::TyInt(ref found)) => { + (&ty::Float(ref exp), &ty::Int(ref found)) => { // if `found` is `None` (meaning found is `isize`), don't suggest `.into()` if exp.bit_width() > found.bit_width().unwrap_or(256) { err.span_suggestion(expr.span, diff --git a/src/librustc_typeck/check/dropck.rs b/src/librustc_typeck/check/dropck.rs index f9166851f6fcc..9d3cbf910e059 100644 --- a/src/librustc_typeck/check/dropck.rs +++ b/src/librustc_typeck/check/dropck.rs @@ -45,7 +45,7 @@ pub fn check_drop_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let dtor_self_type = tcx.type_of(drop_impl_did); let dtor_predicates = tcx.predicates_of(drop_impl_did); match dtor_self_type.sty { - ty::TyAdt(adt_def, self_to_impl_substs) => { + ty::Adt(adt_def, self_to_impl_substs) => { ensure_drop_params_and_item_params_correspond(tcx, drop_impl_did, dtor_self_type, diff --git a/src/librustc_typeck/check/intrinsic.rs b/src/librustc_typeck/check/intrinsic.rs index af4356dc8de78..23872ddf2f64b 100644 --- a/src/librustc_typeck/check/intrinsic.rs +++ b/src/librustc_typeck/check/intrinsic.rs @@ -463,35 +463,35 @@ fn match_intrinsic_type_to_type<'a, 'tcx>( match *expected { Void => match t.sty { - ty::TyTuple(ref v) if v.is_empty() => {}, + ty::Tuple(ref v) if v.is_empty() => {}, _ => simple_error(&format!("`{}`", t), "()"), }, // (The width we pass to LLVM doesn't concern the type checker.) Integer(signed, bits, _llvm_width) => match (signed, bits, &t.sty) { - (true, 8, &ty::TyInt(ast::IntTy::I8)) | - (false, 8, &ty::TyUint(ast::UintTy::U8)) | - (true, 16, &ty::TyInt(ast::IntTy::I16)) | - (false, 16, &ty::TyUint(ast::UintTy::U16)) | - (true, 32, &ty::TyInt(ast::IntTy::I32)) | - (false, 32, &ty::TyUint(ast::UintTy::U32)) | - (true, 64, &ty::TyInt(ast::IntTy::I64)) | - (false, 64, &ty::TyUint(ast::UintTy::U64)) | - (true, 128, &ty::TyInt(ast::IntTy::I128)) | - (false, 128, &ty::TyUint(ast::UintTy::U128)) => {}, + (true, 8, &ty::Int(ast::IntTy::I8)) | + (false, 8, &ty::Uint(ast::UintTy::U8)) | + (true, 16, &ty::Int(ast::IntTy::I16)) | + (false, 16, &ty::Uint(ast::UintTy::U16)) | + (true, 32, &ty::Int(ast::IntTy::I32)) | + (false, 32, &ty::Uint(ast::UintTy::U32)) | + (true, 64, &ty::Int(ast::IntTy::I64)) | + (false, 64, &ty::Uint(ast::UintTy::U64)) | + (true, 128, &ty::Int(ast::IntTy::I128)) | + (false, 128, &ty::Uint(ast::UintTy::U128)) => {}, _ => simple_error(&format!("`{}`", t), &format!("`{}{n}`", if signed {"i"} else {"u"}, n = bits)), }, Float(bits) => match (bits, &t.sty) { - (32, &ty::TyFloat(ast::FloatTy::F32)) | - (64, &ty::TyFloat(ast::FloatTy::F64)) => {}, + (32, &ty::Float(ast::FloatTy::F32)) | + (64, &ty::Float(ast::FloatTy::F64)) => {}, _ => simple_error(&format!("`{}`", t), &format!("`f{n}`", n = bits)), }, Pointer(ref inner_expected, ref _llvm_type, const_) => { match t.sty { - ty::TyRawPtr(ty::TypeAndMut { ty, mutbl }) => { + ty::RawPtr(ty::TypeAndMut { ty, mutbl }) => { if (mutbl == hir::MutImmutable) != const_ { simple_error(&format!("`{}`", t), if const_ {"const pointer"} else {"mut pointer"}) @@ -537,7 +537,7 @@ fn match_intrinsic_type_to_type<'a, 'tcx>( } Aggregate(_flatten, ref expected_contents) => { match t.sty { - ty::TyTuple(contents) => { + ty::Tuple(contents) => { if contents.len() != expected_contents.len() { simple_error(&format!("tuple with length {}", contents.len()), &format!("tuple with length {}", expected_contents.len())); diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs index fbb49c95edf03..6057c18663a6e 100644 --- a/src/librustc_typeck/check/method/confirm.rs +++ b/src/librustc_typeck/check/method/confirm.rs @@ -293,7 +293,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> { .include_raw_pointers() .filter_map(|(ty, _)| { match ty.sty { - ty::TyDynamic(ref data, ..) => data.principal().map(|p| closure(self, ty, p)), + ty::Dynamic(ref data, ..) => data.principal().map(|p| closure(self, ty, p)), _ => None, } }) @@ -479,7 +479,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> { if let Adjust::Deref(Some(ref mut deref)) = adjustment.kind { if let Some(ok) = self.try_overloaded_deref(expr.span, source, needs) { let method = self.register_infer_ok_obligations(ok); - if let ty::TyRef(region, _, mutbl) = method.sig.output().sty { + if let ty::Ref(region, _, mutbl) = method.sig.output().sty { *deref = OverloadedDeref { region, mutbl, @@ -538,7 +538,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> { debug!("convert_place_op_to_mutable: method={:?}", method); self.write_method_call(expr.hir_id, method); - let (region, mutbl) = if let ty::TyRef(r, _, mutbl) = method.sig.inputs()[0].sty { + let (region, mutbl) = if let ty::Ref(r, _, mutbl) = method.sig.inputs()[0].sty { (r, mutbl) } else { span_bug!(expr.span, "input to place op is not a ref?"); @@ -605,7 +605,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> { }) .any(|trait_pred| { match trait_pred.skip_binder().self_ty().sty { - ty::TyDynamic(..) => true, + ty::Dynamic(..) => true, _ => false, } }) diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index 68e851446dc96..85a437283fa68 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -314,7 +314,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { from_unsafe_deref: reached_raw_pointer, unsize: false, }; - if let ty::TyRawPtr(_) = ty.sty { + if let ty::RawPtr(_) = ty.sty { // all the subsequent steps will be from_unsafe_deref reached_raw_pointer = true; } @@ -324,7 +324,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let final_ty = autoderef.maybe_ambiguous_final_ty(); match final_ty.sty { - ty::TyInfer(ty::TyVar(_)) => { + ty::Infer(ty::TyVar(_)) => { // Ended in an inference variable. If we are doing // a real method lookup, this is a hard error because it's // possible that there will be multiple applicable methods. @@ -356,7 +356,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // just ignore it. } } - ty::TyArray(elem_ty, _) => { + ty::Array(elem_ty, _) => { let dereferences = steps.len() - 1; steps.push(CandidateStep { @@ -368,7 +368,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { unsize: true, }); } - ty::TyError => return None, + ty::Error => return None, _ => (), } @@ -450,33 +450,33 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { let lang_items = self.tcx.lang_items(); match self_ty.sty { - ty::TyDynamic(ref data, ..) => { + ty::Dynamic(ref data, ..) => { if let Some(p) = data.principal() { self.assemble_inherent_candidates_from_object(self_ty, p); self.assemble_inherent_impl_candidates_for_type(p.def_id()); } } - ty::TyAdt(def, _) => { + ty::Adt(def, _) => { self.assemble_inherent_impl_candidates_for_type(def.did); } - ty::TyForeign(did) => { + ty::Foreign(did) => { self.assemble_inherent_impl_candidates_for_type(did); } - ty::TyParam(p) => { + ty::Param(p) => { self.assemble_inherent_candidates_from_param(self_ty, p); } - ty::TyChar => { + ty::Char => { let lang_def_id = lang_items.char_impl(); self.assemble_inherent_impl_for_primitive(lang_def_id); } - ty::TyStr => { + ty::Str => { let lang_def_id = lang_items.str_impl(); self.assemble_inherent_impl_for_primitive(lang_def_id); let lang_def_id = lang_items.str_alloc_impl(); self.assemble_inherent_impl_for_primitive(lang_def_id); } - ty::TySlice(_) => { + ty::Slice(_) => { let lang_def_id = lang_items.slice_impl(); self.assemble_inherent_impl_for_primitive(lang_def_id); @@ -489,70 +489,70 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { let lang_def_id = lang_items.slice_u8_alloc_impl(); self.assemble_inherent_impl_for_primitive(lang_def_id); } - ty::TyRawPtr(ty::TypeAndMut { ty: _, mutbl: hir::MutImmutable }) => { + ty::RawPtr(ty::TypeAndMut { ty: _, mutbl: hir::MutImmutable }) => { let lang_def_id = lang_items.const_ptr_impl(); self.assemble_inherent_impl_for_primitive(lang_def_id); } - ty::TyRawPtr(ty::TypeAndMut { ty: _, mutbl: hir::MutMutable }) => { + ty::RawPtr(ty::TypeAndMut { ty: _, mutbl: hir::MutMutable }) => { let lang_def_id = lang_items.mut_ptr_impl(); self.assemble_inherent_impl_for_primitive(lang_def_id); } - ty::TyInt(ast::IntTy::I8) => { + ty::Int(ast::IntTy::I8) => { let lang_def_id = lang_items.i8_impl(); self.assemble_inherent_impl_for_primitive(lang_def_id); } - ty::TyInt(ast::IntTy::I16) => { + ty::Int(ast::IntTy::I16) => { let lang_def_id = lang_items.i16_impl(); self.assemble_inherent_impl_for_primitive(lang_def_id); } - ty::TyInt(ast::IntTy::I32) => { + ty::Int(ast::IntTy::I32) => { let lang_def_id = lang_items.i32_impl(); self.assemble_inherent_impl_for_primitive(lang_def_id); } - ty::TyInt(ast::IntTy::I64) => { + ty::Int(ast::IntTy::I64) => { let lang_def_id = lang_items.i64_impl(); self.assemble_inherent_impl_for_primitive(lang_def_id); } - ty::TyInt(ast::IntTy::I128) => { + ty::Int(ast::IntTy::I128) => { let lang_def_id = lang_items.i128_impl(); self.assemble_inherent_impl_for_primitive(lang_def_id); } - ty::TyInt(ast::IntTy::Isize) => { + ty::Int(ast::IntTy::Isize) => { let lang_def_id = lang_items.isize_impl(); self.assemble_inherent_impl_for_primitive(lang_def_id); } - ty::TyUint(ast::UintTy::U8) => { + ty::Uint(ast::UintTy::U8) => { let lang_def_id = lang_items.u8_impl(); self.assemble_inherent_impl_for_primitive(lang_def_id); } - ty::TyUint(ast::UintTy::U16) => { + ty::Uint(ast::UintTy::U16) => { let lang_def_id = lang_items.u16_impl(); self.assemble_inherent_impl_for_primitive(lang_def_id); } - ty::TyUint(ast::UintTy::U32) => { + ty::Uint(ast::UintTy::U32) => { let lang_def_id = lang_items.u32_impl(); self.assemble_inherent_impl_for_primitive(lang_def_id); } - ty::TyUint(ast::UintTy::U64) => { + ty::Uint(ast::UintTy::U64) => { let lang_def_id = lang_items.u64_impl(); self.assemble_inherent_impl_for_primitive(lang_def_id); } - ty::TyUint(ast::UintTy::U128) => { + ty::Uint(ast::UintTy::U128) => { let lang_def_id = lang_items.u128_impl(); self.assemble_inherent_impl_for_primitive(lang_def_id); } - ty::TyUint(ast::UintTy::Usize) => { + ty::Uint(ast::UintTy::Usize) => { let lang_def_id = lang_items.usize_impl(); self.assemble_inherent_impl_for_primitive(lang_def_id); } - ty::TyFloat(ast::FloatTy::F32) => { + ty::Float(ast::FloatTy::F32) => { let lang_def_id = lang_items.f32_impl(); self.assemble_inherent_impl_for_primitive(lang_def_id); let lang_def_id = lang_items.f32_runtime_impl(); self.assemble_inherent_impl_for_primitive(lang_def_id); } - ty::TyFloat(ast::FloatTy::F64) => { + ty::Float(ast::FloatTy::F64) => { let lang_def_id = lang_items.f64_impl(); self.assemble_inherent_impl_for_primitive(lang_def_id); @@ -652,7 +652,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { match *predicate { ty::Predicate::Trait(ref trait_predicate) => { match trait_predicate.skip_binder().trait_ref.self_ty().sty { - ty::TyParam(ref p) if *p == param_ty => { + ty::Param(ref p) if *p == param_ty => { Some(trait_predicate.to_poly_trait_ref()) } _ => None, @@ -919,7 +919,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { pick.autoderefs = step.autoderefs; // Insert a `&*` or `&mut *` if this is a reference type: - if let ty::TyRef(_, _, mutbl) = step.self_ty.sty { + if let ty::Ref(_, _, mutbl) = step.self_ty.sty { pick.autoderefs += 1; pick.autoref = Some(mutbl); } diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index 31ec62ba70a95..0bef176b499a4 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -32,7 +32,7 @@ use rustc::hir::def_id::LOCAL_CRATE; use rustc::hir; use rustc::hir::print; use rustc::infer::type_variable::TypeVariableOrigin; -use rustc::ty::TyAdt; +use rustc::ty::Adt; use std::cmp::Ordering; @@ -45,9 +45,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { match ty.sty { // Not all of these (e.g. unsafe fns) implement FnOnce // so we look for these beforehand - ty::TyClosure(..) | - ty::TyFnDef(..) | - ty::TyFnPtr(_) => true, + ty::Closure(..) | + ty::FnDef(..) | + ty::FnPtr(_) => true, // If it's not a simple function, look for things which implement FnOnce _ => { let fn_once = match tcx.lang_items().require(FnOnceTraitLangItem) { @@ -199,7 +199,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let item_kind = if is_method { "method" } else if actual.is_enum() { - if let TyAdt(ref adt_def, _) = actual.sty { + if let Adt(ref adt_def, _) = actual.sty { let names = adt_def.variants.iter().map(|s| &s.name); suggestion = find_best_match_for_name(names, &item_name.as_str(), @@ -338,7 +338,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if let Some(expr) = rcvr_expr { for (ty, _) in self.autoderef(span, rcvr_ty) { match ty.sty { - ty::TyAdt(def, substs) if !def.is_enum() => { + ty::Adt(def, substs) if !def.is_enum() => { let variant = &def.non_enum_variant(); if let Some(index) = self.tcx.find_field_index(item_name, variant) { let field = &variant.fields[index]; @@ -638,13 +638,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { -> bool { fn is_local(ty: Ty) -> bool { match ty.sty { - ty::TyAdt(def, _) => def.did.is_local(), - ty::TyForeign(did) => did.is_local(), + ty::Adt(def, _) => def.did.is_local(), + ty::Foreign(did) => did.is_local(), - ty::TyDynamic(ref tr, ..) => tr.principal() + ty::Dynamic(ref tr, ..) => tr.principal() .map_or(false, |p| p.def_id().is_local()), - ty::TyParam(_) => true, + ty::Param(_) => true, // everything else (primitive types etc.) is effectively // non-local (there are "edge" cases, e.g. (LocalType,), but diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 010ca1f7ab475..0dcc799ebb2e2 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -214,7 +214,7 @@ pub struct Inherited<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { // Anonymized types found in explicit return types and their // associated fresh inference variable. Writeback resolves these // variables to get the concrete type, which can be used to - // deanonymize TyAnon, after typeck is done with all functions. + // deanonymize Anon, after typeck is done with all functions. anon_types: RefCell>>, /// Each type parameter has an implicit region bound that @@ -311,7 +311,7 @@ impl<'a, 'gcx, 'tcx> Expectation<'tcx> { /// for examples of where this comes up,. fn rvalue_hint(fcx: &FnCtxt<'a, 'gcx, 'tcx>, ty: Ty<'tcx>) -> Expectation<'tcx> { match fcx.tcx.struct_tail(ty).sty { - ty::TySlice(_) | ty::TyStr | ty::TyDynamic(..) => { + ty::Slice(_) | ty::Str | ty::Dynamic(..) => { ExpectRvalueLikeUnsized(ty) } _ => ExpectHasType(ty) @@ -1137,7 +1137,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>, if let Some(panic_impl_did) = fcx.tcx.lang_items().panic_impl() { if panic_impl_did == fcx.tcx.hir.local_def_id(fn_id) { if let Some(panic_info_did) = fcx.tcx.lang_items().panic_info() { - if declared_ret_ty.sty != ty::TyNever { + if declared_ret_ty.sty != ty::Never { fcx.tcx.sess.span_err( decl.output.span(), "return type should be `!`", @@ -1148,8 +1148,8 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>, let span = fcx.tcx.hir.span(fn_id); if inputs.len() == 1 { let arg_is_panic_info = match inputs[0].sty { - ty::TyRef(region, ty, mutbl) => match ty.sty { - ty::TyAdt(ref adt, _) => { + ty::Ref(region, ty, mutbl) => match ty.sty { + ty::Adt(ref adt, _) => { adt.did == panic_info_did && mutbl == hir::Mutability::MutImmutable && *region != RegionKind::ReStatic @@ -1190,7 +1190,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>, if let Some(alloc_error_handler_did) = fcx.tcx.lang_items().oom() { if alloc_error_handler_did == fcx.tcx.hir.local_def_id(fn_id) { if let Some(alloc_layout_did) = fcx.tcx.lang_items().alloc_layout() { - if declared_ret_ty.sty != ty::TyNever { + if declared_ret_ty.sty != ty::Never { fcx.tcx.sess.span_err( decl.output.span(), "return type should be `!`", @@ -1201,7 +1201,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>, let span = fcx.tcx.hir.span(fn_id); if inputs.len() == 1 { let arg_is_alloc_layout = match inputs[0].sty { - ty::TyAdt(ref adt, _) => { + ty::Adt(ref adt, _) => { adt.did == alloc_layout_did }, _ => false, @@ -1633,7 +1633,7 @@ fn check_representable<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, pub fn check_simd<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sp: Span, def_id: DefId) { let t = tcx.type_of(def_id); match t.sty { - ty::TyAdt(def, substs) if def.is_struct() => { + ty::Adt(def, substs) if def.is_struct() => { let fields = &def.non_enum_variant().fields; if fields.is_empty() { span_err!(tcx.sess, sp, E0075, "SIMD vector cannot be empty"); @@ -1647,7 +1647,7 @@ pub fn check_simd<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sp: Span, def_id: DefId return; } match e.sty { - ty::TyParam(_) => { /* struct(T, T, T, T) is ok */ } + ty::Param(_) => { /* struct(T, T, T, T) is ok */ } _ if e.is_machine() => { /* struct(u8, u8, u8, u8) is ok */ } _ => { span_err!(tcx.sess, sp, E0077, @@ -1693,7 +1693,7 @@ fn check_packed_inner<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, return false; } match t.sty { - ty::TyAdt(def, substs) if def.is_struct() || def.is_union() => { + ty::Adt(def, substs) if def.is_struct() || def.is_union() => { if tcx.adt_def(def.did).repr.align > 0 { return true; } @@ -1702,7 +1702,7 @@ fn check_packed_inner<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, for field in &def.non_enum_variant().fields { let f = field.ty(tcx, substs); match f.sty { - ty::TyAdt(def, _) => { + ty::Adt(def, _) => { if check_packed_inner(tcx, def.did, stack) { return true; } @@ -1982,7 +1982,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { fn resolve_type_vars_with_obligations(&self, mut ty: Ty<'tcx>) -> Ty<'tcx> { debug!("resolve_type_vars_with_obligations(ty={:?})", ty); - // No TyInfer()? Nothing needs doing. + // No Infer()? Nothing needs doing. if !ty.has_infer_types() { debug!("resolve_type_vars_with_obligations: ty={:?}", ty); return ty; @@ -2331,7 +2331,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // feature(never_type) is enabled, unconstrained ints with i32, // unconstrained floats with f64. // Fallback becomes very dubious if we have encountered type-checking errors. - // In that case, fallback to TyError. + // In that case, fallback to Error. // The return value indicates whether fallback has occurred. fn fallback_if_possible(&self, ty: Ty<'tcx>) -> bool { use rustc::ty::error::UnconstrainedNumeric::Neither; @@ -2481,7 +2481,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let mut self_ty = adjusted_ty; if unsize { // We only unsize arrays here. - if let ty::TyArray(element_ty, _) = adjusted_ty.sty { + if let ty::Array(element_ty, _) = adjusted_ty.sty { self_ty = self.tcx.mk_slice(element_ty); } else { continue; @@ -2500,7 +2500,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let method = self.register_infer_ok_obligations(ok); let mut adjustments = autoderef.adjust_steps(needs); - if let ty::TyRef(region, _, r_mutbl) = method.sig.inputs()[0].sty { + if let ty::Ref(region, _, r_mutbl) = method.sig.inputs()[0].sty { let mutbl = match r_mutbl { hir::MutImmutable => AutoBorrowMutability::Immutable, hir::MutMutable => AutoBorrowMutability::Mutable { @@ -2694,15 +2694,15 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let formal_tys = if tuple_arguments == TupleArguments { let tuple_type = self.structurally_resolved_type(sp, fn_inputs[0]); match tuple_type.sty { - ty::TyTuple(arg_types) if arg_types.len() != args.len() => { + ty::Tuple(arg_types) if arg_types.len() != args.len() => { param_count_error(arg_types.len(), args.len(), "E0057", false, false); expected_arg_tys = &[]; self.err_args(args.len()) } - ty::TyTuple(arg_types) => { + ty::Tuple(arg_types) => { expected_arg_tys = match expected_arg_tys.get(0) { Some(&ty) => match ty.sty { - ty::TyTuple(ref tys) => &tys, + ty::Tuple(ref tys) => &tys, _ => &[] }, None => &[] @@ -2831,16 +2831,16 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // in C but we just error out instead and require explicit casts. let arg_ty = self.structurally_resolved_type(arg.span, arg_ty); match arg_ty.sty { - ty::TyFloat(ast::FloatTy::F32) => { + ty::Float(ast::FloatTy::F32) => { variadic_error(tcx.sess, arg.span, arg_ty, "c_double"); } - ty::TyInt(ast::IntTy::I8) | ty::TyInt(ast::IntTy::I16) | ty::TyBool => { + ty::Int(ast::IntTy::I8) | ty::Int(ast::IntTy::I16) | ty::Bool => { variadic_error(tcx.sess, arg.span, arg_ty, "c_int"); } - ty::TyUint(ast::UintTy::U8) | ty::TyUint(ast::UintTy::U16) => { + ty::Uint(ast::UintTy::U8) | ty::Uint(ast::UintTy::U16) => { variadic_error(tcx.sess, arg.span, arg_ty, "c_uint"); } - ty::TyFnDef(..) => { + ty::FnDef(..) => { let ptr_ty = self.tcx.mk_fn_ptr(arg_ty.fn_sig(self.tcx)); let ptr_ty = self.resolve_type_vars_if_possible(&ptr_ty); variadic_error(tcx.sess, arg.span, arg_ty, &ptr_ty.to_string()); @@ -2876,10 +2876,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { ast::LitKind::Int(_, ast::LitIntType::Unsuffixed) => { let opt_ty = expected.to_option(self).and_then(|ty| { match ty.sty { - ty::TyInt(_) | ty::TyUint(_) => Some(ty), - ty::TyChar => Some(tcx.types.u8), - ty::TyRawPtr(..) => Some(tcx.types.usize), - ty::TyFnDef(..) | ty::TyFnPtr(_) => Some(tcx.types.usize), + ty::Int(_) | ty::Uint(_) => Some(ty), + ty::Char => Some(tcx.types.u8), + ty::RawPtr(..) => Some(tcx.types.usize), + ty::FnDef(..) | ty::FnPtr(_) => Some(tcx.types.usize), _ => None } }); @@ -2890,7 +2890,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { ast::LitKind::FloatUnsuffixed(_) => { let opt_ty = expected.to_option(self).and_then(|ty| { match ty.sty { - ty::TyFloat(_) => Some(ty), + ty::Float(_) => Some(ty), _ => None } }); @@ -3179,7 +3179,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let mut autoderef = self.autoderef(expr.span, expr_t); while let Some((base_t, _)) = autoderef.next() { match base_t.sty { - ty::TyAdt(base_def, substs) if !base_def.is_enum() => { + ty::Adt(base_def, substs) if !base_def.is_enum() => { debug!("struct named {:?}", base_t); let (ident, def_scope) = self.tcx.adjust_ident(field, base_def.did, self.body_id); @@ -3201,7 +3201,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { private_candidate = Some((base_def.did, field_ty)); } } - ty::TyTuple(ref tys) => { + ty::Tuple(ref tys) => { let fstr = field.as_str(); if let Ok(index) = fstr.parse::() { if fstr == index.to_string() { @@ -3246,7 +3246,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let mut err = self.no_such_field_err(field.span, field, expr_t); match expr_t.sty { - ty::TyAdt(def, _) if !def.is_enum() => { + ty::Adt(def, _) if !def.is_enum() => { if let Some(suggested_field_name) = Self::suggest_field_name(def.non_enum_variant(), &field.as_str(), vec![]) { @@ -3262,7 +3262,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } }; } - ty::TyRawPtr(..) => { + ty::RawPtr(..) => { let base = self.tcx.hir.node_to_pretty_string(base.id); let msg = format!("`{}` is a native pointer; try dereferencing it", base); let suggestion = format!("(*{}).{}", base, field); @@ -3336,7 +3336,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let mut err = self.type_error_struct_with_diag( field.ident.span, |actual| match ty.sty { - ty::TyAdt(adt, ..) if adt.is_enum() => { + ty::Adt(adt, ..) if adt.is_enum() => { struct_span_err!(self.tcx.sess, field.ident.span, E0559, "{} `{}::{}` has no field named `{}`", kind_name, actual, variant.name, field.ident) @@ -3357,7 +3357,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { format!("field does not exist - did you mean `{}`?", field_name)); } else { match ty.sty { - ty::TyAdt(adt, ..) => { + ty::Adt(adt, ..) => { if adt.is_enum() { err.span_label(field.ident.span, format!("`{}::{}` does not have this field", @@ -3395,7 +3395,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { self.demand_eqtype(span, adt_ty_hint, adt_ty); let (substs, adt_kind, kind_name) = match &adt_ty.sty{ - &ty::TyAdt(adt, substs) => { + &ty::Adt(adt, substs) => { (substs, adt.adt_kind(), adt.variant_descr()) } _ => span_bug!(span, "non-ADT passed to check_expr_struct_fields") @@ -3520,7 +3520,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } Def::Variant(..) => { match ty.sty { - ty::TyAdt(adt, substs) => { + ty::Adt(adt, substs) => { Some((adt.variant_of_def(def), adt.did, substs)) } _ => bug!("unexpected type: {:?}", ty.sty) @@ -3529,7 +3529,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { Def::Struct(..) | Def::Union(..) | Def::TyAlias(..) | Def::AssociatedTy(..) | Def::SelfTy(..) => { match ty.sty { - ty::TyAdt(adt, substs) if !adt.is_enum() => { + ty::Adt(adt, substs) if !adt.is_enum() => { Some((adt.non_enum_variant(), adt.did, substs)) } _ => None, @@ -3578,7 +3578,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { }; // Prohibit struct expressions when non exhaustive flag is set. - if let ty::TyAdt(adt, _) = struct_ty.sty { + if let ty::Adt(adt, _) = struct_ty.sty { if !adt.did.is_local() && adt.is_non_exhaustive() { span_err!(self.tcx.sess, expr.span, E0639, "cannot create non-exhaustive {} using struct expression", @@ -3595,7 +3595,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if !error_happened { self.check_expr_has_type_or_error(base_expr, struct_ty); match struct_ty.sty { - ty::TyAdt(adt, substs) if adt.is_struct() => { + ty::Adt(adt, substs) if adt.is_struct() => { let fru_field_types = adt.non_enum_variant().fields.iter().map(|f| { self.normalize_associated_types_in(expr.span, &f.ty(self.tcx, substs)) }).collect(); @@ -3625,7 +3625,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { /// strict, _|_ can appear in the type of an expression that does not, /// itself, diverge: for example, fn() -> _|_.) /// Note that inspecting a type's structure *directly* may expose the fact - /// that there are actually multiple representations for `TyError`, so avoid + /// that there are actually multiple representations for `Error`, so avoid /// that when err needs to be handled differently. fn check_expr_with_expectation_and_needs(&self, expr: &'gcx hir::Expr, @@ -3684,7 +3684,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { hir::ExprKind::Box(ref subexpr) => { let expected_inner = expected.to_option(self).map_or(NoExpectation, |ty| { match ty.sty { - ty::TyAdt(def, _) if def.is_box() + ty::Adt(def, _) if def.is_box() => Expectation::rvalue_hint(self, ty.boxed_ty()), _ => NoExpectation } @@ -3728,7 +3728,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } else if let Some(ok) = self.try_overloaded_deref( expr.span, oprnd_t, needs) { let method = self.register_infer_ok_obligations(ok); - if let ty::TyRef(region, _, mutbl) = method.sig.inputs()[0].sty { + if let ty::Ref(region, _, mutbl) = method.sig.inputs()[0].sty { let mutbl = match mutbl { hir::MutImmutable => AutoBorrowMutability::Immutable, hir::MutMutable => AutoBorrowMutability::Mutable { @@ -3755,7 +3755,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { hir::UnNot => { let result = self.check_user_unop(expr, oprnd_t, unop); // If it's builtin, we can reuse the type, this helps inference. - if !(oprnd_t.is_integral() || oprnd_t.sty == ty::TyBool) { + if !(oprnd_t.is_integral() || oprnd_t.sty == ty::Bool) { oprnd_t = result; } } @@ -3773,7 +3773,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { hir::ExprKind::AddrOf(mutbl, ref oprnd) => { let hint = expected.only_has_type(self).map_or(NoExpectation, |ty| { match ty.sty { - ty::TyRef(_, ty, _) | ty::TyRawPtr(ty::TypeAndMut { ty, .. }) => { + ty::Ref(_, ty, _) | ty::RawPtr(ty::TypeAndMut { ty, .. }) => { if self.is_place_expr(&oprnd) { // Places may legitimately have unsized types. // For example, dereferences of a fat pointer and @@ -4086,7 +4086,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { hir::ExprKind::Array(ref args) => { let uty = expected.to_option(self).and_then(|uty| { match uty.sty { - ty::TyArray(ty, _) | ty::TySlice(ty) => Some(ty), + ty::Array(ty, _) | ty::Slice(ty) => Some(ty), _ => None } }); @@ -4133,7 +4133,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let uty = match expected { ExpectHasType(uty) => { match uty.sty { - ty::TyArray(ty, _) | ty::TySlice(ty) => Some(ty), + ty::Array(ty, _) | ty::Slice(ty) => Some(ty), _ => None } } @@ -4165,7 +4165,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if element_ty.references_error() { tcx.types.err } else if let Ok(count) = count { - tcx.mk_ty(ty::TyArray(t, count)) + tcx.mk_ty(ty::Array(t, count)) } else { tcx.types.err } @@ -4174,7 +4174,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let flds = expected.only_has_type(self).and_then(|ty| { let ty = self.resolve_type_vars_with_obligations(ty); match ty.sty { - ty::TyTuple(ref flds) => Some(&flds[..]), + ty::Tuple(ref flds) => Some(&flds[..]), _ => None } }); @@ -4228,7 +4228,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { "cannot index into a value of type `{}`", base_t); // Try to give some advice about indexing tuples. - if let ty::TyTuple(..) = base_t.sty { + if let ty::Tuple(..) = base_t.sty { let mut needs_note = true; // If the index is an integer, we can show the actual // fixed expression: @@ -5020,7 +5020,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // If no type arguments were provided, we have to infer them. // This case also occurs as a result of some malformed input, e.g. // a lifetime argument being given instead of a type paramter. - // Using inference instead of `TyError` gives better error messages. + // Using inference instead of `Error` gives better error messages. self.var_for_def(span, param) } } @@ -5155,10 +5155,10 @@ pub fn check_bounds_are_used<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let mut types_used = vec![false; own_counts.types]; for leaf_ty in ty.walk() { - if let ty::TyParam(ty::ParamTy { idx, .. }) = leaf_ty.sty { + if let ty::Param(ty::ParamTy { idx, .. }) = leaf_ty.sty { debug!("Found use of ty param num {}", idx); types_used[idx as usize - own_counts.lifetimes] = true; - } else if let ty::TyError = leaf_ty.sty { + } else if let ty::Error = leaf_ty.sty { // If there is already another error, do not emit // an error for not using a type Parameter. assert!(tcx.sess.err_count() > 0); diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs index de211d2209c9a..b7cf6819e2180 100644 --- a/src/librustc_typeck/check/op.rs +++ b/src/librustc_typeck/check/op.rs @@ -13,7 +13,7 @@ use super::{FnCtxt, Needs}; use super::method::MethodCallee; use rustc::ty::{self, Ty, TypeFoldable}; -use rustc::ty::TypeVariants::{TyRef, TyAdt, TyStr, TyUint, TyNever, TyTuple, TyChar, TyArray}; +use rustc::ty::TyKind::{Ref, Adt, Str, Uint, Never, Tuple, Char, Array}; use rustc::ty::adjustment::{Adjustment, Adjust, AllowTwoPhase, AutoBorrow, AutoBorrowMutability}; use rustc::infer::type_variable::TypeVariableOrigin; use errors; @@ -204,7 +204,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { Ok(method) => { let by_ref_binop = !op.node.is_by_value(); if is_assign == IsAssign::Yes || by_ref_binop { - if let ty::TyRef(region, _, mutbl) = method.sig.inputs()[0].sty { + if let ty::Ref(region, _, mutbl) = method.sig.inputs()[0].sty { let mutbl = match mutbl { hir::MutImmutable => AutoBorrowMutability::Immutable, hir::MutMutable => AutoBorrowMutability::Mutable { @@ -221,7 +221,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } } if by_ref_binop { - if let ty::TyRef(region, _, mutbl) = method.sig.inputs()[1].sty { + if let ty::Ref(region, _, mutbl) = method.sig.inputs()[1].sty { let mutbl = match mutbl { hir::MutImmutable => AutoBorrowMutability::Immutable, hir::MutMutable => AutoBorrowMutability::Mutable { @@ -265,7 +265,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { format!("cannot use `{}=` on type `{}`", op.node.as_str(), lhs_ty)); let mut suggested_deref = false; - if let TyRef(_, mut rty, _) = lhs_ty.sty { + if let Ref(_, mut rty, _) = lhs_ty.sty { if { !self.infcx.type_moves_by_default(self.param_env, rty, @@ -276,7 +276,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { .is_ok() } { if let Ok(lstring) = source_map.span_to_snippet(lhs_expr.span) { - while let TyRef(_, rty_inner, _) = rty.sty { + while let Ref(_, rty_inner, _) = rty.sty { rty = rty_inner; } let msg = &format!( @@ -311,7 +311,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // This has nothing here because it means we did string // concatenation (e.g. "Hello " += "World!"). This means // we don't want the note in the else clause to be emitted - } else if let ty::TyParam(_) = lhs_ty.sty { + } else if let ty::Param(_) = lhs_ty.sty { // FIXME: point to span of param err.note(&format!( "`{}` might need a bound for `{}`", @@ -333,7 +333,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { op.node.as_str(), lhs_ty); let mut suggested_deref = false; - if let TyRef(_, mut rty, _) = lhs_ty.sty { + if let Ref(_, mut rty, _) = lhs_ty.sty { if { !self.infcx.type_moves_by_default(self.param_env, rty, @@ -344,7 +344,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { .is_ok() } { if let Ok(lstring) = source_map.span_to_snippet(lhs_expr.span) { - while let TyRef(_, rty_inner, _) = rty.sty { + while let Ref(_, rty_inner, _) = rty.sty { rty = rty_inner; } let msg = &format!( @@ -385,7 +385,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // This has nothing here because it means we did string // concatenation (e.g. "Hello " + "World!"). This means // we don't want the note in the else clause to be emitted - } else if let ty::TyParam(_) = lhs_ty.sty { + } else if let ty::Param(_) = lhs_ty.sty { // FIXME: point to span of param err.note(&format!( "`{}` might need a bound for `{}`", @@ -429,8 +429,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // If this function returns true it means a note was printed, so we don't need // to print the normal "implementation of `std::ops::Add` might be missing" note match (&lhs_ty.sty, &rhs_ty.sty) { - (&TyRef(_, l_ty, _), &TyRef(_, r_ty, _)) - if l_ty.sty == TyStr && r_ty.sty == TyStr => { + (&Ref(_, l_ty, _), &Ref(_, r_ty, _)) + if l_ty.sty == Str && r_ty.sty == Str => { if !is_assign { err.span_label(expr.span, "`+` can't be used to concatenate two `&str` strings"); @@ -443,8 +443,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } true } - (&TyRef(_, l_ty, _), &TyAdt(..)) - if l_ty.sty == TyStr && &format!("{:?}", rhs_ty) == "std::string::String" => { + (&Ref(_, l_ty, _), &Adt(..)) + if l_ty.sty == Str && &format!("{:?}", rhs_ty) == "std::string::String" => { err.span_label(expr.span, "`+` can't be used to concatenate a `&str` with a `String`"); match ( @@ -489,11 +489,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { err.span_label(ex.span, format!("cannot apply unary \ operator `{}`", op.as_str())); match actual.sty { - TyUint(_) if op == hir::UnNeg => { + Uint(_) if op == hir::UnNeg => { err.note("unsigned values cannot be negated"); }, - TyStr | TyNever | TyChar | TyTuple(_) | TyArray(_,_) => {}, - TyRef(_, ref lty, _) if lty.sty == TyStr => {}, + Str | Never | Char | Tuple(_) | Array(_,_) => {}, + Ref(_, ref lty, _) if lty.sty == Str => {}, _ => { let missing_trait = match op { hir::UnNeg => "std::ops::Neg", diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs index 6af939fcf99b7..867864b3853d0 100644 --- a/src/librustc_typeck/check/regionck.rs +++ b/src/librustc_typeck/check/regionck.rs @@ -589,7 +589,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for RegionCtxt<'a, 'gcx, 'tcx> { // For overloaded derefs, base_ty is the input to `Deref::deref`, // but it's a reference type uing the same region as the output. let base_ty = self.resolve_expr_type_adjusted(base); - if let ty::TyRef(r_ptr, _, _) = base_ty.sty { + if let ty::Ref(r_ptr, _, _) = base_ty.sty { self.mk_subregion_due_to_dereference(expr.span, expr_region, r_ptr); } @@ -702,22 +702,22 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> { from_ty, to_ty); match (&from_ty.sty, &to_ty.sty) { - /*From:*/ (&ty::TyRef(from_r, from_ty, _), - /*To: */ &ty::TyRef(to_r, to_ty, _)) => { + /*From:*/ (&ty::Ref(from_r, from_ty, _), + /*To: */ &ty::Ref(to_r, to_ty, _)) => { // Target cannot outlive source, naturally. self.sub_regions(infer::Reborrow(cast_expr.span), to_r, from_r); self.walk_cast(cast_expr, from_ty, to_ty); } /*From:*/ (_, - /*To: */ &ty::TyDynamic(.., r)) => { + /*To: */ &ty::Dynamic(.., r)) => { // When T is existentially quantified as a trait // `Foo+'to`, it must outlive the region bound `'to`. self.type_must_outlive(infer::RelateObjectBound(cast_expr.span), from_ty, r); } - /*From:*/ (&ty::TyAdt(from_def, _), - /*To: */ &ty::TyAdt(to_def, _)) if from_def.is_box() && to_def.is_box() => { + /*From:*/ (&ty::Adt(from_def, _), + /*To: */ &ty::Adt(to_def, _)) if from_def.is_box() && to_def.is_box() => { self.walk_cast(cast_expr, from_ty.boxed_ty(), to_ty.boxed_ty()); } @@ -736,7 +736,7 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> { fn constrain_callee(&mut self, callee_expr: &hir::Expr) { let callee_ty = self.resolve_node_type(callee_expr.hir_id); match callee_ty.sty { - ty::TyFnDef(..) | ty::TyFnPtr(_) => { } + ty::FnDef(..) | ty::FnPtr(_) => { } _ => { // this should not happen, but it does if the program is // erroneous @@ -914,9 +914,9 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> { self.ty_to_string(indexed_ty)); let r_index_expr = ty::ReScope(region::Scope::Node(index_expr.hir_id.local_id)); - if let ty::TyRef(r_ptr, r_ty, _) = indexed_ty.sty { + if let ty::Ref(r_ptr, r_ty, _) = indexed_ty.sty { match r_ty.sty { - ty::TySlice(_) | ty::TyStr => { + ty::Slice(_) | ty::Str => { self.sub_regions(infer::IndexSlice(index_expr.span), self.tcx.mk_region(r_index_expr), r_ptr); } @@ -1089,7 +1089,7 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> { id, mutbl, cmt_borrowed); let rptr_ty = self.resolve_node_type(id); - if let ty::TyRef(r, _, _) = rptr_ty.sty { + if let ty::Ref(r, _, _) = rptr_ty.sty { debug!("rptr_ty={}", rptr_ty); self.link_region(span, r, ty::BorrowKind::from_mutbl(mutbl), cmt_borrowed); } diff --git a/src/librustc_typeck/check/upvar.rs b/src/librustc_typeck/check/upvar.rs index 61fe90be21774..41df937980ff3 100644 --- a/src/librustc_typeck/check/upvar.rs +++ b/src/librustc_typeck/check/upvar.rs @@ -109,9 +109,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // Extract the type of the closure. let (closure_def_id, substs) = match self.node_ty(closure_hir_id).sty { - ty::TyClosure(def_id, substs) => (def_id, UpvarSubsts::Closure(substs)), - ty::TyGenerator(def_id, substs, _) => (def_id, UpvarSubsts::Generator(substs)), - ty::TyError => { + ty::Closure(def_id, substs) => (def_id, UpvarSubsts::Closure(substs)), + ty::Generator(def_id, substs, _) => (def_id, UpvarSubsts::Generator(substs)), + ty::Error => { // #51714: skip analysis when we have already encountered type errors return; } diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index 4b609779540f0..99e0e8775b0cd 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -454,7 +454,7 @@ fn check_where_clauses<'a, 'gcx, 'fcx, 'tcx>( impl<'tcx> ty::fold::TypeVisitor<'tcx> for CountParams { fn visit_ty(&mut self, t: Ty<'tcx>) -> bool { match t.sty { - ty::TyParam(p) => { + ty::Param(p) => { self.params.insert(p.idx); t.super_visit_with(self) } @@ -576,7 +576,7 @@ fn check_existential_types<'a, 'fcx, 'gcx, 'tcx>( ty.fold_with(&mut ty::fold::BottomUpFolder { tcx: fcx.tcx, fldop: |ty| { - if let ty::TyAnon(def_id, substs) = ty.sty { + if let ty::Anon(def_id, substs) = ty.sty { trace!("check_existential_types: anon_ty, {:?}, {:?}", def_id, substs); let generics = tcx.generics_of(def_id); // only check named existential types @@ -588,7 +588,7 @@ fn check_existential_types<'a, 'fcx, 'gcx, 'tcx>( for (subst, param) in substs.iter().zip(&generics.params) { match subst.unpack() { ty::subst::UnpackedKind::Type(ty) => match ty.sty { - ty::TyParam(..) => {}, + ty::Param(..) => {}, // prevent `fn foo() -> Foo` from being defining _ => { tcx @@ -674,7 +674,7 @@ fn check_existential_types<'a, 'fcx, 'gcx, 'tcx>( } } } // if is_named_existential_type - } // if let TyAnon + } // if let Anon ty }, reg_op: |reg| reg, diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index e87183f847321..1e147b6c2638d 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -174,7 +174,7 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> { match tables.expr_ty_adjusted(&base).sty { // All valid indexing looks like this - ty::TyRef(_, base_ty, _) => { + ty::Ref(_, base_ty, _) => { let index_ty = tables.expr_ty_adjusted(&index); let index_ty = self.fcx.resolve_type_vars_if_possible(&index_ty); @@ -417,7 +417,7 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> { fldop: |ty| { trace!("checking type {:?}: {:#?}", ty, ty.sty); // find a type parameter - if let ty::TyParam(..) = ty.sty { + if let ty::Param(..) = ty.sty { // look it up in the substitution list assert_eq!(anon_defn.substs.len(), generics.params.len()); for (subst, param) in anon_defn.substs.iter().zip(&generics.params) { diff --git a/src/librustc_typeck/coherence/builtin.rs b/src/librustc_typeck/coherence/builtin.rs index ba65d0606b372..d01e7dbdfefe5 100644 --- a/src/librustc_typeck/coherence/builtin.rs +++ b/src/librustc_typeck/coherence/builtin.rs @@ -55,7 +55,7 @@ impl<'a, 'tcx> Checker<'a, 'tcx> { fn visit_implementation_of_drop<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, impl_did: DefId) { match tcx.type_of(impl_did).sty { - ty::TyAdt(..) => {} + ty::Adt(..) => {} _ => { // Destructors only work on nominal types. if let Some(impl_node_id) = tcx.hir.as_local_node_id(impl_did) { @@ -217,23 +217,23 @@ pub fn coerce_unsized_info<'a, 'gcx>(gcx: TyCtxt<'a, 'gcx, 'gcx>, (mt_a.ty, mt_b.ty, unsize_trait, None) }; let (source, target, trait_def_id, kind) = match (&source.sty, &target.sty) { - (&ty::TyRef(r_a, ty_a, mutbl_a), &ty::TyRef(r_b, ty_b, mutbl_b)) => { + (&ty::Ref(r_a, ty_a, mutbl_a), &ty::Ref(r_b, ty_b, mutbl_b)) => { infcx.sub_regions(infer::RelateObjectBound(span), r_b, r_a); let mt_a = ty::TypeAndMut { ty: ty_a, mutbl: mutbl_a }; let mt_b = ty::TypeAndMut { ty: ty_b, mutbl: mutbl_b }; check_mutbl(mt_a, mt_b, &|ty| gcx.mk_imm_ref(r_b, ty)) } - (&ty::TyRef(_, ty_a, mutbl_a), &ty::TyRawPtr(mt_b)) => { + (&ty::Ref(_, ty_a, mutbl_a), &ty::RawPtr(mt_b)) => { let mt_a = ty::TypeAndMut { ty: ty_a, mutbl: mutbl_a }; check_mutbl(mt_a, mt_b, &|ty| gcx.mk_imm_ptr(ty)) } - (&ty::TyRawPtr(mt_a), &ty::TyRawPtr(mt_b)) => { + (&ty::RawPtr(mt_a), &ty::RawPtr(mt_b)) => { check_mutbl(mt_a, mt_b, &|ty| gcx.mk_imm_ptr(ty)) } - (&ty::TyAdt(def_a, substs_a), &ty::TyAdt(def_b, substs_b)) if def_a.is_struct() && + (&ty::Adt(def_a, substs_a), &ty::Adt(def_b, substs_b)) if def_a.is_struct() && def_b.is_struct() => { if def_a != def_b { let source_path = gcx.item_path_str(def_a.did); diff --git a/src/librustc_typeck/coherence/inherent_impls.rs b/src/librustc_typeck/coherence/inherent_impls.rs index f37167d1f6688..52e37b8d0ce11 100644 --- a/src/librustc_typeck/coherence/inherent_impls.rs +++ b/src/librustc_typeck/coherence/inherent_impls.rs @@ -102,16 +102,16 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> { let self_ty = self.tcx.type_of(def_id); let lang_items = self.tcx.lang_items(); match self_ty.sty { - ty::TyAdt(def, _) => { + ty::Adt(def, _) => { self.check_def_id(item, def.did); } - ty::TyForeign(did) => { + ty::Foreign(did) => { self.check_def_id(item, did); } - ty::TyDynamic(ref data, ..) if data.principal().is_some() => { + ty::Dynamic(ref data, ..) if data.principal().is_some() => { self.check_def_id(item, data.principal().unwrap().def_id()); } - ty::TyChar => { + ty::Char => { self.check_primitive_impl(def_id, lang_items.char_impl(), None, @@ -119,7 +119,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> { "char", item.span); } - ty::TyStr => { + ty::Str => { self.check_primitive_impl(def_id, lang_items.str_impl(), lang_items.str_alloc_impl(), @@ -127,7 +127,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> { "str", item.span); } - ty::TySlice(slice_item) if slice_item == self.tcx.types.u8 => { + ty::Slice(slice_item) if slice_item == self.tcx.types.u8 => { self.check_primitive_impl(def_id, lang_items.slice_u8_impl(), lang_items.slice_u8_alloc_impl(), @@ -135,7 +135,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> { "[u8]", item.span); } - ty::TySlice(_) => { + ty::Slice(_) => { self.check_primitive_impl(def_id, lang_items.slice_impl(), lang_items.slice_alloc_impl(), @@ -143,7 +143,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> { "[T]", item.span); } - ty::TyRawPtr(ty::TypeAndMut { ty: _, mutbl: hir::MutImmutable }) => { + ty::RawPtr(ty::TypeAndMut { ty: _, mutbl: hir::MutImmutable }) => { self.check_primitive_impl(def_id, lang_items.const_ptr_impl(), None, @@ -151,7 +151,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> { "*const T", item.span); } - ty::TyRawPtr(ty::TypeAndMut { ty: _, mutbl: hir::MutMutable }) => { + ty::RawPtr(ty::TypeAndMut { ty: _, mutbl: hir::MutMutable }) => { self.check_primitive_impl(def_id, lang_items.mut_ptr_impl(), None, @@ -159,7 +159,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> { "*mut T", item.span); } - ty::TyInt(ast::IntTy::I8) => { + ty::Int(ast::IntTy::I8) => { self.check_primitive_impl(def_id, lang_items.i8_impl(), None, @@ -167,7 +167,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> { "i8", item.span); } - ty::TyInt(ast::IntTy::I16) => { + ty::Int(ast::IntTy::I16) => { self.check_primitive_impl(def_id, lang_items.i16_impl(), None, @@ -175,7 +175,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> { "i16", item.span); } - ty::TyInt(ast::IntTy::I32) => { + ty::Int(ast::IntTy::I32) => { self.check_primitive_impl(def_id, lang_items.i32_impl(), None, @@ -183,7 +183,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> { "i32", item.span); } - ty::TyInt(ast::IntTy::I64) => { + ty::Int(ast::IntTy::I64) => { self.check_primitive_impl(def_id, lang_items.i64_impl(), None, @@ -191,7 +191,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> { "i64", item.span); } - ty::TyInt(ast::IntTy::I128) => { + ty::Int(ast::IntTy::I128) => { self.check_primitive_impl(def_id, lang_items.i128_impl(), None, @@ -199,7 +199,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> { "i128", item.span); } - ty::TyInt(ast::IntTy::Isize) => { + ty::Int(ast::IntTy::Isize) => { self.check_primitive_impl(def_id, lang_items.isize_impl(), None, @@ -207,7 +207,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> { "isize", item.span); } - ty::TyUint(ast::UintTy::U8) => { + ty::Uint(ast::UintTy::U8) => { self.check_primitive_impl(def_id, lang_items.u8_impl(), None, @@ -215,7 +215,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> { "u8", item.span); } - ty::TyUint(ast::UintTy::U16) => { + ty::Uint(ast::UintTy::U16) => { self.check_primitive_impl(def_id, lang_items.u16_impl(), None, @@ -223,7 +223,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> { "u16", item.span); } - ty::TyUint(ast::UintTy::U32) => { + ty::Uint(ast::UintTy::U32) => { self.check_primitive_impl(def_id, lang_items.u32_impl(), None, @@ -231,7 +231,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> { "u32", item.span); } - ty::TyUint(ast::UintTy::U64) => { + ty::Uint(ast::UintTy::U64) => { self.check_primitive_impl(def_id, lang_items.u64_impl(), None, @@ -239,7 +239,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> { "u64", item.span); } - ty::TyUint(ast::UintTy::U128) => { + ty::Uint(ast::UintTy::U128) => { self.check_primitive_impl(def_id, lang_items.u128_impl(), None, @@ -247,7 +247,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> { "u128", item.span); } - ty::TyUint(ast::UintTy::Usize) => { + ty::Uint(ast::UintTy::Usize) => { self.check_primitive_impl(def_id, lang_items.usize_impl(), None, @@ -255,7 +255,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> { "usize", item.span); } - ty::TyFloat(ast::FloatTy::F32) => { + ty::Float(ast::FloatTy::F32) => { self.check_primitive_impl(def_id, lang_items.f32_impl(), lang_items.f32_runtime_impl(), @@ -263,7 +263,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> { "f32", item.span); } - ty::TyFloat(ast::FloatTy::F64) => { + ty::Float(ast::FloatTy::F64) => { self.check_primitive_impl(def_id, lang_items.f64_impl(), lang_items.f64_runtime_impl(), @@ -271,7 +271,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> { "f64", item.span); } - ty::TyError => { + ty::Error => { return; } _ => { diff --git a/src/librustc_typeck/coherence/mod.rs b/src/librustc_typeck/coherence/mod.rs index 1b04c5da59b28..168cf47fb5266 100644 --- a/src/librustc_typeck/coherence/mod.rs +++ b/src/librustc_typeck/coherence/mod.rs @@ -157,7 +157,7 @@ fn check_impl_overlap<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, node_id: ast::NodeI tcx.specialization_graph_of(trait_def_id); // check for overlap with the automatic `impl Trait for Trait` - if let ty::TyDynamic(ref data, ..) = trait_ref.self_ty().sty { + if let ty::Dynamic(ref data, ..) = trait_ref.self_ty().sty { // This is something like impl Trait1 for Trait2. Illegal // if Trait1 is a supertrait of Trait2 or Trait2 is not object safe. diff --git a/src/librustc_typeck/coherence/orphan.rs b/src/librustc_typeck/coherence/orphan.rs index 4a3747017dfc1..f9b89488232d2 100644 --- a/src/librustc_typeck/coherence/orphan.rs +++ b/src/librustc_typeck/coherence/orphan.rs @@ -114,8 +114,8 @@ impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for OrphanChecker<'cx, 'tcx> { !trait_def_id.is_local() { let self_ty = trait_ref.self_ty(); let opt_self_def_id = match self_ty.sty { - ty::TyAdt(self_def, _) => Some(self_def.did), - ty::TyForeign(did) => Some(did), + ty::Adt(self_def, _) => Some(self_def.did), + ty::Foreign(did) => Some(did), _ => None, }; diff --git a/src/librustc_typeck/constrained_type_params.rs b/src/librustc_typeck/constrained_type_params.rs index 5f55b9b06ef1b..37b0b83ccd088 100644 --- a/src/librustc_typeck/constrained_type_params.rs +++ b/src/librustc_typeck/constrained_type_params.rs @@ -62,11 +62,11 @@ struct ParameterCollector { impl<'tcx> TypeVisitor<'tcx> for ParameterCollector { fn visit_ty(&mut self, t: Ty<'tcx>) -> bool { match t.sty { - ty::TyProjection(..) | ty::TyAnon(..) if !self.include_nonconstraining => { + ty::Projection(..) | ty::Anon(..) if !self.include_nonconstraining => { // projections are not injective return false; } - ty::TyParam(data) => { + ty::Param(data) => { self.parameters.push(Parameter::from(data)); } _ => {} diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index 62f93ea20e48c..eddbac3f5417b 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -185,7 +185,7 @@ fn check_main_fn_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let main_def_id = tcx.hir.local_def_id(main_id); let main_t = tcx.type_of(main_def_id); match main_t.sty { - ty::TyFnDef(..) => { + ty::FnDef(..) => { match tcx.hir.find(main_id) { Some(hir_map::NodeItem(it)) => { match it.node { @@ -257,7 +257,7 @@ fn check_start_fn_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let start_def_id = tcx.hir.local_def_id(start_id); let start_t = tcx.type_of(start_def_id); match start_t.sty { - ty::TyFnDef(..) => { + ty::FnDef(..) => { match tcx.hir.find(start_id) { Some(hir_map::NodeItem(it)) => { match it.node { diff --git a/src/librustc_typeck/outlives/implicit_infer.rs b/src/librustc_typeck/outlives/implicit_infer.rs index e378f1a2dce36..ec36fa0fbc145 100644 --- a/src/librustc_typeck/outlives/implicit_infer.rs +++ b/src/librustc_typeck/outlives/implicit_infer.rs @@ -85,7 +85,7 @@ impl<'cx, 'tcx> ItemLikeVisitor<'tcx> for InferVisitor<'cx, 'tcx> { // Calculating the predicate requirements necessary // for item_did. // - // For field of type &'a T (reference) or TyAdt + // For field of type &'a T (reference) or Adt // (struct/enum/union) there will be outlive // requirements for adt_def. let field_ty = self.tcx.type_of(field_def.did); @@ -138,16 +138,16 @@ fn insert_required_predicates_to_be_wf<'tcx>( // a predicate requirement of T: 'a (T outlives 'a). // // We also want to calculate potential predicates for the T - ty::TyRef(region, rty, _) => { - debug!("TyRef"); + ty::Ref(region, rty, _) => { + debug!("Ref"); insert_outlives_predicate(tcx, rty.into(), region, required_predicates); } - // For each TyAdt (struct/enum/union) type `Foo<'a, T>`, we + // For each Adt (struct/enum/union) type `Foo<'a, T>`, we // can load the current set of inferred and explicit // predicates from `global_inferred_outlives` and filter the // ones that are TypeOutlives. - ty::TyAdt(def, substs) => { + ty::Adt(def, substs) => { // First check the inferred predicates // // Example 1: @@ -166,7 +166,7 @@ fn insert_required_predicates_to_be_wf<'tcx>( // round we will get `U: 'b`. We then apply the substitution // `['b => 'a, U => T]` and thus get the requirement that `T: // 'a` holds for `Foo`. - debug!("TyAdt"); + debug!("Adt"); if let Some(unsubstituted_predicates) = global_inferred_outlives.get(&def.did) { for unsubstituted_predicate in unsubstituted_predicates { // `unsubstituted_predicate` is `U: 'b` in the @@ -195,7 +195,7 @@ fn insert_required_predicates_to_be_wf<'tcx>( ); } - ty::TyDynamic(obj, ..) => { + ty::Dynamic(obj, ..) => { // This corresponds to `dyn Trait<..>`. In this case, we should // use the explicit predicates as well. @@ -204,7 +204,7 @@ fn insert_required_predicates_to_be_wf<'tcx>( // `dyn Trait` at this stage. Therefore when checking explicit // predicates in `check_explicit_predicates` we need to ignore // checking the explicit_map for Self type. - debug!("TyDynamic"); + debug!("Dynamic"); debug!("field_ty = {}", &field_ty); debug!("ty in field = {}", &ty); if let Some(ex_trait_ref) = obj.principal() { @@ -219,10 +219,10 @@ fn insert_required_predicates_to_be_wf<'tcx>( } } - ty::TyProjection(obj) => { + ty::Projection(obj) => { // This corresponds to `>::Bar`. In this case, we should use the // explicit predicates as well. - debug!("TyProjection"); + debug!("Projection"); check_explicit_predicates( tcx, &tcx.associated_item(obj.item_def_id).container.id(), diff --git a/src/librustc_typeck/variance/constraints.rs b/src/librustc_typeck/variance/constraints.rs index 9fecf5e73e761..a79215497182e 100644 --- a/src/librustc_typeck/variance/constraints.rs +++ b/src/librustc_typeck/variance/constraints.rs @@ -152,7 +152,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { let inferred_start = self.terms_cx.inferred_starts[&id]; let current_item = &CurrentItem { inferred_start }; match tcx.type_of(def_id).sty { - ty::TyAdt(def, _) => { + ty::Adt(def, _) => { // Not entirely obvious: constraints on structs/enums do not // affect the variance of their type parameters. See discussion // in comment at top of module. @@ -166,7 +166,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { } } - ty::TyFnDef(..) => { + ty::FnDef(..) => { self.add_constraints_from_sig(current_item, tcx.fn_sig(def_id), self.covariant); @@ -261,52 +261,52 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { variance); match ty.sty { - ty::TyBool | ty::TyChar | ty::TyInt(_) | ty::TyUint(_) | ty::TyFloat(_) | - ty::TyStr | ty::TyNever | ty::TyForeign(..) => { + ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Float(_) | + ty::Str | ty::Never | ty::Foreign(..) => { // leaf type -- noop } - ty::TyFnDef(..) | - ty::TyGenerator(..) | - ty::TyClosure(..) => { + ty::FnDef(..) | + ty::Generator(..) | + ty::Closure(..) => { bug!("Unexpected closure type in variance computation"); } - ty::TyRef(region, ty, mutbl) => { + ty::Ref(region, ty, mutbl) => { let contra = self.contravariant(variance); self.add_constraints_from_region(current, region, contra); self.add_constraints_from_mt(current, &ty::TypeAndMut { ty, mutbl }, variance); } - ty::TyArray(typ, _) | - ty::TySlice(typ) => { + ty::Array(typ, _) | + ty::Slice(typ) => { self.add_constraints_from_ty(current, typ, variance); } - ty::TyRawPtr(ref mt) => { + ty::RawPtr(ref mt) => { self.add_constraints_from_mt(current, mt, variance); } - ty::TyTuple(subtys) => { + ty::Tuple(subtys) => { for &subty in subtys { self.add_constraints_from_ty(current, subty, variance); } } - ty::TyAdt(def, substs) => { + ty::Adt(def, substs) => { self.add_constraints_from_substs(current, def.did, substs, variance); } - ty::TyProjection(ref data) => { + ty::Projection(ref data) => { let tcx = self.tcx(); self.add_constraints_from_trait_ref(current, data.trait_ref(tcx), variance); } - ty::TyAnon(_, substs) => { + ty::Anon(_, substs) => { self.add_constraints_from_invariant_substs(current, substs, variance); } - ty::TyDynamic(ref data, r) => { + ty::Dynamic(ref data, r) => { // The type `Foo` is contravariant w/r/t `'a`: let contra = self.contravariant(variance); self.add_constraints_from_region(current, r, contra); @@ -323,21 +323,21 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { } } - ty::TyParam(ref data) => { + ty::Param(ref data) => { self.add_constraint(current, data.idx, variance); } - ty::TyFnPtr(sig) => { + ty::FnPtr(sig) => { self.add_constraints_from_sig(current, sig, variance); } - ty::TyError => { + ty::Error => { // we encounter this when walking the trait references for object - // types, where we use TyError as the Self type + // types, where we use Error as the Self type } - ty::TyGeneratorWitness(..) | - ty::TyInfer(..) => { + ty::GeneratorWitness(..) | + ty::Infer(..) => { bug!("unexpected type encountered in \ variance inference: {}", ty); diff --git a/src/librustc_typeck/variance/solve.rs b/src/librustc_typeck/variance/solve.rs index 340a7b1d08ede..7116a42cead83 100644 --- a/src/librustc_typeck/variance/solve.rs +++ b/src/librustc_typeck/variance/solve.rs @@ -101,7 +101,7 @@ impl<'a, 'tcx> SolveContext<'a, 'tcx> { debug!("id={} variances={:?}", id, variances); // Functions can have unused type parameters: make those invariant. - if let ty::TyFnDef(..) = tcx.type_of(def_id).sty { + if let ty::FnDef(..) = tcx.type_of(def_id).sty { for variance in &mut variances { if *variance == ty::Bivariant { *variance = ty::Invariant; diff --git a/src/librustdoc/clean/blanket_impl.rs b/src/librustdoc/clean/blanket_impl.rs index b95b3ca8e1138..e7e371cd56785 100644 --- a/src/librustdoc/clean/blanket_impl.rs +++ b/src/librustdoc/clean/blanket_impl.rs @@ -83,7 +83,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> BlanketImplFinder <'a, 'tcx, 'rcx, 'cstore> { .expect("Cannot get impl trait"); match trait_ref.self_ty().sty { - ty::TypeVariants::TyParam(_) => {}, + ty::Param(_) => {}, _ => return, } diff --git a/src/librustdoc/clean/def_ctor.rs b/src/librustdoc/clean/def_ctor.rs index 4db211b7f1e70..cd9f4eb42dfc6 100644 --- a/src/librustdoc/clean/def_ctor.rs +++ b/src/librustdoc/clean/def_ctor.rs @@ -20,24 +20,24 @@ where F: Fn(& dyn Fn(DefId) -> Def) -> Vec { let ty = cx.tcx.type_of(def_id); match ty.sty { - ty::TyAdt(adt, _) => callback(&match adt.adt_kind() { + ty::Adt(adt, _) => callback(&match adt.adt_kind() { AdtKind::Struct => Def::Struct, AdtKind::Enum => Def::Enum, AdtKind::Union => Def::Union, }), - ty::TyInt(_) | - ty::TyUint(_) | - ty::TyFloat(_) | - ty::TyStr | - ty::TyBool | - ty::TyChar => callback(&move |_: DefId| { + ty::Int(_) | + ty::Uint(_) | + ty::Float(_) | + ty::Str | + ty::Bool | + ty::Char => callback(&move |_: DefId| { match ty.sty { - ty::TyInt(x) => Def::PrimTy(hir::TyInt(x)), - ty::TyUint(x) => Def::PrimTy(hir::TyUint(x)), - ty::TyFloat(x) => Def::PrimTy(hir::TyFloat(x)), - ty::TyStr => Def::PrimTy(hir::TyStr), - ty::TyBool => Def::PrimTy(hir::TyBool), - ty::TyChar => Def::PrimTy(hir::TyChar), + ty::Int(x) => Def::PrimTy(hir::Int(x)), + ty::Uint(x) => Def::PrimTy(hir::Uint(x)), + ty::Float(x) => Def::PrimTy(hir::Float(x)), + ty::Str => Def::PrimTy(hir::Str), + ty::Bool => Def::PrimTy(hir::Bool), + ty::Char => Def::PrimTy(hir::Char), _ => unreachable!(), } }), diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index 1c66c39b660b2..75d7488d26a75 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -83,7 +83,7 @@ pub fn try_inline(cx: &DocContext, def: Def, name: ast::Name, visited: &mut FxHa ret.extend(build_impls(cx, did, true)); clean::EnumItem(build_enum(cx, did)) } - Def::TyForeign(did) => { + Def::ForeignTy(did) => { record_extern_fqn(cx, did, clean::TypeKind::Foreign); ret.extend(build_impls(cx, did, false)); clean::ForeignTypeItem diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 6cb37c0e6de14..a8bfb3efd33ed 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1077,7 +1077,7 @@ fn external_generic_args(cx: &DocContext, trait_did: Option, has_self: bo Some(did) if cx.tcx.lang_items().fn_trait_kind(did).is_some() => { assert_eq!(types.len(), 1); let inputs = match types[0].sty { - ty::TyTuple(ref tys) => tys.iter().map(|t| t.clean(cx)).collect(), + ty::Tuple(ref tys) => tys.iter().map(|t| t.clean(cx)).collect(), _ => { return GenericArgs::AngleBracketed { lifetimes, @@ -1089,7 +1089,7 @@ fn external_generic_args(cx: &DocContext, trait_did: Option, has_self: bo let output = None; // FIXME(#20299) return type comes from a projection now // match types[1].sty { - // ty::TyTuple(ref v) if v.is_empty() => None, // -> () + // ty::Tuple(ref v) if v.is_empty() => None, // -> () // _ => Some(types[1].clean(cx)) // }; GenericArgs::Parenthesized { @@ -1133,9 +1133,9 @@ impl<'a, 'tcx> Clean for (&'a ty::TraitRef<'tcx>, Vec // collect any late bound regions let mut late_bounds = vec![]; for ty_s in trait_ref.input_types().skip(1) { - if let ty::TyTuple(ts) = ty_s.sty { + if let ty::Tuple(ts) = ty_s.sty { for &ty_s in ts { - if let ty::TyRef(ref reg, _, _) = ty_s.sty { + if let ty::Ref(ref reg, _, _) = ty_s.sty { if let &ty::RegionKind::ReLateBound(..) = *reg { debug!(" hit an ReLateBound {:?}", reg); if let Some(Lifetime(name)) = reg.clean(cx) { @@ -1979,7 +1979,7 @@ impl<'tcx> Clean for ty::AssociatedItem { let self_arg_ty = *sig.input(0).skip_binder(); if self_arg_ty == self_ty { decl.inputs.values[0].type_ = Generic(String::from("Self")); - } else if let ty::TyRef(_, ty, _) = self_arg_ty.sty { + } else if let ty::Ref(_, ty, _) = self_arg_ty.sty { if ty == self_ty { match decl.inputs.values[0].type_ { BorrowedRef{ref mut type_, ..} => { @@ -2506,7 +2506,7 @@ impl Clean for hir::Ty { TyKind::Path(hir::QPath::TypeRelative(ref qself, ref segment)) => { let mut def = Def::Err; let ty = hir_ty_to_ty(cx.tcx, self); - if let ty::TyProjection(proj) = ty.sty { + if let ty::Projection(proj) = ty.sty { def = Def::Trait(proj.trait_ref(cx.tcx).def_id); } let trait_path = hir::Path { @@ -2545,15 +2545,15 @@ impl Clean for hir::Ty { impl<'tcx> Clean for Ty<'tcx> { fn clean(&self, cx: &DocContext) -> Type { match self.sty { - ty::TyNever => Never, - ty::TyBool => Primitive(PrimitiveType::Bool), - ty::TyChar => Primitive(PrimitiveType::Char), - ty::TyInt(int_ty) => Primitive(int_ty.into()), - ty::TyUint(uint_ty) => Primitive(uint_ty.into()), - ty::TyFloat(float_ty) => Primitive(float_ty.into()), - ty::TyStr => Primitive(PrimitiveType::Str), - ty::TySlice(ty) => Slice(box ty.clean(cx)), - ty::TyArray(ty, n) => { + ty::Never => Never, + ty::Bool => Primitive(PrimitiveType::Bool), + ty::Char => Primitive(PrimitiveType::Char), + ty::Int(int_ty) => Primitive(int_ty.into()), + ty::Uint(uint_ty) => Primitive(uint_ty.into()), + ty::Float(float_ty) => Primitive(float_ty.into()), + ty::Str => Primitive(PrimitiveType::Str), + ty::Slice(ty) => Slice(box ty.clean(cx)), + ty::Array(ty, n) => { let mut n = cx.tcx.lift(&n).expect("array lift failed"); if let ConstValue::Unevaluated(def_id, substs) = n.val { let param_env = cx.tcx.param_env(def_id); @@ -2568,15 +2568,15 @@ impl<'tcx> Clean for Ty<'tcx> { let n = print_const(cx, n); Array(box ty.clean(cx), n) } - ty::TyRawPtr(mt) => RawPointer(mt.mutbl.clean(cx), box mt.ty.clean(cx)), - ty::TyRef(r, ty, mutbl) => BorrowedRef { + ty::RawPtr(mt) => RawPointer(mt.mutbl.clean(cx), box mt.ty.clean(cx)), + ty::Ref(r, ty, mutbl) => BorrowedRef { lifetime: r.clean(cx), mutability: mutbl.clean(cx), type_: box ty.clean(cx), }, - ty::TyFnDef(..) | - ty::TyFnPtr(_) => { - let ty = cx.tcx.lift(self).expect("TyFnPtr lift failed"); + ty::FnDef(..) | + ty::FnPtr(_) => { + let ty = cx.tcx.lift(self).expect("FnPtr lift failed"); let sig = ty.fn_sig(cx.tcx); BareFunction(box BareFunctionDecl { unsafety: sig.unsafety(), @@ -2585,7 +2585,7 @@ impl<'tcx> Clean for Ty<'tcx> { abi: sig.abi(), }) } - ty::TyAdt(def, substs) => { + ty::Adt(def, substs) => { let did = def.did; let kind = match def.adt_kind() { AdtKind::Struct => TypeKind::Struct, @@ -2602,7 +2602,7 @@ impl<'tcx> Clean for Ty<'tcx> { is_generic: false, } } - ty::TyForeign(did) => { + ty::Foreign(did) => { inline::record_extern_fqn(cx, did, TypeKind::Foreign); let path = external_path(cx, &cx.tcx.item_name(did).as_str(), None, false, vec![], Substs::empty()); @@ -2613,7 +2613,7 @@ impl<'tcx> Clean for Ty<'tcx> { is_generic: false, } } - ty::TyDynamic(ref obj, ref reg) => { + ty::Dynamic(ref obj, ref reg) => { if let Some(principal) = obj.principal() { let did = principal.def_id(); inline::record_extern_fqn(cx, did, TypeKind::Trait); @@ -2657,17 +2657,17 @@ impl<'tcx> Clean for Ty<'tcx> { Never } } - ty::TyTuple(ref t) => Tuple(t.clean(cx)), + ty::Tuple(ref t) => Tuple(t.clean(cx)), - ty::TyProjection(ref data) => data.clean(cx), + ty::Projection(ref data) => data.clean(cx), - ty::TyParam(ref p) => Generic(p.name.to_string()), + ty::Param(ref p) => Generic(p.name.to_string()), - ty::TyAnon(def_id, substs) => { + ty::Anon(def_id, substs) => { // Grab the "TraitA + TraitB" from `impl TraitA + TraitB`, // by looking up the projections associated with the def_id. let predicates_of = cx.tcx.predicates_of(def_id); - let substs = cx.tcx.lift(&substs).expect("TyAnon lift failed"); + let substs = cx.tcx.lift(&substs).expect("Anon lift failed"); let bounds = predicates_of.instantiate(cx.tcx, substs); let mut regions = vec![]; let mut has_sized = false; @@ -2717,11 +2717,11 @@ impl<'tcx> Clean for Ty<'tcx> { ImplTrait(bounds) } - ty::TyClosure(..) | ty::TyGenerator(..) => Tuple(vec![]), // FIXME(pcwalton) + ty::Closure(..) | ty::Generator(..) => Tuple(vec![]), // FIXME(pcwalton) - ty::TyGeneratorWitness(..) => panic!("TyGeneratorWitness"), - ty::TyInfer(..) => panic!("TyInfer"), - ty::TyError => panic!("TyError"), + ty::GeneratorWitness(..) => panic!("GeneratorWitness"), + ty::Infer(..) => panic!("Infer"), + ty::Error => panic!("Error"), } } } @@ -3700,12 +3700,12 @@ fn resolve_type(cx: &DocContext, let is_generic = match path.def { Def::PrimTy(p) => match p { - hir::TyStr => return Primitive(PrimitiveType::Str), - hir::TyBool => return Primitive(PrimitiveType::Bool), - hir::TyChar => return Primitive(PrimitiveType::Char), - hir::TyInt(int_ty) => return Primitive(int_ty.into()), - hir::TyUint(uint_ty) => return Primitive(uint_ty.into()), - hir::TyFloat(float_ty) => return Primitive(float_ty.into()), + hir::Str => return Primitive(PrimitiveType::Str), + hir::Bool => return Primitive(PrimitiveType::Bool), + hir::Char => return Primitive(PrimitiveType::Char), + hir::Int(int_ty) => return Primitive(int_ty.into()), + hir::Uint(uint_ty) => return Primitive(uint_ty.into()), + hir::Float(float_ty) => return Primitive(float_ty.into()), }, Def::SelfTy(..) if path.segments.len() == 1 => { return Generic(keywords::SelfType.name().to_string()); @@ -3731,7 +3731,7 @@ pub fn register_def(cx: &DocContext, def: Def) -> DefId { Def::Struct(i) => (i, TypeKind::Struct), Def::Union(i) => (i, TypeKind::Union), Def::Mod(i) => (i, TypeKind::Module), - Def::TyForeign(i) => (i, TypeKind::Foreign), + Def::ForeignTy(i) => (i, TypeKind::Foreign), Def::Const(i) => (i, TypeKind::Const), Def::Static(i, _) => (i, TypeKind::Static), Def::Variant(i) => (cx.tcx.parent_def_id(i).expect("cannot get parent def id"), diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index c00d67aaab6b4..cced30d1a0c20 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -149,7 +149,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> LinkCollector<'a, 'tcx, 'rcx, 'cstore> { Ok((ty.def, Some(format!("{}.{}", out, item_name)))) } else { match cx.tcx.type_of(did).sty { - ty::TyAdt(def, _) => { + ty::Adt(def, _) => { if let Some(item) = if def.is_enum() { def.all_fields().find(|item| item.ident.name == item_name) } else { @@ -567,23 +567,23 @@ fn handle_variant(cx: &DocContext, def: Def) -> Result<(Def, Option), () } const PRIMITIVES: &[(&str, Def)] = &[ - ("u8", Def::PrimTy(hir::PrimTy::TyUint(syntax::ast::UintTy::U8))), - ("u16", Def::PrimTy(hir::PrimTy::TyUint(syntax::ast::UintTy::U16))), - ("u32", Def::PrimTy(hir::PrimTy::TyUint(syntax::ast::UintTy::U32))), - ("u64", Def::PrimTy(hir::PrimTy::TyUint(syntax::ast::UintTy::U64))), - ("u128", Def::PrimTy(hir::PrimTy::TyUint(syntax::ast::UintTy::U128))), - ("usize", Def::PrimTy(hir::PrimTy::TyUint(syntax::ast::UintTy::Usize))), - ("i8", Def::PrimTy(hir::PrimTy::TyInt(syntax::ast::IntTy::I8))), - ("i16", Def::PrimTy(hir::PrimTy::TyInt(syntax::ast::IntTy::I16))), - ("i32", Def::PrimTy(hir::PrimTy::TyInt(syntax::ast::IntTy::I32))), - ("i64", Def::PrimTy(hir::PrimTy::TyInt(syntax::ast::IntTy::I64))), - ("i128", Def::PrimTy(hir::PrimTy::TyInt(syntax::ast::IntTy::I128))), - ("isize", Def::PrimTy(hir::PrimTy::TyInt(syntax::ast::IntTy::Isize))), - ("f32", Def::PrimTy(hir::PrimTy::TyFloat(syntax::ast::FloatTy::F32))), - ("f64", Def::PrimTy(hir::PrimTy::TyFloat(syntax::ast::FloatTy::F64))), - ("str", Def::PrimTy(hir::PrimTy::TyStr)), - ("bool", Def::PrimTy(hir::PrimTy::TyBool)), - ("char", Def::PrimTy(hir::PrimTy::TyChar)), + ("u8", Def::PrimTy(hir::PrimTy::Uint(syntax::ast::UintTy::U8))), + ("u16", Def::PrimTy(hir::PrimTy::Uint(syntax::ast::UintTy::U16))), + ("u32", Def::PrimTy(hir::PrimTy::Uint(syntax::ast::UintTy::U32))), + ("u64", Def::PrimTy(hir::PrimTy::Uint(syntax::ast::UintTy::U64))), + ("u128", Def::PrimTy(hir::PrimTy::Uint(syntax::ast::UintTy::U128))), + ("usize", Def::PrimTy(hir::PrimTy::Uint(syntax::ast::UintTy::Usize))), + ("i8", Def::PrimTy(hir::PrimTy::Int(syntax::ast::IntTy::I8))), + ("i16", Def::PrimTy(hir::PrimTy::Int(syntax::ast::IntTy::I16))), + ("i32", Def::PrimTy(hir::PrimTy::Int(syntax::ast::IntTy::I32))), + ("i64", Def::PrimTy(hir::PrimTy::Int(syntax::ast::IntTy::I64))), + ("i128", Def::PrimTy(hir::PrimTy::Int(syntax::ast::IntTy::I128))), + ("isize", Def::PrimTy(hir::PrimTy::Int(syntax::ast::IntTy::Isize))), + ("f32", Def::PrimTy(hir::PrimTy::Float(syntax::ast::FloatTy::F32))), + ("f64", Def::PrimTy(hir::PrimTy::Float(syntax::ast::FloatTy::F64))), + ("str", Def::PrimTy(hir::PrimTy::Str)), + ("bool", Def::PrimTy(hir::PrimTy::Bool)), + ("char", Def::PrimTy(hir::PrimTy::Char)), ]; fn is_primitive(path_str: &str, is_val: bool) -> Option { diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index 68ddf72da0617..15a94b8adfcb2 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -267,7 +267,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> RustdocVisitor<'a, 'tcx, 'rcx, 'cstore> { Def::Struct(did) | Def::Union(did) | Def::Enum(did) | - Def::TyForeign(did) | + Def::ForeignTy(did) | Def::TyAlias(did) if !self_is_hidden => { self.cx.access_levels.borrow_mut().map.insert(did, AccessLevel::Public); }, diff --git a/src/test/run-pass/auxiliary/issue13507.rs b/src/test/run-pass/auxiliary/issue13507.rs index dee40b2fc5735..87b01ed990036 100644 --- a/src/test/run-pass/auxiliary/issue13507.rs +++ b/src/test/run-pass/auxiliary/issue13507.rs @@ -32,43 +32,43 @@ pub mod testtypes { ] } - // Tests TyBool + // Tests Bool pub type FooBool = bool; - // Tests TyChar + // Tests Char pub type FooChar = char; - // Tests TyInt (does not test all variants of IntTy) + // Tests Int (does not test all variants of IntTy) pub type FooInt = isize; - // Tests TyUint (does not test all variants of UintTy) + // Tests Uint (does not test all variants of UintTy) pub type FooUint = usize; - // Tests TyFloat (does not test all variants of FloatTy) + // Tests Float (does not test all variants of FloatTy) pub type FooFloat = f64; - // Tests TyStr + // Tests Str pub type FooStr = str; - // Tests TyArray + // Tests Array pub type FooArray = [u8; 1]; - // Tests TySlice + // Tests Slice pub type FooSlice = [u8]; // Tests Box (of u8) pub type FooBox = Box; - // Tests TyRawPtr + // Tests RawPtr pub type FooPtr = *const u8; - // Tests TyRef + // Tests Ref pub type FooRef = &'static u8; - // Tests TyFnPtr + // Tests FnPtr pub type FooFnPtr = fn(u8) -> bool; - // Tests TyDynamic + // Tests Dynamic pub trait FooTrait { fn foo_method(&self) -> usize; } @@ -85,13 +85,13 @@ pub mod testtypes { VarB(usize, usize) } - // Tests TyTuple + // Tests Tuple pub type FooNil = (); pub type FooTuple = (u8, i8, bool); - // Skipping TyParam + // Skipping Param - // Skipping TyInfer + // Skipping Infer - // Skipping TyError + // Skipping Error } diff --git a/src/test/run-pass/unboxed-closures-unique-type-id.rs b/src/test/run-pass/unboxed-closures-unique-type-id.rs index 40071ec9754e2..c95885518ea2f 100644 --- a/src/test/run-pass/unboxed-closures-unique-type-id.rs +++ b/src/test/run-pass/unboxed-closures-unique-type-id.rs @@ -12,7 +12,7 @@ // // error: internal compiler error: get_unique_type_id_of_type() - // unexpected type: closure, -// TyClosure(syntax::ast::DefId{krate: 0, node: 66}, +// Closure(syntax::ast::DefId{krate: 0, node: 66}, // ReScope(63)) // // This is a regression test for issue #17021.