Skip to content

Commit 51e1c64

Browse files
committed
conservative_is_uninhabited implies abi.is_uninhabited
1 parent d065a49 commit 51e1c64

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
@@ -191,7 +191,14 @@ fn layout_raw<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
191191

192192
ty::tls::enter_context(&icx, |_| {
193193
let cx = LayoutCx { tcx, param_env };
194-
cx.layout_raw_uncached(ty)
194+
let layout = cx.layout_raw_uncached(ty);
195+
// Type-level uninhabitedness should always imply ABI uninhabitedness.
196+
if let Ok(layout) = layout {
197+
if ty.conservative_is_uninhabited(tcx) {
198+
assert!(layout.abi.is_uninhabited());
199+
}
200+
}
201+
layout
195202
})
196203
})
197204
}
@@ -205,12 +212,11 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) {
205212

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)