about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2023-12-26 13:29:14 -0500
committerGitHub <noreply@github.com>2023-12-26 13:29:14 -0500
commita5b3d139b3a7aee8a01701df47f7824bd13eec1c (patch)
treee633473e928074dfa7d5929585083afecf88c57d
parente1be642b41a79bd23b46aaa229cac4e23638b169 (diff)
parent29036045c3d156e2e952732c61034ec0c00f5903 (diff)
downloadrust-a5b3d139b3a7aee8a01701df47f7824bd13eec1c.tar.gz
rust-a5b3d139b3a7aee8a01701df47f7824bd13eec1c.zip
Rollup merge of #119323 - lukas-code:test-never-to-infinite, r=compiler-errors
add test for coercing never to infinite type

Closes https://github.com/rust-lang/rust/issues/113197.

This was fixed in https://github.com/rust-lang/rust/pull/118308, probably https://github.com/rust-lang/rust/pull/118308/commits/1978168c136ba65b8da3f5a45834631c13d7c56f.
-rw-r--r--tests/ui/sized/recursive-type-binding.rs (renamed from tests/ui/sized/recursive-type-2.rs)0
-rw-r--r--tests/ui/sized/recursive-type-binding.stderr (renamed from tests/ui/sized/recursive-type-2.stderr)2
-rw-r--r--tests/ui/sized/recursive-type-coercion-from-never.rs16
-rw-r--r--tests/ui/sized/recursive-type-coercion-from-never.stderr14
-rw-r--r--tests/ui/sized/recursive-type-pass.rs (renamed from tests/ui/sized/recursive-type-1.rs)0
5 files changed, 31 insertions, 1 deletions
diff --git a/tests/ui/sized/recursive-type-2.rs b/tests/ui/sized/recursive-type-binding.rs
index 7d95417a6ff..7d95417a6ff 100644
--- a/tests/ui/sized/recursive-type-2.rs
+++ b/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
index 4e7f40a0153..d9c2efa4d53 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-coercion-from-never.rs b/tests/ui/sized/recursive-type-coercion-from-never.rs
new file mode 100644
index 00000000000..a1b65463731
--- /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: A>(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 00000000000..7580e780dda
--- /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`.
diff --git a/tests/ui/sized/recursive-type-1.rs b/tests/ui/sized/recursive-type-pass.rs
index cd6805967e5..cd6805967e5 100644
--- a/tests/ui/sized/recursive-type-1.rs
+++ b/tests/ui/sized/recursive-type-pass.rs