} else {
struct_error(tcx, message)
};
- err.span_label(self.span, self.error.to_string());
+ if !must_error {
+ err.span_label(self.span, self.error.to_string());
+ }
// Skip the last, which is just the environment of the constant. The stacktrace
// is sometimes empty because we create "fake" eval contexts in CTFE to do work
// on constant values.
fn spanned_layout_of(&self, ty: Ty<'tcx>, span: Span) -> Self::TyLayout {
self.tcx.layout_of(ty::ParamEnv::reveal_all().and(ty))
.unwrap_or_else(|e| if let LayoutError::SizeOverflow(_) = e {
- match span {
- Some(span) => self.sess().span_fatal(span, &e.to_string()),
- None => self.sess().fatal(&e.to_string()),
- }
+ self.sess().span_fatal(span, &e.to_string())
} else {
bug!("failed to get layout for `{}`: {}", ty, e)
})
use rustc::mir::traversal;
use rustc::ty;
use rustc::ty::layout::{LayoutOf, HasTyCtxt};
+use syntax_pos::DUMMY_SP;
use super::FunctionCx;
use crate::traits::*;
analyzer.visit_body(mir);
- for (index, ty) in mir.local_decls.iter().map(|l| l.ty).enumerate() {
+ for (index, (ty, span)) in mir.local_decls.iter()
+ .map(|l| (l.ty, l.source_info.span))
+ .enumerate()
+ {
let ty = fx.monomorphize(&ty);
debug!("local {} has type {:?}", index, ty);
- let layout = fx.cx.layout_of(ty);
+ let layout = fx.cx.spanned_layout_of(ty, span);
if fx.cx.is_backend_immediate(layout) {
// These sorts of types are immediates that we can store
// in an Value without an alloca.
}
}
- fn process_place(&mut self,
- place_ref: &mir::PlaceRef<'_, 'tcx>,
- context: PlaceContext,
- location: Location) {
+ fn process_place(
+ &mut self,
+ place_ref: &mir::PlaceRef<'_, 'tcx>,
+ context: PlaceContext,
+ location: Location,
+ ) {
let cx = self.fx.cx;
if let Some(proj) = place_ref.projection {
.projection_ty(cx.tcx(), &proj.elem)
.ty;
let elem_ty = self.fx.monomorphize(&elem_ty);
- if cx.layout_of(elem_ty).is_zst() {
+ let span = if let mir::PlaceBase::Local(index) = place_ref.base {
+ self.fx.mir.local_decls[*index].source_info.span
+ } else {
+ DUMMY_SP
+ };
+ if cx.spanned_layout_of(elem_ty, span).is_zst() {
return;
}
if let mir::ProjectionElem::Field(..) = proj.elem {
- let layout = cx.layout_of(base_ty.ty);
+ let layout = cx.spanned_layout_of(base_ty.ty, span);
if cx.is_backend_immediate(layout) || cx.is_backend_scalar_pair(layout) {
// Recurse with the same context, instead of `Projection`,
// potentially stopping at non-operand projections,
--> $SRC_DIR/libcore/mem/mod.rs:LL:COL
|
LL | intrinsics::size_of::<T>()
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the type `[u8; 18446744073709551615]` is too big for the current architecture
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
::: $DIR/issue-55878.rs:3:26
|
-// normalize-stderr-test "std::option::Option<\[u32; \d+\]>" -> "TYPE"
-// normalize-stderr-test "\[u32; \d+\]" -> "TYPE"
-
// 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" -> ""
#[cfg(target_pointer_width = "32")]
-fn main() {
- let big: Option<[u32; (1<<29)-1]> = None;
-}
+type BIG = Option<[u32; (1<<29)-1]>;
#[cfg(target_pointer_width = "64")]
+type BIG = Option<[u32; (1<<45)-1]>;
+
fn main() {
- let big: Option<[u32; (1<<45)-1]> = None;
+ let big: BIG = None;
+ //~^ ERROR is too big for the current architecture
}
-error: the type `TYPE` is too big for the current architecture
+error: the type `std::option::Option<[u32; 35184372088831]>` is too big for the current architecture
+ --> $DIR/huge-enum.rs:12:9
+ |
+LL | let big: BIG = None;
+ | ^^^
error: aborting due to previous error
fn main() {
let fat: Option<S1M<S1M<S1M<u32>>>> = None;
+ //~^ ERROR the type `S32<S1M<S1M<u32>>>` is too big for the current architecture
+
}
error: the type `SXX<SXX<SXX<u32>>>` is too big for the current architecture
+ --> $DIR/huge-struct.rs:49:9
+ |
+LL | let fat: Option<SXX<SXX<SXX<u32>>>> = None;
+ | ^^^
error: aborting due to previous error
--> $DIR/issue-56762.rs:19:1
|
LL | static MY_TOO_BIG_ARRAY_1: TooBigArray = TooBigArray::new();
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the type `[u8; 2305843009213693951]` is too big for the current architecture
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0080]: the type `[u8; 2305843009213693951]` is too big for the current architecture
--> $DIR/issue-56762.rs:21:1
|
LL | static MY_TOO_BIG_ARRAY_2: [u8; HUGE_SIZE] = [0x00; HUGE_SIZE];
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the type `[u8; 2305843009213693951]` is too big for the current architecture
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors