about summary refs log tree commit diff
diff options
context:
space:
mode:
authorIrina Popa <irinagpopa@gmail.com>2018-02-05 21:07:20 +0200
committerIrina Popa <irinagpopa@gmail.com>2018-04-26 16:50:28 +0300
commit7a5147616b16b78a65d80f13b85c3010131d3b7a (patch)
tree09ff196592e7e2a7ca43bc2dc37e205396e4ffc8
parent3bd7efadae490bcf3434719dc97e649f93645901 (diff)
downloadrust-7a5147616b16b78a65d80f13b85c3010131d3b7a.tar.gz
rust-7a5147616b16b78a65d80f13b85c3010131d3b7a.zip
rustc_target: move LayoutOf's type parameter to an associated type.
-rw-r--r--src/librustc/lint/context.rs3
-rw-r--r--src/librustc/ty/layout.rs12
-rw-r--r--src/librustc_mir/interpret/eval_context.rs6
-rw-r--r--src/librustc_mir/transform/const_prop.rs3
-rw-r--r--src/librustc_target/abi/mod.rs7
-rw-r--r--src/librustc_trans/context.rs3
6 files changed, 21 insertions, 13 deletions
diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs
index d5849ea22b1..f90baa2ccd9 100644
--- a/src/librustc/lint/context.rs
+++ b/src/librustc/lint/context.rs
@@ -657,7 +657,8 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
     }
 }
 
-impl<'a, 'tcx> LayoutOf<Ty<'tcx>> for &'a LateContext<'a, 'tcx> {
+impl<'a, 'tcx> LayoutOf for &'a LateContext<'a, 'tcx> {
+    type Ty = Ty<'tcx>;
     type TyLayout = Result<TyLayout<'tcx>, LayoutError<'tcx>>;
 
     fn layout_of(self, ty: Ty<'tcx>) -> Self::TyLayout {
diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs
index c7fbd31b259..069250bb055 100644
--- a/src/librustc/ty/layout.rs
+++ b/src/librustc/ty/layout.rs
@@ -1371,7 +1371,8 @@ impl<T, E> MaybeResult<T> for Result<T, E> {
     }
 }
 
-impl<'a, 'tcx> LayoutOf<Ty<'tcx>> for LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
+impl<'a, 'tcx> LayoutOf for LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
+    type Ty = Ty<'tcx>;
     type TyLayout = Result<TyLayout<'tcx>, LayoutError<'tcx>>;
 
     /// Computes the layout of a type. Note that this implicitly
@@ -1397,7 +1398,8 @@ impl<'a, 'tcx> LayoutOf<Ty<'tcx>> for LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
     }
 }
 
