about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2018-05-15 13:15:49 +0100
committervarkor <github@varkor.com>2018-05-15 14:22:25 +0100
commite9c28b2564c26767b6cab2f95e851389b4c1b014 (patch)
tree21b42b8133f1abf8f11f8bb30d61754eb01b1f18 /src
parent3ae2468261dca097ecfa81a74654fed32b60f8ce (diff)
downloadrust-e9c28b2564c26767b6cab2f95e851389b4c1b014.tar.gz
rust-e9c28b2564c26767b6cab2f95e851389b4c1b014.zip
Use Kind instead of UnpackedKind in Substs methods
Diffstat (limited to 'src')
-rw-r--r--src/librustc/infer/mod.rs8
-rw-r--r--src/librustc/traits/mod.rs8
-rw-r--r--src/librustc/ty/context.rs6
-rw-r--r--src/librustc/ty/subst.rs17
-rw-r--r--src/librustc/ty/util.rs2
-rw-r--r--src/librustc_mir/monomorphize/collector.rs8
-rw-r--r--src/librustc_mir/shim.rs6
-rw-r--r--src/librustc_typeck/astconv.rs36
-rw-r--r--src/librustc_typeck/check/closure.rs6
-rw-r--r--src/librustc_typeck/check/method/confirm.rs10
-rw-r--r--src/librustc_typeck/check/method/mod.rs6
-rw-r--r--src/librustc_typeck/check/method/probe.rs15
-rw-r--r--src/librustc_typeck/check/mod.rs24
-rw-r--r--src/librustc_typeck/check/wfcheck.rs9
-rw-r--r--src/librustc_typeck/collect.rs8
15 files changed, 75 insertions, 94 deletions
diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs
index 7a1e255dc5d..38db58b1e00 100644
--- a/src/librustc/infer/mod.rs
+++ b/src/librustc/infer/mod.rs
@@ -21,7 +21,7 @@ use hir::def_id::DefId;
 use middle::free_region::RegionRelations;
 use middle::region;
 use middle::lang_items;
-use ty::subst::{UnpackedKind, Substs};
+use ty::subst::{Kind, Substs};
 use ty::{TyVid, IntVid, FloatVid};
 use ty::{self, Ty, TyCtxt, GenericParamDefKind};
 use ty::error::{ExpectedFound, TypeError, UnconstrainedNumeric};
@@ -908,12 +908,12 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
     pub fn var_for_def(&self,
                        span: Span,
                        param: &ty::GenericParamDef)
-                       -> UnpackedKind<'tcx> {
+                       -> Kind<'tcx> {
         match param.kind {
             GenericParamDefKind::Lifetime => {
                 // Create a region inference variable for the given
                 // region parameter definition.
-                UnpackedKind::Lifetime(self.next_region_var(EarlyBoundRegion(span, param.name)))
+                self.next_region_var(EarlyBoundRegion(span, param.name)).into()
             }
             GenericParamDefKind::Type(_) => {
                 // Create a type inference variable for the given
@@ -930,7 +930,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
                                              false,
                                              TypeVariableOrigin::TypeParameterDefinition(span, param.name));
 
-                UnpackedKind::Type(self.tcx.mk_var(ty_var_id))
+                self.tcx.mk_var(ty_var_id).into()
             }
         }
     }
diff --git a/src/librustc/traits/mod.rs b/src/librustc/traits/mod.rs
index 4b5c767b031..36fedab9e79 100644
--- a/src/librustc/traits/mod.rs
+++ b/src/librustc/traits/mod.rs
@@ -22,7 +22,7 @@ use hir::def_id::DefId;
 use infer::outlives::env::OutlivesEnvironment;
 use middle::region;
 use middle::const_val::ConstEvalErr;
-use ty::subst::{UnpackedKind, Substs};
+use ty::subst::Substs;
 use ty::{self, AdtKind, Slice, Ty, TyCtxt, GenericParamDefKind, TypeFoldable, ToPredicate};
 use ty::error::{ExpectedFound, TypeError};
 use infer::{InferCtxt};
