diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index 9a5db202296..d1a8a9a34e1 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -1519,6 +1519,10 @@ pub trait HasTyCtxt<'tcx>: HasDataLayout { fn tcx<'a>(&'a self) -> TyCtxt<'a, 'tcx, 'tcx>; } +pub trait HasParamEnv<'tcx> { + fn param_env(&self) -> ty::ParamEnv<'tcx>; +} + impl<'a, 'gcx, 'tcx> HasDataLayout for TyCtxt<'a, 'gcx, 'tcx> { fn data_layout(&self) -> &TargetDataLayout { &self.data_layout @@ -1531,6 +1535,12 @@ impl<'a, 'gcx, 'tcx> HasTyCtxt<'gcx> for TyCtxt<'a, 'gcx, 'tcx> { } } +impl<'tcx, C> HasParamEnv<'tcx> for LayoutCx<'tcx, C> { + fn param_env(&self) -> ty::ParamEnv<'tcx> { + self.param_env + } +} + impl<'tcx, T: HasDataLayout> HasDataLayout for LayoutCx<'tcx, T> { fn data_layout(&self) -> &TargetDataLayout { self.tcx.data_layout() @@ -1662,16 +1672,6 @@ impl ty::query::TyCtxtAt<'a, 'tcx, '_> { } } -pub trait HasParamEnv<'tcx> { - fn param_env(&self) -> ty::ParamEnv<'tcx>; -} - -impl<'tcx, C> HasParamEnv<'tcx> for LayoutCx<'tcx, C> { - fn param_env(&self) -> ty::ParamEnv<'tcx> { - self.param_env - } -} - impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx> where C: LayoutOf> + HasTyCtxt<'tcx>, C::TyLayout: MaybeResult>, @@ -1718,9 +1718,10 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx> let tcx = cx.tcx(); let discr_layout = |discr: &Scalar| -> C::TyLayout { let layout = LayoutDetails::scalar(cx, discr.clone()); - MaybeResult::from(Ok( - TyLayout {details: tcx.intern_layout(layout),ty: discr.value.to_ty(tcx)} - )) + MaybeResult::from(Ok(TyLayout { + details: tcx.intern_layout(layout), + ty: discr.value.to_ty(tcx), + })) }; cx.layout_of(match this.ty.sty { @@ -1754,12 +1755,10 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx> } else { tcx.mk_mut_ref(tcx.lifetimes.re_static, nil) }; - return MaybeResult::from( - cx.layout_of(ptr_ty).to_result().map(|mut ptr_layout| { - ptr_layout.ty = this.ty; - ptr_layout - }) - ); + return MaybeResult::from(cx.layout_of(ptr_ty).to_result().map(|mut ptr_layout| { + ptr_layout.ty = this.ty; + ptr_layout + })); } match tcx.struct_tail(pointee).sty { diff --git a/src/librustc_codegen_ssa/traits/mod.rs b/src/librustc_codegen_ssa/traits/mod.rs index 8c336b11a5d..c237cd8bd26 100644 --- a/src/librustc_codegen_ssa/traits/mod.rs +++ b/src/librustc_codegen_ssa/traits/mod.rs @@ -89,6 +89,5 @@ pub trait HasCodegen<'tcx>: Type = Self::Type, Funclet = Self::Funclet, DIScope = Self::DIScope, - > - + HasParamEnv<'tcx>; + >; }