Skip to content

Commit 6f23a05

Browse files
committed
Fix a panic on type size overflow
1 parent 70fbca2 commit 6f23a05

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/common.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,12 @@ impl<'a, 'tcx: 'a, B: Backend> LayoutOf for FunctionCx<'a, 'tcx, B> {
181181

182182
fn layout_of(&self, ty: Ty<'tcx>) -> TyLayout<'tcx> {
183183
let ty = self.monomorphize(&ty);
184-
self.tcx.layout_of(ParamEnv::reveal_all().and(&ty)).unwrap()
184+
self.tcx.layout_of(ParamEnv::reveal_all().and(&ty))
185+
.unwrap_or_else(|e| if let layout::LayoutError::SizeOverflow(_) = e {
186+
self.tcx.sess.fatal(&e.to_string())
187+
} else {
188+
bug!("failed to get layout for `{}`: {}", ty, e)
189+
})
185190
}
186191
}
187192

0 commit comments

Comments
 (0)