Skip to content

Commit bdd79b8

Browse files
committed
tweak output and tests
1 parent 387dcff commit bdd79b8

File tree

9 files changed

+42
-24
lines changed

9 files changed

+42
-24
lines changed

src/librustc/mir/interpret/error.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,9 @@ impl<'tcx> ConstEvalErr<'tcx> {
165165
} else {
166166
struct_error(tcx, message)
167167
};
168-
err.span_label(self.span, self.error.to_string());
168+
if !must_error {
169+
err.span_label(self.span, self.error.to_string());
170+
}
169171
// Skip the last, which is just the environment of the constant. The stacktrace
170172
// is sometimes empty because we create "fake" eval contexts in CTFE to do work
171173
// on constant values.

src/librustc_codegen_llvm/context.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -867,10 +867,7 @@ impl LayoutOf for CodegenCx<'ll, 'tcx> {
867867
fn spanned_layout_of(&self, ty: Ty<'tcx>, span: Span) -> Self::TyLayout {
868868
self.tcx.layout_of(ty::ParamEnv::reveal_all().and(ty))
869869
.unwrap_or_else(|e| if let LayoutError::SizeOverflow(_) = e {
870-
match span {
871-
Some(span) => self.sess().span_fatal(span, &e.to_string()),
872-
None => self.sess().fatal(&e.to_string()),
873-
}
870+
self.sess().span_fatal(span, &e.to_string())
874871
} else {
875872
bug!("failed to get layout for `{}`: {}", ty, e)
876873
})

src/librustc_codegen_ssa/mir/analyze.rs

+19-8
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use rustc::mir::visit::{Visitor, PlaceContext, MutatingUseContext, NonMutatingUs
99
use rustc::mir::traversal;
1010
use rustc::ty;
1111
use rustc::ty::layout::{LayoutOf, HasTyCtxt};
12+
use syntax_pos::DUMMY_SP;
1213
use super::FunctionCx;
1314
use crate::traits::*;
1415

@@ -20,10 +21,13 @@ pub fn non_ssa_locals<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
2021

2122
analyzer.visit_body(mir);
2223

23-
for (index, ty) in mir.local_decls.iter().map(|l| l.ty).enumerate() {
24+
for (index, (ty, span)) in mir.local_decls.iter()
25+
.map(|l| (l.ty, l.source_info.span))
26+
.enumerate()
27+
{
2428
let ty = fx.monomorphize(&ty);
2529
debug!("local {} has type {:?}", index, ty);
26-
let layout = fx.cx.layout_of(ty);
30+
let layout = fx.cx.spanned_layout_of(ty, span);
2731
if fx.cx.is_backend_immediate(layout) {
2832
// These sorts of types are immediates that we can store
2933
// in an Value without an alloca.
@@ -93,10 +97,12 @@ impl<Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
9397
}
9498
}
9599

96-
fn process_place(&mut self,
97-
place_ref: &mir::PlaceRef<'_, 'tcx>,
98-
context: PlaceContext,
99-
location: Location) {
100+
fn process_place(
101+
&mut self,
102+
place_ref: &mir::PlaceRef<'_, 'tcx>,
103+
context: PlaceContext,
104+
location: Location,
105+
) {
100106
let cx = self.fx.cx;
101107

102108
if let Some(proj) = place_ref.projection {
@@ -116,12 +122,17 @@ impl<Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
116122
.projection_ty(cx.tcx(), &proj.elem)
117123
.ty;
118124
let elem_ty = self.fx.monomorphize(&elem_ty);
119-
if cx.layout_of(elem_ty).is_zst() {
125+
let span = if let mir::PlaceBase::Local(index) = place_ref.base {
126+
self.fx.mir.local_decls[*index].source_info.span
127+
} else {
128+
DUMMY_SP
129+
};
130+
if cx.spanned_layout_of(elem_ty, span).is_zst() {
120131
return;
121132
}
122133

123134
if let mir::ProjectionElem::Field(..) = proj.elem {
124-
let layout = cx.layout_of(base_ty.ty);
135+
let layout = cx.spanned_layout_of(base_ty.ty, span);
125136
if cx.is_backend_immediate(layout) || cx.is_backend_scalar_pair(layout) {
126137
// Recurse with the same context, instead of `Projection`,
127138
// potentially stopping at non-operand projections,

src/test/ui/consts/issue-55878.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0080]: the type `[u8; 18446744073709551615]` is too big for the current a
22
--> $SRC_DIR/libcore/mem/mod.rs:LL:COL
33
|
44
LL | intrinsics::size_of::<T>()
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ the type `[u8; 18446744073709551615]` is too big for the current architecture
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
::: $DIR/issue-55878.rs:3:26
88
|

src/test/ui/huge-enum.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
// normalize-stderr-test "std::option::Option<\[u32; \d+\]>" -> "TYPE"
2-
// normalize-stderr-test "\[u32; \d+\]" -> "TYPE"
3-
41
// FIXME https://github.com/rust-lang/rust/issues/59774
52
// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> ""
63
// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> ""
74

85
#[cfg(target_pointer_width = "32")]
9-
fn main() {
10-
let big: Option<[u32; (1<<29)-1]> = None;
11-
}
6+
type BIG = Option<[u32; (1<<29)-1]>;
127

138
#[cfg(target_pointer_width = "64")]
9+
type BIG = Option<[u32; (1<<45)-1]>;
10+
1411
fn main() {
15-
let big: Option<[u32; (1<<45)-1]> = None;
12+
let big: BIG = None;
13+
//~^ ERROR is too big for the current architecture
1614
}

src/test/ui/huge-enum.stderr

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
error: the type `TYPE` is too big for the current architecture
1+
error: the type `std::option::Option<[u32; 35184372088831]>` is too big for the current architecture
2+
--> $DIR/huge-enum.rs:12:9
3+
|
4+
LL | let big: BIG = None;
5+
| ^^^
26

37
error: aborting due to previous error
48

src/test/ui/huge-struct.rs

+2
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,6 @@ struct S1M<T> { val: S1k<S1k<T>> }
4747

4848
fn main() {
4949
let fat: Option<S1M<S1M<S1M<u32>>>> = None;
50+
//~^ ERROR the type `S32<S1M<S1M<u32>>>` is too big for the current architecture
51+
5052
}

src/test/ui/huge-struct.stderr

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
error: the type `SXX<SXX<SXX<u32>>>` is too big for the current architecture
2+
--> $DIR/huge-struct.rs:49:9
3+
|
4+
LL | let fat: Option<SXX<SXX<SXX<u32>>>> = None;
5+
| ^^^
26

37
error: aborting due to previous error
48

src/test/ui/issues/issue-56762.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ error[E0080]: the type `[u8; 2305843009213693951]` is too big for the current ar
22
--> $DIR/issue-56762.rs:19:1
33
|
44
LL | static MY_TOO_BIG_ARRAY_1: TooBigArray = TooBigArray::new();
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the type `[u8; 2305843009213693951]` is too big for the current architecture
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66

77
error[E0080]: the type `[u8; 2305843009213693951]` is too big for the current architecture
88
--> $DIR/issue-56762.rs:21:1
99
|
1010
LL | static MY_TOO_BIG_ARRAY_2: [u8; HUGE_SIZE] = [0x00; HUGE_SIZE];
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the type `[u8; 2305843009213693951]` is too big for the current architecture
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212

1313
error: aborting due to 2 previous errors
1414

0 commit comments

Comments
 (0)