diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2019-08-03 15:59:25 -0700 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2019-08-03 21:59:51 -0700 |
| commit | db099fb491fa2e713047af4f22d4139a71a21dbc (patch) | |
| tree | cb001370005afb2792cf1eaa048e0e5634f8a3a9 /src/librustc_codegen_llvm | |
| parent | 2c5684208c6f951b2cbe90df26a6691a95099e93 (diff) | |
| download | rust-db099fb491fa2e713047af4f22d4139a71a21dbc.tar.gz rust-db099fb491fa2e713047af4f22d4139a71a21dbc.zip | |
Point to local place span on "type too big" error
Diffstat (limited to 'src/librustc_codegen_llvm')
| -rw-r--r-- | src/librustc_codegen_llvm/builder.rs | 4 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/context.rs | 10 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/librustc_codegen_llvm/builder.rs b/src/librustc_codegen_llvm/builder.rs index 894e5c2fd3d..c01ba728034 100644 --- a/src/librustc_codegen_llvm/builder.rs +++ b/src/librustc_codegen_llvm/builder.rs @@ -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> { diff --git a/src/librustc_codegen_llvm/context.rs b/src/librustc_codegen_llvm/context.rs index 2b68eb53a4a..18d82c27d8c 100644 --- a/src/librustc_codegen_llvm/context.rs +++ b/src/librustc_codegen_llvm/context.rs @@ -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) }) |
