tweak output and tests

This commit is contained in:
Esteban Küber 2019-08-04 12:23:05 -07:00
parent 387dcff796
commit bdd79b849e
9 changed files with 42 additions and 24 deletions

View File

@ -165,7 +165,9 @@ impl<'tcx> ConstEvalErr<'tcx> {
} else { } else {
struct_error(tcx, message) 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 // 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 // is sometimes empty because we create "fake" eval contexts in CTFE to do work
// on constant values. // on constant values.

View File

@ -867,10 +867,7 @@ impl LayoutOf for CodegenCx<'ll, 'tcx> {
fn spanned_layout_of(&self, ty: Ty<'tcx>, span: Span) -> Self::TyLayout { fn spanned_layout_of(&self, ty: Ty<'tcx>, span: Span) -> Self::TyLayout {
self.tcx.layout_of(ty::ParamEnv::reveal_all().and(ty)) self.tcx.layout_of(ty::ParamEnv::reveal_all().and(ty))
.unwrap_or_else(|e| if let LayoutError::SizeOverflow(_) = e { .unwrap_or_else(|e| if let LayoutError::SizeOverflow(_) = e {
match span { self.sess().span_fatal(span, &e.to_string())
Some(span) => self.sess().span_fatal(span, &e.to_string()),
None => self.sess().fatal(&e.to_string()),
}
} else { } else {
bug!("failed to get layout for `{}`: {}", ty, e) bug!("failed to get layout for `{}`: {}", ty, e)
}) })

View File

@ -9,6 +9,7 @@ use rustc::mir::visit::{Visitor, PlaceContext, MutatingUseContext, NonMutatingUs
use rustc::mir::traversal; use rustc::mir::traversal;
use rustc::ty; use rustc::ty;
use rustc::ty::layout::{LayoutOf, HasTyCtxt}; use rustc::ty::layout::{LayoutOf, HasTyCtxt};
use syntax_pos::DUMMY_SP;
use super::FunctionCx; use super::FunctionCx;
use crate::traits::*; use crate::traits::*;
@ -20,10 +21,13 @@ pub fn non_ssa_locals<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
analyzer.visit_body(mir); 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); let ty = fx.monomorphize(&ty);
debug!("local {} has type {:?}", index, 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) { if fx.cx.is_backend_immediate(layout) {
// These sorts of types are immediates that we can store // These sorts of types are immediates that we can store
// in an Value without an alloca. // in an Value without an alloca.
@ -93,10 +97,12 @@ impl<Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
} }
} }
fn process_place(&mut self, fn process_place(
place_ref: &mir::PlaceRef<'_, 'tcx>, &mut self,
context: PlaceContext, place_ref: &mir::PlaceRef<'_, 'tcx>,
location: Location) { context: PlaceContext,
location: Location,
) {
let cx = self.fx.cx; let cx = self.fx.cx;
if let Some(proj) = place_ref.projection { if let Some(proj) = place_ref.projection {
@ -116,12 +122,17 @@ impl<Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
.projection_ty(cx.tcx(), &proj.elem) .projection_ty(cx.tcx(), &proj.elem)
.ty; .ty;
let elem_ty = self.fx.monomorphize(&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; return;
} }
if let mir::ProjectionElem::Field(..) = proj.elem { 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) { if cx.is_backend_immediate(layout) || cx.is_backend_scalar_pair(layout) {
// Recurse with the same context, instead of `Projection`, // Recurse with the same context, instead of `Projection`,
// potentially stopping at non-operand projections, // potentially stopping at non-operand projections,

View File

@ -2,7 +2,7 @@ error[E0080]: the type `[u8; 18446744073709551615]` is too big for the current a
--> $SRC_DIR/libcore/mem/mod.rs:LL:COL --> $SRC_DIR/libcore/mem/mod.rs:LL:COL
| |
LL | intrinsics::size_of::<T>() LL | intrinsics::size_of::<T>()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ the type `[u8; 18446744073709551615]` is too big for the current architecture | ^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
::: $DIR/issue-55878.rs:3:26 ::: $DIR/issue-55878.rs:3:26
| |

View File

@ -1,16 +1,14 @@
// normalize-stderr-test "std::option::Option<\[u32; \d+\]>" -> "TYPE"
// normalize-stderr-test "\[u32; \d+\]" -> "TYPE"
// FIXME https://github.com/rust-lang/rust/issues/59774 // FIXME https://github.com/rust-lang/rust/issues/59774
// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> "" // normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> ""
// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> "" // normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> ""
#[cfg(target_pointer_width = "32")] #[cfg(target_pointer_width = "32")]
fn main() { type BIG = Option<[u32; (1<<29)-1]>;
let big: Option<[u32; (1<<29)-1]> = None;
}
#[cfg(target_pointer_width = "64")] #[cfg(target_pointer_width = "64")]
type BIG = Option<[u32; (1<<45)-1]>;
fn main() { fn main() {
let big: Option<[u32; (1<<45)-1]> = None; let big: BIG = None;
//~^ ERROR is too big for the current architecture
} }

View File

@ -1,4 +1,8 @@
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 error: aborting due to previous error

View File

@ -47,4 +47,6 @@ struct S1M<T> { val: S1k<S1k<T>> }
fn main() { fn main() {
let fat: Option<S1M<S1M<S1M<u32>>>> = None; let fat: Option<S1M<S1M<S1M<u32>>>> = None;
//~^ ERROR the type `S32<S1M<S1M<u32>>>` is too big for the current architecture
} }

View File

@ -1,4 +1,8 @@
error: the type `SXX<SXX<SXX<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 error: aborting due to previous error

View File

@ -2,13 +2,13 @@ error[E0080]: the type `[u8; 2305843009213693951]` is too big for the current ar
--> $DIR/issue-56762.rs:19:1 --> $DIR/issue-56762.rs:19:1
| |
LL | static MY_TOO_BIG_ARRAY_1: TooBigArray = TooBigArray::new(); 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 error[E0080]: the type `[u8; 2305843009213693951]` is too big for the current architecture
--> $DIR/issue-56762.rs:21:1 --> $DIR/issue-56762.rs:21:1
| |
LL | static MY_TOO_BIG_ARRAY_2: [u8; HUGE_SIZE] = [0x00; HUGE_SIZE]; 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 error: aborting due to 2 previous errors