Point to local place span on "type too big" error
This commit is contained in:
@@ -6,6 +6,7 @@ use crate::type_::Type;
|
||||
use crate::type_of::LayoutLlvmExt;
|
||||
use crate::value::Value;
|
||||
use syntax::symbol::LocalInternedString;
|
||||
use syntax::source_map::Span;
|
||||
use rustc_codegen_ssa::common::{IntPredicate, TypeKind, RealPredicate};
|
||||
use rustc_codegen_ssa::MemFlags;
|
||||
use libc::{c_uint, c_char};
|
||||
@@ -90,6 +91,9 @@ impl ty::layout::LayoutOf for Builder<'_, '_, 'tcx> {
|
||||
fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyLayout {
|
||||
self.cx.layout_of(ty)
|
||||
}
|
||||
fn spanned_layout_of(&self, ty: Ty<'tcx>, _: Option<Span>) -> Self::TyLayout {
|
||||
self.cx.layout_of(ty)
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for Builder<'_, 'll, 'tcx> {
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user