@@ -843,11 +843,9 @@ fn vtable_methods<'a, 'tcx>(
                 let substs = trait_ref.map_bound(|trait_ref| {
                     Substs::for_item(tcx, def_id, |param, _| {
                         match param.kind {
-                            GenericParamDefKind::Lifetime => {
-                                UnpackedKind::Lifetime(tcx.types.re_erased)
-                            }
+                            GenericParamDefKind::Lifetime => tcx.types.re_erased.into(),
                             GenericParamDefKind::Type(_) => {
-                                UnpackedKind::Type(trait_ref.substs.type_for_def(param))
+                                trait_ref.substs.type_for_def(param).into()
                             }
                         }
                     })
diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs
index 66c451e8193..592f04ca913 100644
--- a/src/librustc/ty/context.rs
+++ b/src/librustc/ty/context.rs
@@ -32,7 +32,7 @@ use middle::lang_items;
 use middle::resolve_lifetime::{self, ObjectLifetimeDefault};
 use middle::stability;
 use mir::{self, Mir, interpret};
-use ty::subst::{Kind, UnpackedKind, Substs, Subst};
+use ty::subst::{Kind, Substs, Subst};
 use ty::ReprOptions;
 use ty::Instance;
 use traits;
@@ -2331,10 +2331,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
                 GenericParamDefKind::Lifetime => bug!(),
                 GenericParamDefKind::Type(ty_param) => {
                     if param.index == 0 {
-                        UnpackedKind::Type(ty)
+                        ty.into()
                     } else {
                         assert!(ty_param.has_default);
-                        UnpackedKind::Type(self.type_of(param.def_id).subst(self, substs))
+                        self.type_of(param.def_id).subst(self, substs).into()
                     }
                 }
             }
diff --git a/src/librustc/ty/subst.rs b/src/librustc/ty/subst.rs
index 5c2b5c5cd45..3c016b38aff 100644
--- a/src/librustc/ty/subst.rs
+++ b/src/librustc/ty/subst.rs
@@ -184,12 +184,9 @@ impl<'a, 'gcx, 'tcx> Substs<'tcx> {
         Substs::for_item(tcx, def_id, |param, _| {
             match param.kind {
                 GenericParamDefKind::Lifetime => {
-                    UnpackedKind::Lifetime(
-                        tcx.mk_region(ty::ReEarlyBound(param.to_early_bound_region_data())))
-                }
-                GenericParamDefKind::Type(_) => {
-                    UnpackedKind::Type(tcx.mk_ty_param_from_def(param))
+                    tcx.mk_region(ty::ReEarlyBound(param.to_early_bound_region_data())).into()
                 }
+                GenericParamDefKind::Type(_) => tcx.mk_ty_param_from_def(param).into(),
             }
         })
     }
@@ -203,7 +200,7 @@ impl<'a, 'gcx, 'tcx> Substs<'tcx> {
                        def_id: DefId,
                        mut mk_kind: F)
                        -> &'tcx Substs<'tcx>
-    where F: FnMut(&ty::GenericParamDef, &[Kind<'tcx>]) -> UnpackedKind<'tcx>
+    where F: FnMut(&ty::GenericParamDef, &[Kind<'tcx>]) -> Kind<'tcx>
     {
         let defs = tcx.generics_of(def_id);
         let mut substs = Vec::with_capacity(defs.count());
@@ -216,7 +213,7 @@ impl<'a, 'gcx, 'tcx> Substs<'tcx> {
                         def_id: DefId,
                         mut mk_kind: F)
                         -> &'tcx Substs<'tcx>
-    where F: FnMut(&ty::GenericParamDef, &[Kind<'tcx>]) -> UnpackedKind<'tcx>
+    where F: FnMut(&ty::GenericParamDef, &[Kind<'tcx>]) -> Kind<'tcx>
     {
         let defs = tcx.generics_of(def_id);
         let mut result = Vec::with_capacity(defs.count());
@@ -229,7 +226,7 @@ impl<'a, 'gcx, 'tcx> Substs<'tcx> {
                              tcx: TyCtxt<'a, 'gcx, 'tcx>,
                              defs: &ty::Generics,
                              mk_kind: &mut F)
-    where F: FnMut(&ty::GenericParamDef, &[Kind<'tcx>]) -> UnpackedKind<'tcx>
+    where F: FnMut(&ty::GenericParamDef, &[Kind<'tcx>]) -> Kind<'tcx>
     {
 
         if let Some(def_id) = defs.parent {
@@ -242,12 +239,12 @@ impl<'a, 'gcx, 'tcx> Substs<'tcx> {
     fn fill_single<F>(substs: &mut Vec<Kind<'tcx>>,
                            defs: &ty::Generics,
                            mk_kind: &mut F)
-    where F: FnMut(&ty::GenericParamDef, &[Kind<'tcx>]) -> UnpackedKind<'tcx>
+    where F: FnMut(&ty::GenericParamDef, &[Kind<'tcx>]) -> Kind<'tcx>
     {
         for param in &defs.params {
             let kind = mk_kind(param, substs);
             assert_eq!(param.index as usize, substs.len());
-            substs.push(kind.pack());
+            substs.push(kind);
         }
     }
 
diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs
index 91280e5b8a3..d5532f8f835 100644
--- a/src/librustc/ty/util.rs
+++ b/src/librustc/ty/util.rs
@@ -576,7 +576,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
     pub fn empty_substs_for_def_id(self, item_def_id: DefId) -> &'tcx Substs<'tcx> {
         Substs::for_item(self, item_def_id, |param, _| {
             match param.kind {
-                GenericParamDefKind::Lifetime => UnpackedKind::Lifetime(self.types.re_erased),
+                GenericParamDefKind::Lifetime => self.types.re_erased.into(),
                 GenericParamDefKind::Type(_) => {
                     bug!("empty_substs_for_def_id: {:?} has type parameters", item_def_id)
                 }
diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs
index c8d4ccaf0bb..bff8f2246ab 100644
--- a/src/librustc_mir/monomorphize/collector.rs
+++ b/src/librustc_mir/monomorphize/collector.rs
@@ -196,7 +196,7 @@ use rustc::hir::def_id::DefId;
 use rustc::middle::const_val::ConstVal;
 use rustc::mir::interpret::{AllocId, ConstValue};
 use rustc::middle::lang_items::{ExchangeMallocFnLangItem, StartFnLangItem};
-use rustc::ty::subst::{Substs, Kind, UnpackedKind};
+use rustc::ty::subst::{Substs, Kind};
 use rustc::ty::{self, TypeFoldable, Ty, TyCtxt, GenericParamDefKind};
 use rustc::ty::adjustment::CustomCoerceUnsized;
 use rustc::session::config;
@@ -1114,11 +1114,9 @@ fn create_mono_items_for_default_impls<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
 
                     let substs = Substs::for_item(tcx, method.def_id, |param, _| {
                         match param.kind {
-                            GenericParamDefKind::Lifetime => {
-                                UnpackedKind::Lifetime(tcx.types.re_erased)
-                            }
+                            GenericParamDefKind::Lifetime => tcx.types.re_erased.into(),
                             GenericParamDefKind::Type(_) => {
-                                UnpackedKind::Type(trait_ref.substs.type_for_def(param))
+                                trait_ref.substs.type_for_def(param).into()
                             }
                         }
                     });
diff --git a/src/librustc_mir/shim.rs b/src/librustc_mir/shim.rs
index 8596d546b09..c79298d8dd2 100644
--- a/src/librustc_mir/shim.rs
+++ b/src/librustc_mir/shim.rs
@@ -13,7 +13,7 @@ use rustc::hir::def_id::DefId;
 use rustc::infer;
 use rustc::mir::*;
 use rustc::ty::{self, Ty, TyCtxt, GenericParamDefKind};
-use rustc::ty::subst::{Kind, UnpackedKind, Subst, Substs};
+use rustc::ty::subst::{Kind, Subst, Substs};
 use rustc::ty::maps::Providers;
 
 use rustc_data_structures::indexed_vec::{IndexVec, Idx};
@@ -429,8 +429,8 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> {
 
         let substs = Substs::for_item(tcx, self.def_id, |param, _| {
             match param.kind {
-                GenericParamDefKind::Lifetime => UnpackedKind::Lifetime(tcx.types.re_erased),
-                GenericParamDefKind::Type(_) => UnpackedKind::Type(ty),
+                GenericParamDefKind::Lifetime => tcx.types.re_erased.into(),
+                GenericParamDefKind::Type(_) => ty.into(),
             }
         });
 
diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs
index 32ea9938ff5..dc7c8849f91 100644
--- a/src/librustc_typeck/astconv.rs
+++ b/src/librustc_typeck/astconv.rs
@@ -269,31 +269,30 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
             match param.kind {
                 GenericParamDefKind::Lifetime => {
                     let i = param.index as usize - own_self;
-                    let lt = if let Some(lifetime) = parameters.lifetimes.get(i) {
-                        self.ast_region_to_region(lifetime, Some(param))
+                    if let Some(lifetime) = parameters.lifetimes.get(i) {
+                        self.ast_region_to_region(lifetime, Some(param)).into()
                     } else {
-                        tcx.types.re_static
-                    };
-                    UnpackedKind::Lifetime(lt)
+                        tcx.types.re_static.into()
+                    }
                 }
                 GenericParamDefKind::Type(ty) => {
                     let i = param.index as usize;
 
                     // Handle Self first, so we can adjust the index to match the AST.
                     if let (0, Some(ty)) = (i, self_ty) {
-                        return UnpackedKind::Type(ty);
+                        return ty.into();
                     }
 
                     let i = i - (lt_accepted + own_self);
-                    let ty = if i < ty_provided {
+                    if i < ty_provided {
                         // A provided type parameter.
-                        self.ast_ty_to_ty(&parameters.types[i])
+                        self.ast_ty_to_ty(&parameters.types[i]).into()
                     } else if infer_types {
                         // No type parameters were provided, we can infer all.
                         if !default_needs_object_self(param) {
-                            self.ty_infer_for_def(param, span)
+                            self.ty_infer_for_def(param, span).into()
                         } else {
-                            self.ty_infer(span)
+                            self.ty_infer(span).into()
                         }
                     } else if ty.has_default {
                         // No type parameter provided, but a default exists.
@@ -314,20 +313,19 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
                                                 type parameters must be specified on object \
                                                 types"))
                                 .emit();
-                            tcx.types.err
+                            tcx.types.err.into()
                         } else {
                             // This is a default type parameter.
                             self.normalize_ty(
                                 span,
                                 tcx.at(span).type_of(param.def_id)
                                     .subst_spanned(tcx, substs, Some(span))
-                            )
+                            ).into()
                         }
                     } else {
                         // We've already errored above about the mismatch.
-                        tcx.types.err
-                    };
-                    UnpackedKind::Type(ty)
+                        tcx.types.err.into()
+                    }
                 }
             }
         });
@@ -1162,12 +1160,10 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
             Substs::fill_item(&mut substs, tcx, parent_generics, &mut |param, _| {
                 match param.kind {
                     GenericParamDefKind::Lifetime => {
-                        UnpackedKind::Lifetime(
-                            tcx.mk_region(ty::ReEarlyBound(param.to_early_bound_region_data())))
-                    }
-                    GenericParamDefKind::Type(_) => {
-                        UnpackedKind::Type(tcx.mk_ty_param_from_def(param))
+                        tcx.mk_region(
+                            ty::ReEarlyBound(param.to_early_bound_region_data())).into()
                     }
+                    GenericParamDefKind::Type(_) => tcx.mk_ty_param_from_def(param).into(),
                 }
             });
 
diff --git a/src/librustc_typeck/check/closure.rs b/src/librustc_typeck/check/closure.rs
index 152f020c476..c2ec6475b9c 100644
--- a/src/librustc_typeck/check/closure.rs
+++ b/src/librustc_typeck/check/closure.rs
@@ -19,7 +19,7 @@ use rustc::infer::LateBoundRegionConversionTime;
 use rustc::infer::type_variable::TypeVariableOrigin;
 use rustc::traits::error_reporting::ArgKind;
 use rustc::ty::{self, ToPolyTraitRef, Ty, GenericParamDefKind};
-use rustc::ty::subst::{UnpackedKind, Substs};
+use rustc::ty::subst::Substs;
 use rustc::ty::TypeFoldable;
 use std::cmp;
 use std::iter;
@@ -110,8 +110,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
                     span_bug!(expr.span, "closure has region param")
                 }
                 GenericParamDefKind::Type(_) => {
-                    UnpackedKind::Type(self.infcx
-                        .next_ty_var(TypeVariableOrigin::ClosureSynthetic(expr.span)))
+                    self.infcx
+                        .next_ty_var(TypeVariableOrigin::ClosureSynthetic(expr.span)).into()
                 }
             }
         });
diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs
index e2b4380fda2..aa3a166d065 100644
--- a/src/librustc_typeck/check/method/confirm.rs
+++ b/src/librustc_typeck/check/method/confirm.rs
@@ -16,7 +16,7 @@ use hir::def_id::DefId;
 use rustc::ty::subst::Substs;
 use rustc::traits;
 use rustc::ty::{self, Ty, GenericParamDefKind};
-use rustc::ty::subst::{UnpackedKind, Subst};
+use rustc::ty::subst::Subst;
 use rustc::ty::adjustment::{Adjustment, Adjust, OverloadedDeref};
 use rustc::ty::adjustment::{AllowTwoPhase, AutoBorrow, AutoBorrowMutability};
 use rustc::ty::fold::TypeFoldable;
@@ -320,22 +320,22 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
         Substs::for_item(self.tcx, pick.item.def_id, |param, _| {
             let i = param.index as usize;
             if i < parent_substs.len() {
-                parent_substs[i].unpack()
+                parent_substs[i]
             } else {
                 match param.kind {
                     GenericParamDefKind::Lifetime => {
                         if let Some(lifetime) = provided.as_ref().and_then(|p| {
                             p.lifetimes.get(i - parent_substs.len())
                         }) {
-                            return UnpackedKind::Lifetime(
-                                AstConv::ast_region_to_region(self.fcx, lifetime, Some(param)));
+                            return AstConv::ast_region_to_region(
+                                self.fcx, lifetime, Some(param)).into();
                         }
                     }
                     GenericParamDefKind::Type(_) => {
                         if let Some(ast_ty) = provided.as_ref().and_then(|p| {
                             p.types.get(i - parent_substs.len() - own_counts.lifetimes)
                         }) {
-                            return UnpackedKind::Type(self.to_ty(ast_ty));
+                            return self.to_ty(ast_ty).into();
                         }
                     }
                 }
diff --git a/src/librustc_typeck/check/method/mod.rs b/src/librustc_typeck/check/method/mod.rs
index f02f70caef9..15a8efd5885 100644
--- a/src/librustc_typeck/check/method/mod.rs
+++ b/src/librustc_typeck/check/method/mod.rs
@@ -20,7 +20,7 @@ use rustc::ty::subst::Substs;
 use rustc::traits;
 use rustc::ty::{self, Ty, ToPredicate, ToPolyTraitRef, TraitRef, TypeFoldable};
 use rustc::ty::GenericParamDefKind;
-use rustc::ty::subst::{UnpackedKind, Subst};
+use rustc::ty::subst::Subst;
 use rustc::infer::{self, InferOk};
 
 use syntax::ast;
@@ -259,9 +259,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
                 GenericParamDefKind::Lifetime => {}
                 GenericParamDefKind::Type(_) => {
                     if param.index == 0 {
-                        return UnpackedKind::Type(self_ty);
+                        return self_ty.into();
                     } else if let Some(ref input_types) = opt_input_types {
-                        return UnpackedKind::Type(input_types[param.index as usize - 1]);
+                        return input_types[param.index as usize - 1].into();
                     }
                 }
             }
diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs
index 54fea4ab00a..6b860dbe8fe 100644
--- a/src/librustc_typeck/check/method/probe.rs
+++ b/src/librustc_typeck/check/method/probe.rs
@@ -17,7 +17,7 @@ use check::FnCtxt;
 use hir::def_id::DefId;
 use hir::def::Def;
 use namespace::Namespace;
-use rustc::ty::subst::{UnpackedKind, Subst, Substs};
+use rustc::ty::subst::{Subst, Substs};
 use rustc::traits::{self, ObligationCause};
 use rustc::ty::{self, Ty, ToPolyTraitRef, ToPredicate, TraitRef, TypeFoldable};
 use rustc::ty::GenericParamDefKind;
@@ -1391,13 +1391,13 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
             let substs = Substs::for_item(self.tcx, method, |param, _| {
                 let i = param.index as usize;
                 if i < substs.len() {
-                    substs[i].unpack()
+                    substs[i]
                 } else {
                     match param.kind {
                         GenericParamDefKind::Lifetime => {
                             // In general, during probe we erase regions. See
                             // `impl_self_ty()` for an explanation.
-                            UnpackedKind::Lifetime(self.tcx.types.re_erased)
+                            self.tcx.types.re_erased.into()
                         }
                         GenericParamDefKind::Type(_) => self.var_for_def(self.span, param),
                     }
@@ -1415,13 +1415,10 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
     fn fresh_item_substs(&self, def_id: DefId) -> &'tcx Substs<'tcx> {
         Substs::for_item(self.tcx, def_id, |param, _| {
             match param.kind {
-                GenericParamDefKind::Lifetime => {
-                    UnpackedKind::Lifetime(self.tcx.types.re_erased)
-                }
+                GenericParamDefKind::Lifetime => self.tcx.types.re_erased.into(),
                 GenericParamDefKind::Type(_) => {
-                    UnpackedKind::Type(self.next_ty_var(
-                        TypeVariableOrigin::SubstitutionPlaceholder(
-                        self.tcx.def_span(def_id))))
+                    self.next_ty_var(TypeVariableOrigin::SubstitutionPlaceholder(
+                        self.tcx.def_span(def_id))).into()
                 }
             }
         })
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
index 0b0659729ef..2e9f31dd15e 100644
--- a/src/librustc_typeck/check/mod.rs
+++ b/src/librustc_typeck/check/mod.rs
@@ -1746,11 +1746,10 @@ impl<'a, 'gcx, 'tcx> AstConv<'gcx, 'tcx> for FnCtxt<'a, 'gcx, 'tcx> {
     fn ty_infer_for_def(&self,
                         ty_param_def: &ty::GenericParamDef,
                         span: Span) -> Ty<'tcx> {
-        if let UnpackedKind::Type(ty) = self.var_for_def(span, ty_param_def) {
-            ty
-        } else {
-            unreachable!()
+        if let UnpackedKind::Type(ty) = self.var_for_def(span, ty_param_def).unpack() {
+            return ty;
         }
+        unreachable!()
     }
 
     fn projected_ty_from_poly_trait_ref(&self,
@@ -4769,7 +4768,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
                 if let GenericParamDefKind::Type(_) = param.kind {
                     // Handle Self first, so we can adjust the index to match the AST.
                     if has_self && i == 0 {
-                        return opt_self_ty.map(|ty| UnpackedKind::Type(ty)).unwrap_or_else(|| {
+                        return opt_self_ty.map(|ty| Kind::from(ty)).unwrap_or_else(|| {
                             self.var_for_def(span, param)
                         });
                     }
@@ -4787,12 +4786,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
                         s.parameters.as_ref().map_or(&[][..], |p| &p.lifetimes[..])
                     });
 
-                    let lt = if let Some(lifetime) = lifetimes.get(i) {
-                        AstConv::ast_region_to_region(self, lifetime, Some(param))
+                    if let Some(lifetime) = lifetimes.get(i) {
+                        AstConv::ast_region_to_region(self, lifetime, Some(param)).into()
                     } else {
-                        self.re_infer(span, Some(param)).unwrap()
-                    };
-                    UnpackedKind::Lifetime(lt)
+                        self.re_infer(span, Some(param)).unwrap().into()
+                    }
                 }
                 GenericParamDefKind::Type(_) => {
                     let (types, infer_types) = segment.map_or((&[][..], true), |(s, _)| {
@@ -4811,14 +4809,14 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
 
                     if let Some(ast_ty) = types.get(i) {
                         // A provided type parameter.
-                        UnpackedKind::Type(self.to_ty(ast_ty))
+                        self.to_ty(ast_ty).into()
                     } else if !infer_types && has_default {
                         // No type parameter provided, but a default exists.
                         let default = self.tcx.type_of(param.def_id);
-                        UnpackedKind::Type(self.normalize_ty(
+                        self.normalize_ty(
                             span,
                             default.subst_spanned(self.tcx, substs, Some(span))
-                        ))
+                        ).into()
                     } else {
                         // No type parameters were provided, we can infer all.
                         // This can also be reached in some error cases:
diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs
index 5c6a78de313..34978c4e31b 100644
--- a/src/librustc_typeck/check/wfcheck.rs
+++ b/src/librustc_typeck/check/wfcheck.rs
@@ -14,7 +14,7 @@ use constrained_type_params::{identify_constrained_type_params, Parameter};
 use hir::def_id::DefId;
 use rustc::traits::{self, ObligationCauseCode};
 use rustc::ty::{self, Lift, Ty, TyCtxt, GenericParamDefKind};
-use rustc::ty::subst::{UnpackedKind, Substs};
+use rustc::ty::subst::Substs;
 use rustc::ty::util::ExplicitSelf;
 use rustc::util::nodemap::{FxHashSet, FxHashMap};
 use rustc::middle::lang_items;
@@ -409,8 +409,7 @@ fn check_where_clauses<'a, 'gcx, 'fcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'gcx>,
         match param.kind {
             GenericParamDefKind::Lifetime => {
                 // All regions are identity.
-                UnpackedKind::Lifetime(
-                    fcx.tcx.mk_region(ty::ReEarlyBound(param.to_early_bound_region_data())))
+                fcx.tcx.mk_region(ty::ReEarlyBound(param.to_early_bound_region_data())).into()
             }
             GenericParamDefKind::Type(_) => {
                 // If the param has a default,
@@ -419,11 +418,11 @@ fn check_where_clauses<'a, 'gcx, 'fcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'gcx>,
                     // and it's not a dependent default
                     if !default_ty.needs_subst() {
                         // then substitute with the default.
-                        return UnpackedKind::Type(default_ty);
+                        return default_ty.into();
                     }
                 }
                 // Mark unwanted params as err.
-                UnpackedKind::Type(fcx.tcx.types.err)
+                fcx.tcx.types.err.into()
             }
         }
     });
diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs
index 1a2480bf45e..8eb05078359 100644
--- a/src/librustc_typeck/collect.rs
+++ b/src/librustc_typeck/collect.rs
@@ -30,7 +30,7 @@ use constrained_type_params as ctp;
 use middle::lang_items::SizedTraitLangItem;
 use middle::resolve_lifetime as rl;
 use rustc::mir::mono::Linkage;
-use rustc::ty::subst::{UnpackedKind, Substs};
+use rustc::ty::subst::Substs;
 use rustc::ty::GenericParamDefKind;
 use rustc::ty::{ToPredicate, ReprOptions};
 use rustc::ty::{self, AdtKind, ToPolyTraitRef, Ty, TyCtxt};
@@ -1101,11 +1101,9 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                     match param.kind {
                         GenericParamDefKind::Lifetime => {
                             let region = param.to_early_bound_region_data();
-                            UnpackedKind::Lifetime(tcx.mk_region(ty::ReEarlyBound(region)))
-                        }
-                        GenericParamDefKind::Type(_) => {
-                            UnpackedKind::Type(tcx.mk_ty_param_from_def(param))
+                            tcx.mk_region(ty::ReEarlyBound(region)).into()
                         }
+                        GenericParamDefKind::Type(_) => tcx.mk_ty_param_from_def(param).into(),
                     }
                 })
             };