fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyLayout {
self.tcx.layout_of(self.param_env.and(ty))
}
+ fn spanned_layout_of(&self, ty: Ty<'tcx>, _: Option<Span>) -> Self::TyLayout {
+ self.layout_of(ty)
+ }
}
impl<'a, 'tcx, T: LateLintPass<'a, 'tcx>> LateContextAndPass<'a, 'tcx, T> {
use syntax::ast::{self, Ident, IntTy, UintTy};
use syntax::attr;
-use syntax_pos::DUMMY_SP;
+use syntax_pos::{DUMMY_SP, Span};
use std::cmp;
use std::fmt;
Ok(layout)
}
+ fn spanned_layout_of(&self, ty: Ty<'tcx>, _: Option<Span>) -> Self::TyLayout {
+ self.layout_of(ty)
+ }
}
impl LayoutOf for LayoutCx<'tcx, ty::query::TyCtxtAt<'tcx>> {
Ok(layout)
}
+ fn spanned_layout_of(&self, ty: Ty<'tcx>, _: Option<Span>) -> Self::TyLayout {
+ self.layout_of(ty)
+ }
}
// Helper (inherent) `layout_of` methods to avoid pushing `LayoutCx` to users.
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};
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> {
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
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)
})
rvalue: &mir::Rvalue<'tcx>,
location: Location) {
debug!("visit_assign(place={:?}, rvalue={:?})", place, rvalue);
+ let mut decl_span = None;
+ if let mir::PlaceBase::Local(local) = &place.base {
+ if let Some(decl) = self.fx.mir.local_decls.get(*local) {
+ decl_span = Some(decl.source_info.span);
+ }
+ }
if let mir::Place {
base: mir::PlaceBase::Local(index),
projection: None,
} = *place {
self.assign(index, location);
- if !self.fx.rvalue_creates_operand(rvalue) {
+ if !self.fx.rvalue_creates_operand(rvalue, decl_span) {
self.not_ssa(index);
}
} else {
use rustc_apfloat::{ieee, Float, Status, Round};
use std::{u128, i128};
use syntax::symbol::sym;
+use syntax::source_map::Span;
use crate::base;
use crate::MemFlags;
}
_ => {
- assert!(self.rvalue_creates_operand(rvalue));
+ assert!(self.rvalue_creates_operand(rvalue, None));
let (mut bx, temp) = self.codegen_rvalue_operand(bx, rvalue);
temp.val.store(&mut bx, dest);
bx
mut bx: Bx,
rvalue: &mir::Rvalue<'tcx>
) -> (Bx, OperandRef<'tcx, Bx::Value>) {
- assert!(self.rvalue_creates_operand(rvalue), "cannot codegen {:?} to operand", rvalue);
+ assert!(
+ self.rvalue_creates_operand(rvalue, None),
+ "cannot codegen {:?} to operand",
+ rvalue,
+ );
match *rvalue {
mir::Rvalue::Cast(ref kind, ref source, mir_cast_ty) => {
}
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
- pub fn rvalue_creates_operand(&self, rvalue: &mir::Rvalue<'tcx>) -> bool {
+ pub fn rvalue_creates_operand(&self, rvalue: &mir::Rvalue<'tcx>, span: Option<Span>) -> bool {
match *rvalue {
mir::Rvalue::Ref(..) |
mir::Rvalue::Len(..) |
mir::Rvalue::Aggregate(..) => {
let ty = rvalue.ty(self.mir, self.cx.tcx());
let ty = self.monomorphize(&ty);
- self.cx.layout_of(ty).is_zst()
+ self.cx.spanned_layout_of(ty, span).is_zst()
+ // self.cx.layout_of(ty).is_zst()
}
}
.layout_of(self.param_env.and(ty))
.map_err(|layout| err_inval!(Layout(layout)).into())
}
+ fn spanned_layout_of(&self, ty: Ty<'tcx>, _: Option<Span>) -> Self::TyLayout {
+ self.layout_of(ty)
+ }
}
impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyLayout {
self.tcx.layout_of(self.param_env.and(ty))
}
+ fn spanned_layout_of(&self, ty: Ty<'tcx>, _: Option<Span>) -> Self::TyLayout {
+ self.layout_of(ty)
+ }
}
impl<'mir, 'tcx> HasDataLayout for ConstPropagator<'mir, 'tcx> {
use rustc::ty::TyCtxt;
use syntax::ast::Attribute;
use syntax::symbol::sym;
+use syntax::source_map::Span;
pub fn test_layout(tcx: TyCtxt<'_>) {
if tcx.features().rustc_attrs {
fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyLayout {
self.tcx.layout_of(self.param_env.and(ty)).unwrap()
}
+ fn spanned_layout_of(&self, ty: Ty<'tcx>, _: Option<Span>) -> Self::TyLayout {
+ self.layout_of(ty)
+ }
}
impl HasTyCtxt<'tcx> for UnwrapLayoutCx<'tcx> {
use rustc_data_structures::newtype_index;
use rustc_data_structures::indexed_vec::{Idx, IndexVec};
use syntax_pos::symbol::{sym, Symbol};
+use syntax_pos::Span;
pub mod call;
type TyLayout;
fn layout_of(&self, ty: Self::Ty) -> Self::TyLayout;
+ fn spanned_layout_of(&self, ty: Self::Ty, span: Option<Span>) -> Self::TyLayout;
}
#[derive(Copy, Clone, PartialEq, Eq)]
error: the type `[u8; N]` is too big for the current architecture
+ --> $DIR/huge-array-simple.rs:12:9
+ |
+LL | let _fat : [u8; (1<<61)+(1<<31)] =
+ | ^^^^
error: aborting due to previous error
-// error-pattern:; 1518600000
-
// FIXME https://github.com/rust-lang/rust/issues/59774
// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> ""
// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> ""
fn generic<T: Copy>(t: T) {
let s: [T; 1518600000] = [t; 1518600000];
+ //~^ ERROR the type `[[u8; 1518599999]; 1518600000]` is too big for the current architecture
}
fn main() {
error: the type `[[u8; 1518599999]; 1518600000]` is too big for the current architecture
+ --> $DIR/huge-array.rs:6:9
+ |
+LL | let s: [T; 1518600000] = [t; 1518600000];
+ | ^
error: aborting due to previous error
error: the type `[usize; N]` is too big for the current architecture
+ --> $DIR/issue-15919.rs:15:9
+ |
+LL | let x = [0usize; 0xffff_ffff_ffff_ffff];
+ | ^
error: aborting due to previous error