about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc/ty/mod.rs6
-rw-r--r--src/librustc/ty/subst.rs12
-rw-r--r--src/librustc_typeck/astconv.rs2
-rw-r--r--src/librustc_typeck/check/mod.rs2
-rw-r--r--src/librustc_typeck/collect.rs6
5 files changed, 12 insertions, 16 deletions
diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs
index bf4bc9d3b3e..45005fd543d 100644
--- a/src/librustc/ty/mod.rs
+++ b/src/librustc/ty/mod.rs
@@ -795,12 +795,8 @@ pub struct Generics {
 }
 
 impl<'a, 'gcx, 'tcx> Generics {
-    pub fn own_count(&self) -> usize {
-        self.params.len()
-    }
-
     pub fn count(&self) -> usize {
-        self.parent_count + self.own_count()
+        self.parent_count + self.params.len()
     }
 
     pub fn lifetimes(&self) -> impl DoubleEndedIterator<Item = &RegionParameterDef> {
diff --git a/src/librustc/ty/subst.rs b/src/librustc/ty/subst.rs
index 2f4daf61a07..ed8549af8b4 100644
--- a/src/librustc/ty/subst.rs
+++ b/src/librustc/ty/subst.rs
@@ -252,20 +252,20 @@ impl<'a, 'gcx, 'tcx> Substs<'tcx> {
         }
 
         for def in &defs.params {
+            assert_eq!(def.index() as usize, substs.len());
             let param = match def {
                 ty::GenericParam::Lifetime(ref lt) => {
-                    UnpackedKind::Lifetime(mk_region(lt, substs))
+                    mk_region(lt, substs).into()
                 }
                 ty::GenericParam::Type(ref ty) => {
                     if skip_self {
                         skip_self = false;
                         continue
                     }
-                    UnpackedKind::Type(mk_type(ty, substs))
+                    mk_type(ty, substs).into()
                 }
             };
-            assert_eq!(def.index() as usize, substs.len());
-            substs.push(param.pack());
+            substs.push(param);
         }
     }
 
@@ -333,7 +333,7 @@ impl<'a, 'gcx, 'tcx> Substs<'tcx> {
                        target_substs: &Substs<'tcx>)
                        -> &'tcx Substs<'tcx> {
         let defs = tcx.generics_of(source_ancestor);
-        tcx.mk_substs(target_substs.iter().chain(&self[defs.own_count()..]).cloned())
+        tcx.mk_substs(target_substs.iter().chain(&self[defs.params.len()..]).cloned())
     }
 
     pub fn truncate_to(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, generics: &ty::Generics)
@@ -586,7 +586,7 @@ impl<'a, 'gcx, 'tcx> ty::TraitRef<'tcx> {
 
         ty::TraitRef {
             def_id: trait_id,
-            substs: tcx.intern_substs(&substs[..defs.own_count()])
+            substs: tcx.intern_substs(&substs[..defs.params.len()])
         }
     }
 }
diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs
index fab8eec35f3..0de26ba584b 100644
--- a/src/librustc_typeck/astconv.rs
+++ b/src/librustc_typeck/astconv.rs
@@ -1143,7 +1143,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
         assert_eq!(substs.len(), generics.parent_count);
 
         // Fill in our own generics with the resolved lifetimes
-        assert_eq!(lifetimes.len(), generics.own_count());
+        assert_eq!(lifetimes.len(), generics.params.len());
         substs.extend(lifetimes.iter().map(|lt| Kind::from(self.ast_region_to_region(lt, None))));
 
         debug!("impl_trait_ty_to_ty: final substs = {:?}", substs);
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
index b6f3d5a80d6..338f5cc8676 100644
--- a/src/librustc_typeck/check/mod.rs
+++ b/src/librustc_typeck/check/mod.rs
@@ -4754,7 +4754,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
                 (generics.parent_count, generics.has_self)
             }
             (Some((_, generics)), None) => {
-                (generics.own_count(), generics.has_self)
+                (generics.params.len(), generics.has_self)
             }
             (None, None) => (0, false)
         };
diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs
index 0fc47b93f8f..ca496aed342 100644
--- a/src/librustc_typeck/collect.rs
+++ b/src/librustc_typeck/collect.rs
@@ -971,10 +971,10 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                                    .collect();
 
     let lifetimes: Vec<ty::GenericParam> =
-        regions.into_iter().map(|lt| ty::GenericParam::Lifetime(lt)).collect();
+        regions.into_iter().map(|lt| ty::GenericParam::Lifetime(lt));
     let types: Vec<ty::GenericParam> =
-        types.into_iter().map(|ty| ty::GenericParam::Type(ty)).collect();
-    let params = lifetimes.into_iter().chain(types.into_iter()).collect();
+        types.into_iter().map(|ty| ty::GenericParam::Type(ty));
+    let params = lifetimes.chain(types).collect();
 
     tcx.alloc_generics(ty::Generics {
         parent: parent_def_id,