about summary refs log tree commit diff
diff options
context:
space:
mode:
authorscalexm <martin.alex32@hotmail.fr>2017-08-07 13:22:48 +0200
committerscalexm <martin.alex32@hotmail.fr>2017-08-14 15:07:21 +0200
commit91aa99607f1076c8f76614ed6f15b1645e87e5a8 (patch)
tree33a9892336584416005ebcedfa0c9c005ee38a51
parent91e99a321569defb72cde69f2b2854b1e166219c (diff)
downloadrust-91aa99607f1076c8f76614ed6f15b1645e87e5a8.tar.gz
rust-91aa99607f1076c8f76614ed6f15b1645e87e5a8.zip
Do not store `ty`
-rw-r--r--src/librustc/traits/mod.rs7
-rw-r--r--src/librustc/traits/select.rs9
-rw-r--r--src/librustc/traits/structural_impls.rs16
-rw-r--r--src/librustc_mir/shim.rs8
-rw-r--r--src/librustc_trans/monomorphize.rs4
5 files changed, 16 insertions, 28 deletions
diff --git a/src/librustc/traits/mod.rs b/src/librustc/traits/mod.rs
index 1c6d75ace52..d1938197e65 100644
--- a/src/librustc/traits/mod.rs
+++ b/src/librustc/traits/mod.rs
@@ -301,7 +301,7 @@ pub enum Vtable<'tcx, N> {
     VtableObject(VtableObjectData<'tcx, N>),
 
     /// Successful resolution for a builtin trait.
-    VtableBuiltin(VtableBuiltinData<'tcx, N>),
+    VtableBuiltin(VtableBuiltinData<N>),
 
     /// Vtable automatically generated for a closure. The def ID is the ID
     /// of the closure expression. This is a `VtableImpl` in spirit, but the
@@ -345,9 +345,7 @@ pub struct VtableDefaultImplData<N> {
 }
 
 #[derive(Clone)]
-pub struct VtableBuiltinData<'tcx, N> {
-    /// `ty` can be used for generating shim for builtin implementations like `Clone::clone`.
-    pub ty: ty::Ty<'tcx>,
+pub struct VtableBuiltinData<N> {
     pub nested: Vec<N>
 }
 
@@ -771,7 +769,6 @@ impl<'tcx, N> Vtable<'tcx, N> {
             }),
             VtableParam(n) => VtableParam(n.into_iter().map(f).collect()),
             VtableBuiltin(i) => VtableBuiltin(VtableBuiltinData {
-                ty: i.ty,
                 nested: i.nested.into_iter().map(f).collect(),
             }),
             VtableObject(o) => VtableObject(VtableObjectData {
diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs
index 88cca70993e..46bdb1344b2 100644
--- a/src/librustc/traits/select.rs
+++ b/src/librustc/traits/select.rs
@@ -2265,7 +2265,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
     fn confirm_builtin_candidate(&mut self,
                                  obligation: &TraitObligation<'tcx>,
                                  has_nested: bool)
-                                 -> VtableBuiltinData<'tcx, PredicateObligation<'tcx>>
+                                 -> VtableBuiltinData<PredicateObligation<'tcx>>
     {
         debug!("confirm_builtin_candidate({:?}, {:?})",
                obligation, has_nested);
@@ -2303,8 +2303,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
         debug!("confirm_builtin_candidate: obligations={:?}",
                obligations);
 
-        let self_ty = self.infcx.shallow_resolve(obligation.predicate.skip_binder().self_ty());
-        VtableBuiltinData { ty: self_ty, nested: obligations }
+        VtableBuiltinData { nested: obligations }
     }
 
     /// This handles the case where a `impl Foo for ..` impl is being used.
@@ -2611,7 +2610,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
 
     fn confirm_builtin_unsize_candidate(&mut self,
                                         obligation: &TraitObligation<'tcx>,)
-        -> Result<VtableBuiltinData<'tcx, PredicateObligation<'tcx>>, SelectionError<'tcx>>
+        -> Result<VtableBuiltinData<PredicateObligation<'tcx>>, SelectionError<'tcx>>
     {
         let tcx = self.tcx();
 
@@ -2814,7 +2813,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
             _ => bug!()
         };
 
-        Ok(VtableBuiltinData { ty: source, nested: nested })
+        Ok(VtableBuiltinData { nested: nested })
     }
 
     ///////////////////////////////////////////////////////////////////////////
diff --git a/src/librustc/traits/structural_impls.rs b/src/librustc/traits/structural_impls.rs
index a83849898f5..003508fbbca 100644
--- a/src/librustc/traits/structural_impls.rs
+++ b/src/librustc/traits/structural_impls.rs
@@ -86,9 +86,9 @@ impl<'tcx, N: fmt::Debug> fmt::Debug for traits::VtableClosureData<'tcx, N> {
     }
 }
 
-impl<'tcx, N: fmt::Debug> fmt::Debug for traits::VtableBuiltinData<'tcx, N> {
+impl<'tcx, N: fmt::Debug> fmt::Debug for traits::VtableBuiltinData<N> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        write!(f, "VtableBuiltin(ty={:?}, nested={:?})", self.ty, self.nested)
+        write!(f, "VtableBuiltin(nested={:?})", self.nested)
     }
 }
 
@@ -300,14 +300,7 @@ impl<'a, 'tcx> Lift<'tcx> for traits::Vtable<'a, ()> {
                 })
             }
             traits::VtableParam(n) => Some(traits::VtableParam(n)),
