Skip to content

Commit 7a51476

Browse files
committed
rustc_target: move LayoutOf's type parameter to an associated type.
1 parent 3bd7efa commit 7a51476

File tree

6 files changed

+21
-13
lines changed

6 files changed

+21
-13
lines changed

src/librustc/lint/context.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,8 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
657657
}
658658
}
659659

660-
impl<'a, 'tcx> LayoutOf<Ty<'tcx>> for &'a LateContext<'a, 'tcx> {
660+
impl<'a, 'tcx> LayoutOf for &'a LateContext<'a, 'tcx> {
661+
type Ty = Ty<'tcx>;
661662
type TyLayout = Result<TyLayout<'tcx>, LayoutError<'tcx>>;
662663

663664
fn layout_of(self, ty: Ty<'tcx>) -> Self::TyLayout {

src/librustc/ty/layout.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -1371,7 +1371,8 @@ impl<T, E> MaybeResult<T> for Result<T, E> {
13711371
}
13721372
}
13731373

1374-
impl<'a, 'tcx> LayoutOf<Ty<'tcx>> for LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
1374+
impl<'a, 'tcx> LayoutOf for LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
1375+
type Ty = Ty<'tcx>;
13751376
type TyLayout = Result<TyLayout<'tcx>, LayoutError<'tcx>>;
13761377

13771378
/// 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>> {
13971398
}
13981399
}
13991400

1400-
impl<'a, 'tcx> LayoutOf<Ty<'tcx>> for LayoutCx<'tcx, ty::maps::TyCtxtAt<'a, 'tcx, 'tcx>> {
1401+
impl<'a, 'tcx> LayoutOf for LayoutCx<'tcx, ty::maps::TyCtxtAt<'a, 'tcx, 'tcx>> {
1402+
type Ty = Ty<'tcx>;
14011403
type TyLayout = Result<TyLayout<'tcx>, LayoutError<'tcx>>;
14021404

14031405
/// Computes the layout of a type. Note that this implicitly
@@ -1458,7 +1460,7 @@ impl<'a, 'tcx> ty::maps::TyCtxtAt<'a, 'tcx, 'tcx> {
14581460

14591461
impl<'a, 'tcx> TyLayout<'tcx> {
14601462
pub fn for_variant<C>(&self, cx: C, variant_index: usize) -> Self
1461-
where C: LayoutOf<Ty<'tcx>> + HasTyCtxt<'tcx>,
1463+
where C: LayoutOf<Ty = Ty<'tcx>> + HasTyCtxt<'tcx>,
14621464
C::TyLayout: MaybeResult<TyLayout<'tcx>>
14631465
{
14641466
let details = match self.variants {
@@ -1495,7 +1497,7 @@ impl<'a, 'tcx> TyLayout<'tcx> {
14951497
}
14961498

14971499
pub fn field<C>(&self, cx: C, i: usize) -> C::TyLayout
1498-
where C: LayoutOf<Ty<'tcx>> + HasTyCtxt<'tcx>,
1500+
where C: LayoutOf<Ty = Ty<'tcx>> + HasTyCtxt<'tcx>,
14991501
C::TyLayout: MaybeResult<TyLayout<'tcx>>
15001502
{
15011503
let tcx = cx.tcx();
@@ -1623,7 +1625,7 @@ impl<'a, 'tcx> TyLayout<'tcx> {
16231625
// FIXME(eddyb) traverse already optimized enums.
16241626
fn find_niche<C>(&self, cx: C, count: u128)
16251627
-> Result<Option<(Size, Scalar, u128)>, LayoutError<'tcx>>
1626-
where C: LayoutOf<Ty<'tcx>, TyLayout = Result<Self, LayoutError<'tcx>>> +
1628+
where C: LayoutOf<Ty = Ty<'tcx>, TyLayout = Result<Self, LayoutError<'tcx>>> +
16271629
HasTyCtxt<'tcx>
16281630
{
16291631
let scalar_component = |scalar: &Scalar, offset| {

src/librustc_mir/interpret/eval_context.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ impl<'c, 'b, 'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> layout::HasTyCtxt<'tcx>
162162
}
163163
}
164164

165-
impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> LayoutOf<Ty<'tcx>> for &'a EvalContext<'a, 'mir, 'tcx, M> {
165+
impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> LayoutOf for &'a EvalContext<'a, 'mir, 'tcx, M> {
166+
type Ty = Ty<'tcx>;
166167
type TyLayout = EvalResult<'tcx, TyLayout<'tcx>>;
167168

168169
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
171172
}
172173
}
173174

174-
impl<'c, 'b, 'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> LayoutOf<Ty<'tcx>>
175+
impl<'c, 'b, 'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> LayoutOf
175176
for &'c &'b mut EvalContext<'a, 'mir, 'tcx, M> {
177+
type Ty = Ty<'tcx>;
176178
type TyLayout = EvalResult<'tcx, TyLayout<'tcx>>;
177179

178180
#[inline]

src/librustc_mir/transform/const_prop.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ struct ConstPropagator<'b, 'a, 'tcx:'a+'b> {
7272
param_env: ParamEnv<'tcx>,
7373
}
7474

75-
impl<'a, 'b, 'tcx> LayoutOf<ty::Ty<'tcx>> for &'a ConstPropagator<'a, 'b, 'tcx> {
75+
impl<'a, 'b, 'tcx> LayoutOf for &'a ConstPropagator<'a, 'b, 'tcx> {
76+
type Ty = ty::Ty<'tcx>;
7677
type TyLayout = Result<TyLayout<'tcx>, LayoutError<'tcx>>;
7778

7879
fn layout_of(self, ty: ty::Ty<'tcx>) -> Self::TyLayout {

src/librustc_target/abi/mod.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -757,8 +757,9 @@ impl LayoutDetails {
757757
}
758758
}
759759

760-
pub trait LayoutOf<T> {
760+
pub trait LayoutOf {
761+
type Ty;
761762
type TyLayout;
762763

763-
fn layout_of(self, ty: T) -> Self::TyLayout;
764-
}
764+
fn layout_of(self, ty: Self::Ty) -> Self::TyLayout;
765+
}

src/librustc_trans/context.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,8 @@ impl<'a, 'tcx> ty::layout::HasTyCtxt<'tcx> for &'a CodegenCx<'a, 'tcx> {
459459
}
460460
}
461461

462-
impl<'a, 'tcx> LayoutOf<Ty<'tcx>> for &'a CodegenCx<'a, 'tcx> {
462+
impl<'a, 'tcx> LayoutOf for &'a CodegenCx<'a, 'tcx> {
463+
type Ty = Ty<'tcx>;
463464
type TyLayout = TyLayout<'tcx>;
464465

465466
fn layout_of(self, ty: Ty<'tcx>) -> Self::TyLayout {

0 commit comments

Comments
 (0)