]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/ty/mod.rs
Ensure `type_param_predicates` fn only returns predicates for type param with given...
[rust.git] / src / librustc / ty / mod.rs
index 538afa6054ff9611ad635915e35bc1f3d8fb3598..1eda57608e75b8460a3d9f65603b73de2c45b25a 100644 (file)
@@ -32,7 +32,7 @@
 use arena::SyncDroplessArena;
 use crate::session::DataTypeKind;
 
-use serialize::{self, Encodable, Encoder};
+use rustc_serialize::{self, Encodable, Encoder};
 use std::cell::RefCell;
 use std::cmp::{self, Ordering};
 use std::fmt;
@@ -185,7 +185,7 @@ pub struct AssocItem {
 pub enum AssocKind {
     Const,
     Method,
-    Existential,
+    OpaqueTy,
     Type
 }
 
@@ -195,7 +195,7 @@ pub fn def_kind(&self) -> DefKind {
             AssocKind::Const => DefKind::AssocConst,
             AssocKind::Method => DefKind::Method,
             AssocKind::Type => DefKind::AssocTy,
-            AssocKind::Existential => DefKind::AssocExistential,
+            AssocKind::OpaqueTy => DefKind::AssocOpaqueTy,
         }
     }
 
@@ -203,7 +203,7 @@ pub fn def_kind(&self) -> DefKind {
     /// for !
     pub fn relevant_for_never(&self) -> bool {
         match self.kind {
-            AssocKind::Existential |
+            AssocKind::OpaqueTy |
             AssocKind::Const |
             AssocKind::Type => true,
             // FIXME(canndrew): Be more thorough here, check if any argument is uninhabited.
@@ -221,7 +221,8 @@ pub fn signature(&self, tcx: TyCtxt<'_>) -> String {
                 tcx.fn_sig(self.def_id).skip_binder().to_string()
             }
             ty::AssocKind::Type => format!("type {};", self.ident),
-            ty::AssocKind::Existential => format!("existential type {};", self.ident),
+            // FIXME(type_alias_impl_trait): we should print bounds here too.
+            ty::AssocKind::OpaqueTy => format!("type {};", self.ident),
             ty::AssocKind::Const => {
                 format!("const {}: {:?};", self.ident, tcx.type_of(self.def_id))
             }
@@ -588,8 +589,8 @@ fn hash_stable<W: StableHasherResult>(&self,
 
 pub type Ty<'tcx> = &'tcx TyS<'tcx>;
 
-impl<'tcx> serialize::UseSpecializedEncodable for Ty<'tcx> {}
-impl<'tcx> serialize::UseSpecializedDecodable for Ty<'tcx> {}
+impl<'tcx> rustc_serialize::UseSpecializedEncodable for Ty<'tcx> {}
+impl<'tcx> rustc_serialize::UseSpecializedDecodable for Ty<'tcx> {}
 
 pub type CanonicalTy<'tcx> = Canonical<'tcx, Ty<'tcx>>;
 
@@ -708,7 +709,7 @@ fn into_iter(self) -> Self::IntoIter {
     }
 }
 
-impl<'tcx> serialize::UseSpecializedDecodable for &'tcx List<Ty<'tcx>> {}
+impl<'tcx> rustc_serialize::UseSpecializedDecodable for &'tcx List<Ty<'tcx>> {}
 
 impl<T> List<T> {
     #[inline(always)]
@@ -903,7 +904,7 @@ pub struct Generics {
     pub parent_count: usize,
     pub params: Vec<GenericParamDef>,
 
-    /// Reverse map to the `index` field of each `GenericParamDef`
+    /// Reverse map to the `index` field of each `GenericParamDef`.
     #[stable_hasher(ignore)]
     pub param_def_id_to_index: FxHashMap<DefId, u32>,
 
@@ -1009,8 +1010,8 @@ pub struct GenericPredicates<'tcx> {
     pub predicates: Vec<(Predicate<'tcx>, Span)>,
 }
 
-impl<'tcx> serialize::UseSpecializedEncodable for GenericPredicates<'tcx> {}
-impl<'tcx> serialize::UseSpecializedDecodable for GenericPredicates<'tcx> {}
+impl<'tcx> rustc_serialize::UseSpecializedEncodable for GenericPredicates<'tcx> {}
+impl<'tcx> rustc_serialize::UseSpecializedDecodable for GenericPredicates<'tcx> {}
 
 impl<'tcx> GenericPredicates<'tcx> {
     pub fn instantiate(
@@ -1251,7 +1252,7 @@ pub fn self_ty(&self) -> Ty<'tcx> {
 
 impl<'tcx> PolyTraitPredicate<'tcx> {
     pub fn def_id(&self) -> DefId {
-        // Ok to skip binder since trait def-ID does not care about regions.
+        // Ok to skip binder since trait `DefId` does not care about regions.
         self.skip_binder().def_id()
     }
 }
@@ -1318,7 +1319,7 @@ pub fn ty(&self) -> Binder<Ty<'tcx>> {
     /// Note that this is not the `DefId` of the `TraitRef` containing this
     /// associated type, which is in `tcx.associated_item(projection_def_id()).container`.
     pub fn projection_def_id(&self) -> DefId {
-        // Ok to skip binder since trait def-ID does not care about regions.
+        // Ok to skip binder since trait `DefId` does not care about regions.
         self.skip_binder().projection_ty.item_def_id
     }
 }
@@ -1645,9 +1646,9 @@ fn hash_stable<W: StableHasherResult>(
 /// particular point.
 #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, HashStable)]
 pub struct ParamEnv<'tcx> {
-    /// Obligations that the caller must satisfy. This is basically
+    /// `Obligation`s 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.
+    /// into `Obligation`s, and elaborated and normalized.
     pub caller_bounds: &'tcx List<ty::Predicate<'tcx>>,
 
     /// Typically, this is `Reveal::UserFacing`, but during codegen we
@@ -1985,13 +1986,13 @@ fn hash<H: Hasher>(&self, s: &mut H) {
     }
 }
 
-impl<'tcx> serialize::UseSpecializedEncodable for &'tcx AdtDef {
+impl<'tcx> rustc_serialize::UseSpecializedEncodable for &'tcx AdtDef {
     fn default_encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
         self.did.encode(s)
     }
 }
 
-impl<'tcx> serialize::UseSpecializedDecodable for &'tcx AdtDef {}
+impl<'tcx> rustc_serialize::UseSpecializedDecodable for &'tcx AdtDef {}
 
 
 impl<'a> HashStable<StableHashingContext<'a>> for AdtDef {
@@ -2795,7 +2796,7 @@ pub fn opt_associated_item(self, def_id: DefId) -> Option<AssocItem> {
                 _ => false,
             }
         } else {
-            match self.def_kind(def_id).expect("no def for def-id") {
+            match self.def_kind(def_id).expect("no def for `DefId`") {
                 DefKind::AssocConst
                 | DefKind::Method
                 | DefKind::AssocTy => true,
@@ -2822,7 +2823,7 @@ fn associated_item_from_trait_item_ref(self,
                 (ty::AssocKind::Method, has_self)
             }
             hir::AssocItemKind::Type => (ty::AssocKind::Type, false),
-            hir::AssocItemKind::Existential => bug!("only impls can have existentials"),
+            hir::AssocItemKind::OpaqueTy => bug!("only impls can have opaque types"),
         };
 
         AssocItem {
@@ -2848,7 +2849,7 @@ fn associated_item_from_impl_item_ref(self,
                 (ty::AssocKind::Method, has_self)
             }
             hir::AssocItemKind::Type => (ty::AssocKind::Type, false),
-            hir::AssocItemKind::Existential => (ty::AssocKind::Existential, false),
+            hir::AssocItemKind::OpaqueTy => (ty::AssocKind::OpaqueTy, false),
         };
 
         AssocItem {
@@ -3213,8 +3214,8 @@ fn trait_of_item(tcx: TyCtxt<'_>, def_id: DefId) -> Option<DefId> {
 pub fn is_impl_trait_defn(tcx: TyCtxt<'_>, def_id: DefId) -> Option<DefId> {
     if let Some(hir_id) = tcx.hir().as_local_hir_id(def_id) {
         if let Node::Item(item) = tcx.hir().get(hir_id) {
-            if let hir::ItemKind::Existential(ref exist_ty) = item.node {
-                return exist_ty.impl_trait_fn;
+            if let hir::ItemKind::OpaqueTy(ref opaque_ty) = item.node {
+                return opaque_ty.impl_trait_fn;
             }
         }
     }