about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJosh Stone <cuviper@gmail.com>2019-03-27 18:15:42 -0700
committerGitHub <noreply@github.com>2019-03-27 18:15:42 -0700
commit4a322f5fddd91433b6577ccca51249e7beaaafc9 (patch)
tree859db26fffabb154ec1f892180da8228e6d8bd48
parent44c411ec6f5aea339fe66d5f22548323cbad2edb (diff)
parent2368aa8e97e9f3d3df1a75dc798e0e3f4cced7da (diff)
Rollup merge of #59459 - JohnTitor:add-tests, r=Centril
Add some tests

close #52977

It seems that there are no tests for this issue, so I opened this PR.
off-topic: I noticed [this test](https://github.com/rust-lang/rust/blob/master/src/test/ui/existential_types/nested_existential_types.rs)'s indents are bad, could I include commit to fix this, or should I separate?

r? @oli-obk
-rw-r--r--src/test/ui/existential_types/existential-types-with-cycle-error.rs12
-rw-r--r--src/test/ui/existential_types/existential-types-with-cycle-error.stderr30
-rw-r--r--src/test/ui/existential_types/existential-types-with-cycle-error2.rs16
-rw-r--r--src/test/ui/existential_types/existential-types-with-cycle-error2.stderr30
4 files changed, 88 insertions, 0 deletions
diff --git a/src/test/ui/existential_types/existential-types-with-cycle-error.rs b/src/test/ui/existential_types/existential-types-with-cycle-error.rs
new file mode 100644
index 00000000000..3f0190892eb
--- /dev/null
+++ b/src/test/ui/existential_types/existential-types-with-cycle-error.rs
@@ -0,0 +1,12 @@
+#![feature(existential_type)]
+
+existential type Foo: Fn() -> Foo;
+//~^ ERROR: cycle detected when processing `Foo`
+
+fn crash(x: Foo) -> Foo {
+    x
+}
+
+fn main() {
+
+}
diff --git a/src/test/ui/existential_types/existential-types-with-cycle-error.stderr b/src/test/ui/existential_types/existential-types-with-cycle-error.stderr
new file mode 100644
index 00000000000..56057a9caa4
--- /dev/null
+++ b/src/test/ui/existential_types/existential-types-with-cycle-error.stderr
@@ -0,0 +1,30 @@
+error[E0391]: cycle detected when processing `Foo`
+  --> $DIR/existential-types-with-cycle-error.rs:3:1
+   |
+LL | existential type Foo: Fn() -> Foo;
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+note: ...which requires processing `crash`...
+  --> $DIR/existential-types-with-cycle-error.rs:6:25
+   |
+LL |   fn crash(x: Foo) -> Foo {
+   |  _________________________^
+LL | |     x
+LL | | }
+   | |_^
+   = note: ...which again requires processing `Foo`, completing the cycle
+note: cycle used when collecting item types in top-level module
+  --> $DIR/existential-types-with-cycle-error.rs:1:1
+   |
+LL | / #![feature(existential_type)]
+LL | |
+LL | | existential type Foo: Fn() -> Foo;
+LL | |
+...  |
+LL | |
+LL | | }
+   | |_^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0391`.
diff --git a/src/test/ui/existential_types/existential-types-with-cycle-error2.rs b/src/test/ui/existential_types/existential-types-with-cycle-error2.rs
new file mode 100644
index 00000000000..29410309ef2
--- /dev/null
+++ b/src/test/ui/existential_types/existential-types-with-cycle-error2.rs
@@ -0,0 +1,16 @@
+#![feature(existential_type)]
+
+pub trait Bar<T> {
+    type Item;
+}
+
+existential type Foo: Bar<Foo, Item = Foo>;
+//~^ ERROR: cycle detected when processing `Foo`
+
+fn crash(x: Foo) -> Foo {
+    x
+}
+
+fn main() {
+
+}
diff --git a/src/test/ui/existential_types/existential-types-with-cycle-error2.stderr b/src/test/ui/existential_types/existential-types-with-cycle-error2.stderr
new file mode 100644
index 00000000000..8c7bf52470a
--- /dev/null
+++ b/src/test/ui/existential_types/existential-types-with-cycle-error2.stderr
@@ -0,0 +1,30 @@
+error[E0391]: cycle detected when processing `Foo`
+  --> $DIR/existential-types-with-cycle-error2.rs:7:1
+   |
+LL | existential type Foo: Bar<Foo, Item = Foo>;
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+note: ...which requires processing `crash`...
+  --> $DIR/existential-types-with-cycle-error2.rs:10:25
+   |
+LL |   fn crash(x: Foo) -> Foo {
+   |  _________________________^
+LL | |     x
+LL | | }
+   | |_^
+   = note: ...which again requires processing `Foo`, completing the cycle
+note: cycle used when collecting item types in top-level module
+  --> $DIR/existential-types-with-cycle-error2.rs:1:1
+   |
+LL | / #![feature(existential_type)]
+LL | |
+LL | | pub trait Bar<T> {
+LL | |     type Item;
+...  |
+LL | |
+LL | | }
+   | |_^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0391`.