-            traits::VtableBuiltin(traits::VtableBuiltinData { ty, nested }) => {
-                tcx.lift(&ty).map(|ty| {
-                    traits::VtableBuiltin(traits::VtableBuiltinData {
-                        ty,
-                        nested,
-                    })
-                })
-            }
+            traits::VtableBuiltin(n) => Some(traits::VtableBuiltin(n)),
             traits::VtableObject(traits::VtableObjectData {
                 upcast_trait_ref,
                 vtable_base,
@@ -385,10 +378,9 @@ impl<'tcx, N: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::VtableDefaultIm
     }
 }
 
-impl<'tcx, N: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::VtableBuiltinData<'tcx, N> {
+impl<'tcx, N: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::VtableBuiltinData<N> {
     fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
         traits::VtableBuiltinData {
-            ty: self.ty.fold_with(folder),
             nested: self.nested.fold_with(folder),
         }
     }
diff --git a/src/librustc_mir/shim.rs b/src/librustc_mir/shim.rs
index cb1a2f6b107..040d96b0dcc 100644
--- a/src/librustc_mir/shim.rs
+++ b/src/librustc_mir/shim.rs
@@ -275,7 +275,7 @@ impl<'a, 'tcx> DropElaborator<'a, 'tcx> for DropShimElaborator<'a, 'tcx> {
 /// Build a `Clone::clone` shim for `recvr_ty`. Here, `def_id` is `Clone::clone`.
 fn build_clone_shim<'a, 'tcx>(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
                               def_id: DefId,
-                              recvr_ty: ty::Ty<'tcx>)
+                              rcvr_ty: ty::Ty<'tcx>)
                               -> Mir<'tcx>
 {
     let sig = tcx.fn_sig(def_id);
@@ -348,7 +348,7 @@ fn build_clone_shim<'a, 'tcx>(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
         loc
     };
 
-    match recvr_ty.sty {
+    match rcvr_ty.sty {
         ty::TyArray(ty, len) => {
             let mut returns = Vec::new();
             for i in 0..len {
@@ -374,7 +374,7 @@ fn build_clone_shim<'a, 'tcx>(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
                     Lvalue::Local(RETURN_POINTER),
                     Rvalue::Aggregate(
                         box AggregateKind::Array(ty),
-                        returns.into_iter().map(|loc| Operand::Consume(loc)).collect()
+                        returns.into_iter().map(Operand::Consume).collect()
                     )
                 )
             };
@@ -396,7 +396,7 @@ fn build_clone_shim<'a, 'tcx>(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
                     Lvalue::Local(RETURN_POINTER),
                     Rvalue::Aggregate(
                         box AggregateKind::Tuple,
-                        returns.into_iter().map(|loc| Operand::Consume(loc)).collect()
+                        returns.into_iter().map(Operand::Consume).collect()
                     )
                 )
             };
diff --git a/src/librustc_trans/monomorphize.rs b/src/librustc_trans/monomorphize.rs
index 1936775df0a..401ee8cfaa8 100644
--- a/src/librustc_trans/monomorphize.rs
+++ b/src/librustc_trans/monomorphize.rs
@@ -143,9 +143,9 @@ fn resolve_associated_item<'a, 'tcx>(
                 substs: rcvr_substs
             }
         }
-        traits::VtableBuiltin(ref data) => {
+        traits::VtableBuiltin(..) => {
             Instance {
-                def: ty::InstanceDef::BuiltinShim(def_id, data.ty),
+                def: ty::InstanceDef::BuiltinShim(def_id, trait_ref.self_ty()),
                 substs: rcvr_substs
             }
         }