about summary refs log tree commit diff
diff options
context:
space:
mode:
authorlcnr <rust@lcnr.de>2021-04-27 14:24:19 +0200
committerMichael Goulet <michael@errs.io>2022-11-10 21:18:06 +0000
commit8ec6c84bb31f9b403b0b25bc4685ece5c744cb48 (patch)
tree0f01db000e441ae232e98c0713ca07a8ef752b44
parent0f2e45b18f47c9cb93267a82ed685f5d37f79367 (diff)
downloadrust-8ec6c84bb31f9b403b0b25bc4685ece5c744cb48.tar.gz
rust-8ec6c84bb31f9b403b0b25bc4685ece5c744cb48.zip
add some more tests
-rw-r--r--src/test/ui/sized/recursive-type-1.rs10
-rw-r--r--src/test/ui/sized/recursive-type-2.rs13
-rw-r--r--src/test/ui/sized/recursive-type-2.stderr12
3 files changed, 35 insertions, 0 deletions
diff --git a/src/test/ui/sized/recursive-type-1.rs b/src/test/ui/sized/recursive-type-1.rs
new file mode 100644
index 00000000000..cd6805967e5
--- /dev/null
+++ b/src/test/ui/sized/recursive-type-1.rs
@@ -0,0 +1,10 @@
+// check-pass
+trait A { type Assoc; }
+
+impl A for () {
+    // FIXME: it would be nice for this to at least cause a warning.
+    type Assoc = Foo<()>;
+}
+struct Foo<T: A>(T::Assoc);
+
+fn main() {}
diff --git a/src/test/ui/sized/recursive-type-2.rs b/src/test/ui/sized/recursive-type-2.rs
new file mode 100644
index 00000000000..7d95417a6ff
--- /dev/null
+++ b/src/test/ui/sized/recursive-type-2.rs
@@ -0,0 +1,13 @@
+// build-fail
+//~^ ERROR cycle detected when computing layout of `Foo<()>`
+
+trait A { type Assoc: ?Sized; }
+
+impl A for () {
+    type Assoc = Foo<()>;
+}
+struct Foo<T: A>(T::Assoc);
+
+fn main() {
+    let x: Foo<()>;
+}
diff --git a/src/test/ui/sized/recursive-type-2.stderr b/src/test/ui/sized/recursive-type-2.stderr
new file mode 100644
index 00000000000..2102c934da3
--- /dev/null
+++ b/src/test/ui/sized/recursive-type-2.stderr
@@ -0,0 +1,12 @@
+error[E0391]: cycle detected when computing layout of `Foo<()>`
+   |
+   = note: ...which again requires computing layout of `Foo<()>`, completing the cycle
+note: cycle used when optimizing MIR for `main`
+  --> $DIR/recursive-type-2.rs:11:1
+   |
+LL | fn main() {
+   | ^^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0391`.