]> git.lizzy.rs Git - rust.git/commitdiff
Fix a panic on type size overflow
authorbjorn3 <bjorn3@users.noreply.github.com>
Thu, 1 Aug 2019 12:58:27 +0000 (14:58 +0200)
committerbjorn3 <bjorn3@users.noreply.github.com>
Tue, 13 Aug 2019 17:40:48 +0000 (19:40 +0200)
src/common.rs

index 46dcb5aad0354aad46a34fd5de77b1baf5a34b94..5cdbd9bd79ea1186aecc2acafbd64a2eba666ceb 100644 (file)
@@ -181,7 +181,12 @@ impl<'a, 'tcx: 'a, B: Backend> LayoutOf for FunctionCx<'a, 'tcx, B> {
 
     fn layout_of(&self, ty: Ty<'tcx>) -> TyLayout<'tcx> {
         let ty = self.monomorphize(&ty);
-        self.tcx.layout_of(ParamEnv::reveal_all().and(&ty)).unwrap()
+        self.tcx.layout_of(ParamEnv::reveal_all().and(&ty))
+            .unwrap_or_else(|e| if let layout::LayoutError::SizeOverflow(_) = e {
+                self.tcx.sess.fatal(&e.to_string())
+            } else {
+                bug!("failed to get layout for `{}`: {}", ty, e)
+            })
     }
 }