1
Fork 0

Point to local place span on "type too big" error

This commit is contained in:
Esteban Küber 2019-08-03 15:59:25 -07:00
parent 2c5684208c
commit db099fb491
14 changed files with 65 additions and 9 deletions

View file

@ -30,6 +30,7 @@ use std::iter;
use std::str;
use std::sync::Arc;
use syntax::symbol::LocalInternedString;
use syntax::source_map::Span;
use crate::abi::Abi;
/// There is one `CodegenCx` per compilation unit. Each one has its own LLVM
@ -860,9 +861,16 @@ impl LayoutOf for CodegenCx<'ll, 'tcx> {
type TyLayout = TyLayout<'tcx>;
fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyLayout {
self.spanned_layout_of(ty, None)
}
fn spanned_layout_of(&self, ty: Ty<'tcx>, span: Option<Span>) -> Self::TyLayout {
self.tcx.layout_of(ty::ParamEnv::reveal_all().and(ty))
.unwrap_or_else(|e| if let LayoutError::SizeOverflow(_) = e {
self.sess().fatal(&e.to_string())
match span {
Some(span) => self.sess().span_fatal(span, &e.to_string()),
None => self.sess().fatal(&e.to_string()),
}
} else {
bug!("failed to get layout for `{}`: {}", ty, e)
})