-impl<'a, 'tcx> LayoutOf<Ty<'tcx>> for LayoutCx<'tcx, ty::maps::TyCtxtAt<'a, 'tcx, 'tcx>> {
+impl<'a, 'tcx> LayoutOf for LayoutCx<'tcx, ty::maps::TyCtxtAt<'a, 'tcx, 'tcx>> {
+    type Ty = Ty<'tcx>;
     type TyLayout = Result<TyLayout<'tcx>, LayoutError<'tcx>>;
 
     /// Computes the layout of a type. Note that this implicitly
@@ -1458,7 +1460,7 @@ impl<'a, 'tcx> ty::maps::TyCtxtAt<'a, 'tcx, 'tcx> {
 
 impl<'a, 'tcx> TyLayout<'tcx> {
     pub fn for_variant<C>(&self, cx: C, variant_index: usize) -> Self
-        where C: LayoutOf<Ty<'tcx>> + HasTyCtxt<'tcx>,
+        where C: LayoutOf<Ty = Ty<'tcx>> + HasTyCtxt<'tcx>,
               C::TyLayout: MaybeResult<TyLayout<'tcx>>
     {
         let details = match self.variants {
@@ -1495,7 +1497,7 @@ impl<'a, 'tcx> TyLayout<'tcx> {
     }
 
     pub fn field<C>(&self, cx: C, i: usize) -> C::TyLayout
-        where C: LayoutOf<Ty<'tcx>> + HasTyCtxt<'tcx>,
+        where C: LayoutOf<Ty = Ty<'tcx>> + HasTyCtxt<'tcx>,
               C::TyLayout: MaybeResult<TyLayout<'tcx>>
     {
         let tcx = cx.tcx();
@@ -1623,7 +1625,7 @@ impl<'a, 'tcx> TyLayout<'tcx> {
     // FIXME(eddyb) traverse already optimized enums.
     fn find_niche<C>(&self, cx: C, count: u128)
         -> Result<Option<(Size, Scalar, u128)>, LayoutError<'tcx>>
-        where C: LayoutOf<Ty<'tcx>, TyLayout = Result<Self, LayoutError<'tcx>>> +
+        where C: LayoutOf<Ty = Ty<'tcx>, TyLayout = Result<Self, LayoutError<'tcx>>> +
                  HasTyCtxt<'tcx>
     {
         let scalar_component = |scalar: &Scalar, offset| {
diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs
index 14ee795b3b1..42f0e38af1f 100644
--- a/src/librustc_mir/interpret/eval_context.rs
+++ b/src/librustc_mir/interpret/eval_context.rs
@@ -162,7 +162,8 @@ impl<'c, 'b, 'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> layout::HasTyCtxt<'tcx>
     }
 }
 
-impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> LayoutOf<Ty<'tcx>> for &'a EvalContext<'a, 'mir, 'tcx, M> {
+impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> LayoutOf for &'a EvalContext<'a, 'mir, 'tcx, M> {
+    type Ty = Ty<'tcx>;
     type TyLayout = EvalResult<'tcx, TyLayout<'tcx>>;
 
     fn layout_of(self, ty: Ty<'tcx>) -> Self::TyLayout {
@@ -171,8 +172,9 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> LayoutOf<Ty<'tcx>> for &'a EvalCont
     }
 }
 
-impl<'c, 'b, 'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> LayoutOf<Ty<'tcx>>
+impl<'c, 'b, 'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> LayoutOf
     for &'c &'b mut EvalContext<'a, 'mir, 'tcx, M> {
+    type Ty = Ty<'tcx>;
     type TyLayout = EvalResult<'tcx, TyLayout<'tcx>>;
 
     #[inline]
diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs
index a3d96f0c073..47b2f430bc7 100644
--- a/src/librustc_mir/transform/const_prop.rs
+++ b/src/librustc_mir/transform/const_prop.rs
@@ -72,7 +72,8 @@ struct ConstPropagator<'b, 'a, 'tcx:'a+'b> {
     param_env: ParamEnv<'tcx>,
 }
 
-impl<'a, 'b, 'tcx> LayoutOf<ty::Ty<'tcx>> for &'a ConstPropagator<'a, 'b, 'tcx> {
+impl<'a, 'b, 'tcx> LayoutOf for &'a ConstPropagator<'a, 'b, 'tcx> {
+    type Ty = ty::Ty<'tcx>;
     type TyLayout = Result<TyLayout<'tcx>, LayoutError<'tcx>>;
 
     fn layout_of(self, ty: ty::Ty<'tcx>) -> Self::TyLayout {
diff --git a/src/librustc_target/abi/mod.rs b/src/librustc_target/abi/mod.rs
index 8cdc34db2df..b0a53445659 100644
--- a/src/librustc_target/abi/mod.rs
+++ b/src/librustc_target/abi/mod.rs
@@ -757,8 +757,9 @@ impl LayoutDetails {
     }
 }
 
-pub trait LayoutOf<T> {
+pub trait LayoutOf {
+    type Ty;
     type TyLayout;
 
-    fn layout_of(self, ty: T) -> Self::TyLayout;
-}
\ No newline at end of file
+    fn layout_of(self, ty: Self::Ty) -> Self::TyLayout;
+}
diff --git a/src/librustc_trans/context.rs b/src/librustc_trans/context.rs
index 4d781d7280d..44149ec9a4e 100644
--- a/src/librustc_trans/context.rs
+++ b/src/librustc_trans/context.rs
@@ -459,7 +459,8 @@ impl<'a, 'tcx> ty::layout::HasTyCtxt<'tcx> for &'a CodegenCx<'a, 'tcx> {
     }
 }
 
-impl<'a, 'tcx> LayoutOf<Ty<'tcx>> for &'a CodegenCx<'a, 'tcx> {
+impl<'a, 'tcx> LayoutOf for &'a CodegenCx<'a, 'tcx> {
+    type Ty = Ty<'tcx>;
     type TyLayout = TyLayout<'tcx>;
 
     fn layout_of(self, ty: Ty<'tcx>) -> Self::TyLayout {