about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/run-pass/existential_type_const.rs17
-rw-r--r--src/test/run-pass/existential_type_const.stderr6
-rw-r--r--src/test/run-pass/existential_type_fns.rs25
-rw-r--r--src/test/ui/existential_types/existential-types-with-cycle-error.rs2
-rw-r--r--src/test/ui/existential_types/existential-types-with-cycle-error.stderr24
-rw-r--r--src/test/ui/existential_types/existential-types-with-cycle-error2.rs2
-rw-r--r--src/test/ui/existential_types/existential-types-with-cycle-error2.stderr24
-rw-r--r--src/test/ui/existential_types/no_inferrable_concrete_type.rs6
-rw-r--r--src/test/ui/existential_types/no_inferrable_concrete_type.stderr21
9 files changed, 56 insertions, 71 deletions
diff --git a/src/test/run-pass/existential_type_const.rs b/src/test/run-pass/existential_type_const.rs
new file mode 100644
index 00000000000..333e15f3445
--- /dev/null
+++ b/src/test/run-pass/existential_type_const.rs
@@ -0,0 +1,17 @@
+#![feature(existential_type)]
+#![feature(impl_trait_in_bindings)]
+//~^ WARN the feature `impl_trait_in_bindings` is incomplete and may cause the compiler to crash
+
+// Ensures that consts can constrain an existential type
+
+use std::fmt::Debug;
+
+// Type `Foo` refers to a type that implements the `Debug` trait.
+// The concrete type to which `Foo` refers is inferred from this module,
+// and this concrete type is hidden from outer modules (but not submodules).
+pub existential type Foo: Debug;
+
+const _FOO: Foo = 5;
+
+fn main() {
+}
diff --git a/src/test/run-pass/existential_type_const.stderr b/src/test/run-pass/existential_type_const.stderr
new file mode 100644
index 00000000000..b6d83fb1703
--- /dev/null
+++ b/src/test/run-pass/existential_type_const.stderr
@@ -0,0 +1,6 @@
+warning: the feature `impl_trait_in_bindings` is incomplete and may cause the compiler to crash
+  --> $DIR/existential_type_const.rs:2:12
+   |
+LL | #![feature(impl_trait_in_bindings)]
+   |            ^^^^^^^^^^^^^^^^^^^^^^
+
diff --git a/src/test/run-pass/existential_type_fns.rs b/src/test/run-pass/existential_type_fns.rs
new file mode 100644
index 00000000000..e477dca9aad
--- /dev/null
+++ b/src/test/run-pass/existential_type_fns.rs
@@ -0,0 +1,25 @@
+#![feature(existential_type)]
+
+// Regression test for issue #61863
+
+pub trait MyTrait {}
+
+#[derive(Debug)]
+pub struct MyStruct {
+  v: u64
+}
+
+impl MyTrait for MyStruct {}
+
+pub fn bla() -> TE {
+    return MyStruct {v:1}
+}
+
+pub fn bla2() -> TE {
+    bla()
+}
+
+
+existential type TE: MyTrait;
+
+fn main() {}
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
index 3f0190892eb..38fcabb5cc1 100644
--- a/src/test/ui/existential_types/existential-types-with-cycle-error.rs
+++ b/src/test/ui/existential_types/existential-types-with-cycle-error.rs
@@ -1,7 +1,7 @@
 #![feature(existential_type)]
 
 existential type Foo: Fn() -> Foo;
-//~^ ERROR: cycle detected when processing `Foo`
+//~^ ERROR: could not find defining uses
 
 fn crash(x: Foo) -> Foo {
     x
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
index 56057a9caa4..98a269d5271 100644
--- a/src/test/ui/existential_types/existential-types-with-cycle-error.stderr
+++ b/src/test/ui/existential_types/existential-types-with-cycle-error.stderr
@@ -1,30 +1,8 @@
-error[E0391]: cycle detected when processing `Foo`
+error: could not find defining uses
   --> $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
index 29410309ef2..f9e6bdb67d4 100644
--- a/src/test/ui/existential_types/existential-types-with-cycle-error2.rs
+++ b/src/test/ui/existential_types/existential-types-with-cycle-error2.rs
@@ -5,7 +5,7 @@ pub trait Bar<T> {
 }
 
 existential type Foo: Bar<Foo, Item = Foo>;
-//~^ ERROR: cycle detected when processing `Foo`
+//~^ ERROR: could not find defining uses
 
 fn crash(x: Foo) -> Foo {
     x
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
index 8c7bf52470a..830305d8631 100644
--- a/src/test/ui/existential_types/existential-types-with-cycle-error2.stderr
+++ b/src/test/ui/existential_types/existential-types-with-cycle-error2.stderr
@@ -1,30 +1,8 @@
-error[E0391]: cycle detected when processing `Foo`
+error: could not find defining uses
   --> $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`.
diff --git a/src/test/ui/existential_types/no_inferrable_concrete_type.rs b/src/test/ui/existential_types/no_inferrable_concrete_type.rs
index 6bbe8bdc0cd..eec8a4be63d 100644
--- a/src/test/ui/existential_types/no_inferrable_concrete_type.rs
+++ b/src/test/ui/existential_types/no_inferrable_concrete_type.rs
@@ -1,9 +1,9 @@
-// Issue 52985: Cause cycle error if user code provides no use case that allows an existential type
-// to be inferred to a concrete type. This results in an infinite cycle during type normalization.
+// Issue 52985: user code provides no use case that allows an existential type
+// We now emit a 'could not find defining uses' error
 
 #![feature(existential_type)]
 
-existential type Foo: Copy; //~ cycle detected
+existential type Foo: Copy; //~ could not find defining uses
 
 // make compiler happy about using 'Foo'
 fn bar(x: Foo) -> Foo { x }
diff --git a/src/test/ui/existential_types/no_inferrable_concrete_type.stderr b/src/test/ui/existential_types/no_inferrable_concrete_type.stderr
index 4605332ef5b..bc9a883c836 100644
--- a/src/test/ui/existential_types/no_inferrable_concrete_type.stderr
+++ b/src/test/ui/existential_types/no_inferrable_concrete_type.stderr
@@ -1,27 +1,8 @@
-error[E0391]: cycle detected when processing `Foo`
+error: could not find defining uses
   --> $DIR/no_inferrable_concrete_type.rs:6:1
    |
 LL | existential type Foo: Copy;
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-note: ...which requires processing `bar`...
-  --> $DIR/no_inferrable_concrete_type.rs:9:23
-   |
-LL | fn bar(x: Foo) -> Foo { x }
-   |                       ^^^^^
-   = note: ...which again requires processing `Foo`, completing the cycle
-note: cycle used when collecting item types in top-level module
-  --> $DIR/no_inferrable_concrete_type.rs:4:1
-   |
-LL | / #![feature(existential_type)]
-LL | |
-LL | | existential type Foo: Copy;
-LL | |
-...  |
-LL | |     let _: Foo = std::mem::transmute(0u8);
-LL | | }
-   | |_^
 
 error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0391`.