Skip to content

Commit 43d13e2

Browse files
authored
Rollup merge of #79158 - lcnr:lazy-norm-coerce, r=oli-obk
type is too big -> values of the type are too big strictly speaking, `[u8; usize::MAX]` or even `[[[u128; usize::MAX]; usize::MAX]; usize::MAX]` are absolutely fine types as long as you don't try to deal with any values of it. This error message seems to cause some confusion imo, for example in #79135 (comment) so I would prefer us to be more precise here. See the added test case which uses one of these types without causing an error. r? ``@oli-obk``
2 parents 5a9104f + 88584d5 commit 43d13e2

19 files changed

+33
-19
lines changed

compiler/rustc_middle/src/ty/layout.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ impl<'tcx> fmt::Display for LayoutError<'tcx> {
176176
match *self {
177177
LayoutError::Unknown(ty) => write!(f, "the type `{}` has an unknown layout", ty),
178178
LayoutError::SizeOverflow(ty) => {
179-
write!(f, "the type `{}` is too big for the current architecture", ty)
179+
write!(f, "values of the type `{}` are too big for the current architecture", ty)
180180
}
181181
}
182182
}

compiler/rustc_trait_selection/src/traits/query/normalize.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> {
9797
self.infcx.tcx
9898
}
9999

100+
#[instrument(skip(self))]
100101
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
101102
if !ty.has_projections() {
102103
return ty;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// normalize-stderr-64bit "18446744073709551615" -> "SIZE"
22
// normalize-stderr-32bit "4294967295" -> "SIZE"
33

4-
// error-pattern: is too big for the current architecture
4+
// error-pattern: are too big for the current architecture
55
fn main() {
66
println!("Size: {}", std::mem::size_of::<[u8; std::u64::MAX as usize]>());
77
}

src/test/ui/huge-array-simple-32.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: the type `[u8; 2147516416]` is too big for the current architecture
1+
error: values of the type `[u8; 2147516416]` are too big for the current architecture
22
--> $DIR/huge-array-simple-32.rs:10:9
33
|
44
LL | let _fat: [u8; (1<<31)+(1<<15)] =

src/test/ui/huge-array-simple-64.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: the type `[u8; 2305843011361177600]` is too big for the current architecture
1+
error: values of the type `[u8; 2305843011361177600]` are too big for the current architecture
22
--> $DIR/huge-array-simple-64.rs:10:9
33
|
44
LL | let _fat: [u8; (1<<61)+(1<<31)] =

src/test/ui/huge-array.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
fn generic<T: Copy>(t: T) {
88
let s: [T; 1518600000] = [t; 1518600000];
9-
//~^ ERROR the type `[[u8; 1518599999]; 1518600000]` is too big for the current architecture
9+
//~^ ERROR values of the type `[[u8; 1518599999]; 1518600000]` are too big
1010
}
1111

1212
fn main() {

src/test/ui/huge-array.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: the type `[[u8; 1518599999]; 1518600000]` is too big for the current architecture
1+
error: values of the type `[[u8; 1518599999]; 1518600000]` are too big for the current architecture
22
--> $DIR/huge-array.rs:8:9
33
|
44
LL | let s: [T; 1518600000] = [t; 1518600000];

src/test/ui/huge-enum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ type BIG = Option<[u32; (1<<45)-1]>;
1414

1515
fn main() {
1616
let big: BIG = None;
17-
//~^ ERROR is too big for the current architecture
17+
//~^ ERROR are too big for the current architecture
1818
}

src/test/ui/huge-enum.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: the type `Option<TYPE>` is too big for the current architecture
1+
error: values of the type `Option<TYPE>` are too big for the current architecture
22
--> $DIR/huge-enum.rs:16:9
33
|
44
LL | let big: BIG = None;

src/test/ui/huge-struct.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@ struct S1M<T> { val: S1k<S1k<T>> }
4848

4949
fn main() {
5050
let fat: Option<S1M<S1M<S1M<u32>>>> = None;
51-
//~^ ERROR is too big for the current architecture
51+
//~^ ERROR are too big for the current architecture
5252

5353
}

0 commit comments

Comments
 (0)