From dcc194ce2fb53555baf4bc16e5cacb3b5e1911b1 Mon Sep 17 00:00:00 2001 From: Bastian Kauschke Date: Mon, 16 Nov 2020 10:48:31 +0100 Subject: [PATCH 1/2] instrument `QueryNormalizer::fold_ty` --- compiler/rustc_trait_selection/src/traits/query/normalize.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/rustc_trait_selection/src/traits/query/normalize.rs b/compiler/rustc_trait_selection/src/traits/query/normalize.rs index 42a598ce3a008..bcd3d37ae6747 100644 --- a/compiler/rustc_trait_selection/src/traits/query/normalize.rs +++ b/compiler/rustc_trait_selection/src/traits/query/normalize.rs @@ -97,6 +97,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> { self.infcx.tcx } + #[instrument(skip(self))] fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { if !ty.has_projections() { return ty; From 88584d5800247f4040a45637a88034ddaadb1a9a Mon Sep 17 00:00:00 2001 From: Bastian Kauschke Date: Wed, 18 Nov 2020 10:42:49 +0100 Subject: [PATCH 2/2] change error for `LayoutErr::SizeOverflow` --- compiler/rustc_middle/src/ty/layout.rs | 2 +- src/test/compile-fail/consts/issue-55878.rs | 2 +- src/test/ui/huge-array-simple-32.stderr | 2 +- src/test/ui/huge-array-simple-64.stderr | 2 +- src/test/ui/huge-array.rs | 2 +- src/test/ui/huge-array.stderr | 2 +- src/test/ui/huge-enum.rs | 2 +- src/test/ui/huge-enum.stderr | 2 +- src/test/ui/huge-struct.rs | 2 +- src/test/ui/huge-struct.stderr | 2 +- src/test/ui/issues/issue-15919-32.stderr | 2 +- src/test/ui/issues/issue-15919-64.stderr | 2 +- src/test/ui/issues/issue-17913.stderr | 2 +- src/test/ui/issues/issue-56762.rs | 4 ++-- src/test/ui/issues/issue-56762.stderr | 4 ++-- src/test/ui/layout/big-type-no-err.rs | 13 +++++++++++++ .../ui/lint/issue-69485-var-size-diffs-too-large.rs | 2 +- .../issue-69485-var-size-diffs-too-large.stderr | 2 +- 18 files changed, 32 insertions(+), 19 deletions(-) create mode 100644 src/test/ui/layout/big-type-no-err.rs diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index 1e93c3650b890..64264ff157c60 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -176,7 +176,7 @@ impl<'tcx> fmt::Display for LayoutError<'tcx> { match *self { LayoutError::Unknown(ty) => write!(f, "the type `{}` has an unknown layout", ty), LayoutError::SizeOverflow(ty) => { - write!(f, "the type `{}` is too big for the current architecture", ty) + write!(f, "values of the type `{}` are too big for the current architecture", ty) } } } diff --git a/src/test/compile-fail/consts/issue-55878.rs b/src/test/compile-fail/consts/issue-55878.rs index aa1dd58d2463d..541befa7b1310 100644 --- a/src/test/compile-fail/consts/issue-55878.rs +++ b/src/test/compile-fail/consts/issue-55878.rs @@ -1,7 +1,7 @@ // normalize-stderr-64bit "18446744073709551615" -> "SIZE" // normalize-stderr-32bit "4294967295" -> "SIZE" -// error-pattern: is too big for the current architecture +// error-pattern: are too big for the current architecture fn main() { println!("Size: {}", std::mem::size_of::<[u8; std::u64::MAX as usize]>()); } diff --git a/src/test/ui/huge-array-simple-32.stderr b/src/test/ui/huge-array-simple-32.stderr index d734a9689e05c..31e120df626de 100644 --- a/src/test/ui/huge-array-simple-32.stderr +++ b/src/test/ui/huge-array-simple-32.stderr @@ -1,4 +1,4 @@ -error: the type `[u8; 2147516416]` is too big for the current architecture +error: values of the type `[u8; 2147516416]` are too big for the current architecture --> $DIR/huge-array-simple-32.rs:10:9 | LL | let _fat: [u8; (1<<31)+(1<<15)] = diff --git a/src/test/ui/huge-array-simple-64.stderr b/src/test/ui/huge-array-simple-64.stderr index 791baa8468747..c5d3fe85d0d83 100644 --- a/src/test/ui/huge-array-simple-64.stderr +++ b/src/test/ui/huge-array-simple-64.stderr @@ -1,4 +1,4 @@ -error: the type `[u8; 2305843011361177600]` is too big for the current architecture +error: values of the type `[u8; 2305843011361177600]` are too big for the current architecture --> $DIR/huge-array-simple-64.rs:10:9 | LL | let _fat: [u8; (1<<61)+(1<<31)] = diff --git a/src/test/ui/huge-array.rs b/src/test/ui/huge-array.rs index 846380586a009..3070801f86576 100644 --- a/src/test/ui/huge-array.rs +++ b/src/test/ui/huge-array.rs @@ -6,7 +6,7 @@ fn generic(t: T) { let s: [T; 1518600000] = [t; 1518600000]; - //~^ ERROR the type `[[u8; 1518599999]; 1518600000]` is too big for the current architecture + //~^ ERROR values of the type `[[u8; 1518599999]; 1518600000]` are too big } fn main() { diff --git a/src/test/ui/huge-array.stderr b/src/test/ui/huge-array.stderr index 23d9e87ae0054..817458b73e47b 100644 --- a/src/test/ui/huge-array.stderr +++ b/src/test/ui/huge-array.stderr @@ -1,4 +1,4 @@ -error: the type `[[u8; 1518599999]; 1518600000]` is too big for the current architecture +error: values of the type `[[u8; 1518599999]; 1518600000]` are too big for the current architecture --> $DIR/huge-array.rs:8:9 | LL | let s: [T; 1518600000] = [t; 1518600000]; diff --git a/src/test/ui/huge-enum.rs b/src/test/ui/huge-enum.rs index 8a713c3a26eda..39ea6e11b1ff7 100644 --- a/src/test/ui/huge-enum.rs +++ b/src/test/ui/huge-enum.rs @@ -14,5 +14,5 @@ type BIG = Option<[u32; (1<<45)-1]>; fn main() { let big: BIG = None; - //~^ ERROR is too big for the current architecture + //~^ ERROR are too big for the current architecture } diff --git a/src/test/ui/huge-enum.stderr b/src/test/ui/huge-enum.stderr index a069c37b80a21..a1456e1a8ab0a 100644 --- a/src/test/ui/huge-enum.stderr +++ b/src/test/ui/huge-enum.stderr @@ -1,4 +1,4 @@ -error: the type `Option` is too big for the current architecture +error: values of the type `Option` are too big for the current architecture --> $DIR/huge-enum.rs:16:9 | LL | let big: BIG = None; diff --git a/src/test/ui/huge-struct.rs b/src/test/ui/huge-struct.rs index 71169a1104798..02f38d860b496 100644 --- a/src/test/ui/huge-struct.rs +++ b/src/test/ui/huge-struct.rs @@ -48,6 +48,6 @@ struct S1M { val: S1k> } fn main() { let fat: Option>>> = None; - //~^ ERROR is too big for the current architecture + //~^ ERROR are too big for the current architecture } diff --git a/src/test/ui/huge-struct.stderr b/src/test/ui/huge-struct.stderr index 72e32a8593b18..f0ee88e595539 100644 --- a/src/test/ui/huge-struct.stderr +++ b/src/test/ui/huge-struct.stderr @@ -1,4 +1,4 @@ -error: the type `SXX>>` is too big for the current architecture +error: values of the type `SXX>>` are too big for the current architecture --> $DIR/huge-struct.rs:50:9 | LL | let fat: Option>>> = None; diff --git a/src/test/ui/issues/issue-15919-32.stderr b/src/test/ui/issues/issue-15919-32.stderr index 8411313fc81b3..133637f9a058b 100644 --- a/src/test/ui/issues/issue-15919-32.stderr +++ b/src/test/ui/issues/issue-15919-32.stderr @@ -1,4 +1,4 @@ -error: the type `[usize; 4294967295]` is too big for the current architecture +error: values of the type `[usize; 4294967295]` are too big for the current architecture --> $DIR/issue-15919-32.rs:9:9 | LL | let x = [0usize; 0xffff_ffff]; diff --git a/src/test/ui/issues/issue-15919-64.stderr b/src/test/ui/issues/issue-15919-64.stderr index f624c96ce84da..193b823035c09 100644 --- a/src/test/ui/issues/issue-15919-64.stderr +++ b/src/test/ui/issues/issue-15919-64.stderr @@ -1,4 +1,4 @@ -error: the type `[usize; 18446744073709551615]` is too big for the current architecture +error: values of the type `[usize; 18446744073709551615]` are too big for the current architecture --> $DIR/issue-15919-64.rs:9:9 | LL | let x = [0usize; 0xffff_ffff_ffff_ffff]; diff --git a/src/test/ui/issues/issue-17913.stderr b/src/test/ui/issues/issue-17913.stderr index ae388c4d491df..9a6431d447004 100644 --- a/src/test/ui/issues/issue-17913.stderr +++ b/src/test/ui/issues/issue-17913.stderr @@ -1,4 +1,4 @@ -error: the type `[&usize; N]` is too big for the current architecture +error: values of the type `[&usize; N]` are too big for the current architecture error: aborting due to previous error diff --git a/src/test/ui/issues/issue-56762.rs b/src/test/ui/issues/issue-56762.rs index 5ba5b9847d085..fb0a270f18bef 100644 --- a/src/test/ui/issues/issue-56762.rs +++ b/src/test/ui/issues/issue-56762.rs @@ -17,8 +17,8 @@ impl TooBigArray { } static MY_TOO_BIG_ARRAY_1: TooBigArray = TooBigArray::new(); -//~^ ERROR the type `[u8; 2305843009213693951]` is too big for the current architecture +//~^ ERROR values of the type `[u8; 2305843009213693951]` are too big static MY_TOO_BIG_ARRAY_2: [u8; HUGE_SIZE] = [0x00; HUGE_SIZE]; -//~^ ERROR the type `[u8; 2305843009213693951]` is too big for the current architecture +//~^ ERROR values of the type `[u8; 2305843009213693951]` are too big fn main() { } diff --git a/src/test/ui/issues/issue-56762.stderr b/src/test/ui/issues/issue-56762.stderr index 69626d4bc7a9e..f26ef280b20b7 100644 --- a/src/test/ui/issues/issue-56762.stderr +++ b/src/test/ui/issues/issue-56762.stderr @@ -1,10 +1,10 @@ -error[E0080]: the type `[u8; 2305843009213693951]` is too big for the current architecture +error[E0080]: values of the type `[u8; 2305843009213693951]` are too big for the current architecture --> $DIR/issue-56762.rs:19:1 | LL | static MY_TOO_BIG_ARRAY_1: TooBigArray = TooBigArray::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0080]: the type `[u8; 2305843009213693951]` is too big for the current architecture +error[E0080]: values of the type `[u8; 2305843009213693951]` are 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]; diff --git a/src/test/ui/layout/big-type-no-err.rs b/src/test/ui/layout/big-type-no-err.rs new file mode 100644 index 0000000000000..af8191a9cb919 --- /dev/null +++ b/src/test/ui/layout/big-type-no-err.rs @@ -0,0 +1,13 @@ +// Enormous types are allowed if they are never actually instantiated. +// run-pass +trait Foo { + type Assoc; +} + +impl Foo for [u16; usize::MAX] { + type Assoc = u32; +} + +fn main() { + let _a: Option<<[u16; usize::MAX] as Foo>::Assoc> = None; +} diff --git a/src/test/ui/lint/issue-69485-var-size-diffs-too-large.rs b/src/test/ui/lint/issue-69485-var-size-diffs-too-large.rs index 0895f4c18e387..2560ffe168be5 100644 --- a/src/test/ui/lint/issue-69485-var-size-diffs-too-large.rs +++ b/src/test/ui/lint/issue-69485-var-size-diffs-too-large.rs @@ -3,7 +3,7 @@ // compile-flags: -Zmir-opt-level=0 fn main() { - Bug::V([0; !0]); //~ ERROR is too big for the current + Bug::V([0; !0]); //~ ERROR are too big for the current } enum Bug { diff --git a/src/test/ui/lint/issue-69485-var-size-diffs-too-large.stderr b/src/test/ui/lint/issue-69485-var-size-diffs-too-large.stderr index 51eac95afb9ce..c229458da47da 100644 --- a/src/test/ui/lint/issue-69485-var-size-diffs-too-large.stderr +++ b/src/test/ui/lint/issue-69485-var-size-diffs-too-large.stderr @@ -1,4 +1,4 @@ -error: the type `[u8; 18446744073709551615]` is too big for the current architecture +error: values of the type `[u8; 18446744073709551615]` are too big for the current architecture --> $DIR/issue-69485-var-size-diffs-too-large.rs:6:12 | LL | Bug::V([0; !0]);