From cb2fc0967fbecc26a33dcc9b99bbeccc826d576b Mon Sep 17 00:00:00 2001 From: Lukas Markeffsky <@> Date: Tue, 26 Dec 2023 17:50:30 +0100 Subject: [PATCH 1/2] rename tests --- .../ui/sized/{recursive-type-2.rs => recursive-type-binding.rs} | 0 .../{recursive-type-2.stderr => recursive-type-binding.stderr} | 2 +- tests/ui/sized/{recursive-type-1.rs => recursive-type-pass.rs} | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename tests/ui/sized/{recursive-type-2.rs => recursive-type-binding.rs} (100%) rename tests/ui/sized/{recursive-type-2.stderr => recursive-type-binding.stderr} (93%) rename tests/ui/sized/{recursive-type-1.rs => recursive-type-pass.rs} (100%) diff --git a/tests/ui/sized/recursive-type-2.rs b/tests/ui/sized/recursive-type-binding.rs similarity index 100% rename from tests/ui/sized/recursive-type-2.rs rename to tests/ui/sized/recursive-type-binding.rs diff --git a/tests/ui/sized/recursive-type-2.stderr b/tests/ui/sized/recursive-type-binding.stderr similarity index 93% rename from tests/ui/sized/recursive-type-2.stderr rename to tests/ui/sized/recursive-type-binding.stderr index 4e7f40a01533c..d9c2efa4d53b7 100644 --- a/tests/ui/sized/recursive-type-2.stderr +++ b/tests/ui/sized/recursive-type-binding.stderr @@ -3,7 +3,7 @@ error[E0391]: cycle detected when computing layout of `Foo<()>` = note: ...which requires computing layout of `<() as A>::Assoc`... = note: ...which again requires computing layout of `Foo<()>`, completing the cycle note: cycle used when elaborating drops for `main` - --> $DIR/recursive-type-2.rs:11:1 + --> $DIR/recursive-type-binding.rs:11:1 | LL | fn main() { | ^^^^^^^^^ diff --git a/tests/ui/sized/recursive-type-1.rs b/tests/ui/sized/recursive-type-pass.rs similarity index 100% rename from tests/ui/sized/recursive-type-1.rs rename to tests/ui/sized/recursive-type-pass.rs From 29036045c3d156e2e952732c61034ec0c00f5903 Mon Sep 17 00:00:00 2001 From: Lukas Markeffsky <@> Date: Tue, 26 Dec 2023 17:50:41 +0100 Subject: [PATCH 2/2] add test for coercing never to infinite type --- .../sized/recursive-type-coercion-from-never.rs | 16 ++++++++++++++++ .../recursive-type-coercion-from-never.stderr | 14 ++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 tests/ui/sized/recursive-type-coercion-from-never.rs create mode 100644 tests/ui/sized/recursive-type-coercion-from-never.stderr diff --git a/tests/ui/sized/recursive-type-coercion-from-never.rs b/tests/ui/sized/recursive-type-coercion-from-never.rs new file mode 100644 index 0000000000000..a1b654637316d --- /dev/null +++ b/tests/ui/sized/recursive-type-coercion-from-never.rs @@ -0,0 +1,16 @@ +// build-fail +//~^ ERROR cycle detected when computing layout of `Foo<()>` + +// Regression test for a stack overflow: https://github.com/rust-lang/rust/issues/113197 + +trait A { type Assoc; } + +impl A for () { + type Assoc = Foo<()>; +} + +struct Foo(T::Assoc); + +fn main() { + Foo::<()>(todo!()); +} diff --git a/tests/ui/sized/recursive-type-coercion-from-never.stderr b/tests/ui/sized/recursive-type-coercion-from-never.stderr new file mode 100644 index 0000000000000..7580e780dda59 --- /dev/null +++ b/tests/ui/sized/recursive-type-coercion-from-never.stderr @@ -0,0 +1,14 @@ +error[E0391]: cycle detected when computing layout of `Foo<()>` + | + = note: ...which requires computing layout of `<() as A>::Assoc`... + = note: ...which again requires computing layout of `Foo<()>`, completing the cycle +note: cycle used when elaborating drops for `main` + --> $DIR/recursive-type-coercion-from-never.rs:14:1 + | +LL | fn main() { + | ^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0391`.