Skip to content

Commit 7e14ffb

Browse files
committed
conservative_is_uninhabited implies abi.is_uninhabited
1 parent 0830650 commit 7e14ffb

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/librustc/ty/layout.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,14 @@ fn layout_raw<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
190190

191191
ty::tls::enter_context(&icx, |_| {
192192
let cx = LayoutCx { tcx, param_env };
193-
cx.layout_raw_uncached(ty)
193+
let layout = cx.layout_raw_uncached(ty);
194+
// Type-level uninhabitedness should always imply ABI uninhabitedness.
195+
if let Ok(layout) = layout {
196+
if ty.conservative_is_uninhabited(tcx) {
197+
assert!(layout.abi.is_uninhabited());
198+
}
199+
}
200+
layout
194201
})
195202
})
196203
}
@@ -205,12 +212,11 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) {
205212
#[derive(Copy, Clone)]
206213
pub struct LayoutCx<'tcx, C> {
207214
pub tcx: C,
208-
pub param_env: ty::ParamEnv<'tcx>
215+
pub param_env: ty::ParamEnv<'tcx>,
209216
}
210217

211218
impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
212-
fn layout_raw_uncached(self, ty: Ty<'tcx>)
213-
-> Result<&'tcx LayoutDetails, LayoutError<'tcx>> {
219+
fn layout_raw_uncached(self, ty: Ty<'tcx>) -> Result<&'tcx LayoutDetails, LayoutError<'tcx>> {
214220
let tcx = self.tcx;
215221
let param_env = self.param_env;
216222
let dl = self.data_layout();

0 commit comments

Comments
 (0)