Skip to content

Commit 968eb7f

Browse files
committed
code review fixes
1 parent 80d5478 commit 968eb7f

File tree

2 files changed

+19
-21
lines changed

2 files changed

+19
-21
lines changed

src/librustc/ty/layout.rs

+18-19
Original file line numberDiff line numberDiff line change
@@ -1519,6 +1519,10 @@ pub trait HasTyCtxt<'tcx>: HasDataLayout {
15191519
fn tcx<'a>(&'a self) -> TyCtxt<'a, 'tcx, 'tcx>;
15201520
}
15211521

1522+
pub trait HasParamEnv<'tcx> {
1523+
fn param_env(&self) -> ty::ParamEnv<'tcx>;
1524+
}
1525+
15221526
impl<'a, 'gcx, 'tcx> HasDataLayout for TyCtxt<'a, 'gcx, 'tcx> {
15231527
fn data_layout(&self) -> &TargetDataLayout {
15241528
&self.data_layout
@@ -1531,6 +1535,12 @@ impl<'a, 'gcx, 'tcx> HasTyCtxt<'gcx> for TyCtxt<'a, 'gcx, 'tcx> {
15311535
}
15321536
}
15331537

1538+
impl<'tcx, C> HasParamEnv<'tcx> for LayoutCx<'tcx, C> {
1539+
fn param_env(&self) -> ty::ParamEnv<'tcx> {
1540+
self.param_env
1541+
}
1542+
}
1543+
15341544
impl<'tcx, T: HasDataLayout> HasDataLayout for LayoutCx<'tcx, T> {
15351545
fn data_layout(&self) -> &TargetDataLayout {
15361546
self.tcx.data_layout()
@@ -1662,16 +1672,6 @@ impl ty::query::TyCtxtAt<'a, 'tcx, '_> {
16621672
}
16631673
}
16641674

1665-
pub trait HasParamEnv<'tcx> {
1666-
fn param_env(&self) -> ty::ParamEnv<'tcx>;
1667-
}
1668-
1669-
impl<'tcx, C> HasParamEnv<'tcx> for LayoutCx<'tcx, C> {
1670-
fn param_env(&self) -> ty::ParamEnv<'tcx> {
1671-
self.param_env
1672-
}
1673-
}
1674-
16751675
impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
16761676
where C: LayoutOf<Ty = Ty<'tcx>> + HasTyCtxt<'tcx>,
16771677
C::TyLayout: MaybeResult<TyLayout<'tcx>>,
@@ -1718,9 +1718,10 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
17181718
let tcx = cx.tcx();
17191719
let discr_layout = |discr: &Scalar| -> C::TyLayout {
17201720
let layout = LayoutDetails::scalar(cx, discr.clone());
1721-
MaybeResult::from(Ok(
1722-
TyLayout {details: tcx.intern_layout(layout),ty: discr.value.to_ty(tcx)}
1723-
))
1721+
MaybeResult::from(Ok(TyLayout {
1722+
details: tcx.intern_layout(layout),
1723+
ty: discr.value.to_ty(tcx),
1724+
}))
17241725
};
17251726

17261727
cx.layout_of(match this.ty.sty {
@@ -1754,12 +1755,10 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
17541755
} else {
17551756
tcx.mk_mut_ref(tcx.lifetimes.re_static, nil)
17561757
};
1757-
return MaybeResult::from(
1758-
cx.layout_of(ptr_ty).to_result().map(|mut ptr_layout| {
1759-
ptr_layout.ty = this.ty;
1760-
ptr_layout
1761-
})
1762-
);
1758+
return MaybeResult::from(cx.layout_of(ptr_ty).to_result().map(|mut ptr_layout| {
1759+
ptr_layout.ty = this.ty;
1760+
ptr_layout
1761+
}));
17631762
}
17641763

17651764
match tcx.struct_tail(pointee).sty {

src/librustc_codegen_ssa/traits/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,5 @@ pub trait HasCodegen<'tcx>:
8989
Type = Self::Type,
9090
Funclet = Self::Funclet,
9191
DIScope = Self::DIScope,
92-
>
93-
+ HasParamEnv<'tcx>;
92+
>;
9493
}

0 commit comments

Comments
 (0)