diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
commit | 218caa410aa38c29984be31a5229b9fa717560ee (patch) | |
tree | c54bd55eeb6e4c508940a30e94c0032fbd45d677 /tests/ui/issues/issue-31299.rs | |
parent | Releasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip |
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/issues/issue-31299.rs')
-rw-r--r-- | tests/ui/issues/issue-31299.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/ui/issues/issue-31299.rs b/tests/ui/issues/issue-31299.rs new file mode 100644 index 000000000..78c3252d3 --- /dev/null +++ b/tests/ui/issues/issue-31299.rs @@ -0,0 +1,35 @@ +// run-pass +// Regression test for #31299. This was generating an overflow error +// because of eager normalization: +// +// proving `M: Sized` requires +// - proving `PtrBack<Vec<M>>: Sized` requires +// - normalizing `Vec<<Vec<M> as Front>::Back>>: Sized` requires +// - proving `Vec<M>: Front` requires +// - `M: Sized` <-- cycle! +// +// If we skip the normalization step, though, everything goes fine. +// +// This could be fixed by implementing lazy normalization everywhere. +// +// However, we want this to work before then. For that, when checking +// whether a type is Sized we only check that the tails are Sized. As +// PtrBack does not have a tail, we don't need to normalize anything +// and this compiles + +trait Front { + type Back; +} + +impl<T> Front for Vec<T> { + type Back = Vec<T>; +} + +struct PtrBack<T: Front>(#[allow(unused_tuple_struct_fields)] Vec<T::Back>); + +struct M(#[allow(unused_tuple_struct_fields)] PtrBack<Vec<M>>); + +#[allow(unused_must_use)] +fn main() { + std::mem::size_of::<M>(); +} |