diff options
| author | varkor <github@varkor.com> | 2018-10-16 21:36:43 +0100 |
|---|---|---|
| committer | varkor <github@varkor.com> | 2018-12-11 11:18:55 +0000 |
| commit | 51e1c6437e64cdf7fa6c75a3bfb2bb3f57d7313b (patch) | |
| tree | 6e710f2003d54754d8decd74c1d8ba4b79cbf224 /src | |
| parent | d065a499417e03ac8e3ab0f48aeddbe13741a2b4 (diff) | |
| download | rust-51e1c6437e64cdf7fa6c75a3bfb2bb3f57d7313b.tar.gz rust-51e1c6437e64cdf7fa6c75a3bfb2bb3f57d7313b.zip | |
conservative_is_uninhabited implies abi.is_uninhabited
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/ty/layout.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index da3c00f5e08..c210372c4e7 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -191,7 +191,14 @@ fn layout_raw<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty::tls::enter_context(&icx, |_| { let cx = LayoutCx { tcx, param_env }; - cx.layout_raw_uncached(ty) + let layout = cx.layout_raw_uncached(ty); + // Type-level uninhabitedness should always imply ABI uninhabitedness. + if let Ok(layout) = layout { + if ty.conservative_is_uninhabited(tcx) { + assert!(layout.abi.is_uninhabited()); + } + } + layout }) }) } @@ -205,12 +212,11 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) { pub struct LayoutCx<'tcx, C> { pub tcx: C, - pub param_env: ty::ParamEnv<'tcx> + pub param_env: ty::ParamEnv<'tcx>, } impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { - fn layout_raw_uncached(&self, ty: Ty<'tcx>) - -> Result<&'tcx LayoutDetails, LayoutError<'tcx>> { + fn layout_raw_uncached(&self, ty: Ty<'tcx>) -> Result<&'tcx LayoutDetails, LayoutError<'tcx>> { let tcx = self.tcx; let param_env = self.param_env; let dl = self.data_layout(); |
