]> git.lizzy.rs Git - rust.git/commitdiff
Move some tests around
authorOliver Schneider <github35764891676564198441@oli-obk.de>
Mon, 16 Jul 2018 14:49:35 +0000 (16:49 +0200)
committerOliver Schneider <github35764891676564198441@oli-obk.de>
Wed, 18 Jul 2018 08:53:09 +0000 (10:53 +0200)
20 files changed:
src/test/ui/existential_type.nll.stderr [deleted file]
src/test/ui/existential_type.rs [deleted file]
src/test/ui/existential_type.stderr [deleted file]
src/test/ui/existential_type2.rs [deleted file]
src/test/ui/existential_type2.stderr [deleted file]
src/test/ui/existential_type3.rs [deleted file]
src/test/ui/existential_type3.stderr [deleted file]
src/test/ui/existential_type4.rs [deleted file]
src/test/ui/existential_type4.stderr [deleted file]
src/test/ui/existential_types/existential-associated-type.rs [new file with mode: 0644]
src/test/ui/existential_types/existential_type.nll.stderr [new file with mode: 0644]
src/test/ui/existential_types/existential_type.rs [new file with mode: 0644]
src/test/ui/existential_types/existential_type.stderr [new file with mode: 0644]
src/test/ui/existential_types/existential_type2.rs [new file with mode: 0644]
src/test/ui/existential_types/existential_type2.stderr [new file with mode: 0644]
src/test/ui/existential_types/existential_type3.rs [new file with mode: 0644]
src/test/ui/existential_types/existential_type3.stderr [new file with mode: 0644]
src/test/ui/existential_types/existential_type4.rs [new file with mode: 0644]
src/test/ui/existential_types/existential_type4.stderr [new file with mode: 0644]
src/test/ui/impl-trait/existential-associated-type.rs [deleted file]

diff --git a/src/test/ui/existential_type.nll.stderr b/src/test/ui/existential_type.nll.stderr
deleted file mode 100644 (file)
index 90840bf..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-error: defining existential type use differs from previous
-  --> $DIR/existential_type.rs:23:1
-   |
-LL | / fn bar() -> Foo { //~ ERROR defining existential type use differs from previous
-LL | |     42i32
-LL | | }
-   | |_^
-   |
-note: previous use here
-  --> $DIR/existential_type.rs:19:1
-   |
-LL | / fn foo() -> Foo {
-LL | |     ""
-LL | | }
-   | |_^
-
-error[E0308]: mismatched types
-  --> $DIR/existential_type.rs:36:5
-   |
-LL | fn bomp() -> boo::Boo {
-   |              -------- expected `Boo` because of return type
-LL |     "" //~ ERROR mismatched types
-   |     ^^ expected anonymized type, found reference
-   |
-   = note: expected type `Boo`
-              found type `&'static str`
-
-error[E0308]: mismatched types
-  --> $DIR/existential_type.rs:50:23
-   |
-LL |         let _: &str = bomp(); //~ ERROR mismatched types
-   |                       ^^^^^^ expected &str, found anonymized type
-   |
-   = note: expected type `&str`
-              found type `Boo`
-
-error[E0308]: mismatched types
-  --> $DIR/existential_type.rs:54:9
-   |
-LL |     fn bomp() -> boo::Boo {
-   |                  -------- expected `Boo` because of return type
-LL |         "" //~ ERROR mismatched types
-   |         ^^ expected anonymized type, found reference
-   |
-   = note: expected type `Boo`
-              found type `&'static str`
-
-error[E0277]: the trait bound `T: Trait` is not satisfied
-  --> $DIR/existential_type.rs:61:1
-   |
-LL | existential type Underconstrained<T: Trait>: 'static; //~ ERROR the trait bound `T: Trait`
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `T`
-   |
-   = help: consider adding a `where T: Trait` bound
-   = note: the return type of a function must have a statically known size
-
-warning: not reporting region error due to nll
-  --> $DIR/existential_type.rs:78:1
-   |
-LL | existential type WrongGeneric<T>: 'static;
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error[E0308]: mismatched types
-  --> $DIR/existential_type.rs:93:27
-   |
-LL |     let _: &'static str = x; //~ mismatched types
-   |                           ^ expected reference, found anonymized type
-   |
-   = note: expected type `&'static str`
-              found type `NoReveal`
-
-error[E0605]: non-primitive cast: `NoReveal` as `&'static str`
-  --> $DIR/existential_type.rs:94:13
-   |
-LL |     let _ = x as &'static str; //~ non-primitive cast
-   |             ^^^^^^^^^^^^^^^^^
-   |
-   = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait
-
-error: could not find defining uses
-  --> $DIR/existential_type.rs:28:1
-   |
-LL | existential type Bar: std::fmt::Debug; //~ ERROR could not find defining uses
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error: could not find defining uses
-  --> $DIR/existential_type.rs:32:5
-   |
-LL |     pub existential type Boo: ::std::fmt::Debug; //~ ERROR could not find defining uses
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error: defining existential type use differs from previous
-  --> $DIR/existential_type.rs:74:1
-   |
-LL | / fn my_iter2<T>(t: T) -> MyIter<T> { //~ ERROR defining existential type use differs from previous
-LL | |     Some(t).into_iter()
-LL | | }
-   | |_^
-   |
-note: previous use here
-  --> $DIR/existential_type.rs:70:1
-   |
-LL | / fn my_iter<T>(t: T) -> MyIter<T> {
-LL | |     std::iter::once(t)
-LL | | }
-   | |_^
-
-error: aborting due to 10 previous errors
-
-Some errors occurred: E0277, E0308, E0605.
-For more information about an error, try `rustc --explain E0277`.
diff --git a/src/test/ui/existential_type.rs b/src/test/ui/existential_type.rs
deleted file mode 100644 (file)
index 6824d36..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-
-#![feature(existential_type)]
-
-fn main() {}
-
-// two definitions with different types
-existential type Foo: std::fmt::Debug;
-
-fn foo() -> Foo {
-    ""
-}
-
-fn bar() -> Foo { //~ ERROR defining existential type use differs from previous
-    42i32
-}
-
-// declared but never defined
-existential type Bar: std::fmt::Debug; //~ ERROR could not find defining uses
-
-mod boo {
-    // declared in module but not defined inside of it
-    pub existential type Boo: ::std::fmt::Debug; //~ ERROR could not find defining uses
-}
-
-fn bomp() -> boo::Boo {
-    "" //~ ERROR mismatched types
-}
-
-mod boo2 {
-    mod boo {
-        pub existential type Boo: ::std::fmt::Debug;
-        fn bomp() -> Boo {
-            ""
-        }
-    }
-
-    // don't actually know the type here
-
-    fn bomp2() {
-        let _: &str = bomp(); //~ ERROR mismatched types
-    }
-
-    fn bomp() -> boo::Boo {
-        "" //~ ERROR mismatched types
-    }
-}
-
-// generics
-
-trait Trait {}
-existential type Underconstrained<T: Trait>: 'static; //~ ERROR the trait bound `T: Trait`
-
-// no `Trait` bound
-fn underconstrain<T>(_: T) -> Underconstrained<T> {
-    unimplemented!()
-}
-
-existential type MyIter<T>: Iterator<Item = T>;
-
-fn my_iter<T>(t: T) -> MyIter<T> {
-    std::iter::once(t)
-}
-
-fn my_iter2<T>(t: T) -> MyIter<T> { //~ ERROR defining existential type use differs from previous
-    Some(t).into_iter()
-}
-
-existential type WrongGeneric<T>: 'static;
-//~^ ERROR the parameter type `T` may not live long enough
-
-fn wrong_generic<T>(t: T) -> WrongGeneric<T> {
-    t
-}
-
-// don't reveal the concrete type
-existential type NoReveal: std::fmt::Debug;
-
-fn define_no_reveal() -> NoReveal {
-    ""
-}
-
-fn no_reveal(x: NoReveal) {
-    let _: &'static str = x; //~ mismatched types
-    let _ = x as &'static str; //~ non-primitive cast
-}
diff --git a/src/test/ui/existential_type.stderr b/src/test/ui/existential_type.stderr
deleted file mode 100644 (file)
index 3e74764..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-error: defining existential type use differs from previous
-  --> $DIR/existential_type.rs:23:1
-   |
-LL | / fn bar() -> Foo { //~ ERROR defining existential type use differs from previous
-LL | |     42i32
-LL | | }
-   | |_^
-   |
-note: previous use here
-  --> $DIR/existential_type.rs:19:1
-   |
-LL | / fn foo() -> Foo {
-LL | |     ""
-LL | | }
-   | |_^
-
-error[E0308]: mismatched types
-  --> $DIR/existential_type.rs:36:5
-   |
-LL | fn bomp() -> boo::Boo {
-   |              -------- expected `Boo` because of return type
-LL |     "" //~ ERROR mismatched types
-   |     ^^ expected anonymized type, found reference
-   |
-   = note: expected type `Boo`
-              found type `&'static str`
-
-error[E0308]: mismatched types
-  --> $DIR/existential_type.rs:50:23
-   |
-LL |         let _: &str = bomp(); //~ ERROR mismatched types
-   |                       ^^^^^^ expected &str, found anonymized type
-   |
-   = note: expected type `&str`
-              found type `Boo`
-
-error[E0308]: mismatched types
-  --> $DIR/existential_type.rs:54:9
-   |
-LL |     fn bomp() -> boo::Boo {
-   |                  -------- expected `Boo` because of return type
-LL |         "" //~ ERROR mismatched types
-   |         ^^ expected anonymized type, found reference
-   |
-   = note: expected type `Boo`
-              found type `&'static str`
-
-error[E0277]: the trait bound `T: Trait` is not satisfied
-  --> $DIR/existential_type.rs:61:1
-   |
-LL | existential type Underconstrained<T: Trait>: 'static; //~ ERROR the trait bound `T: Trait`
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `T`
-   |
-   = help: consider adding a `where T: Trait` bound
-   = note: the return type of a function must have a statically known size
-
-error[E0310]: the parameter type `T` may not live long enough
-  --> $DIR/existential_type.rs:78:1
-   |
-LL | existential type WrongGeneric<T>: 'static;
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-...
-LL | fn wrong_generic<T>(t: T) -> WrongGeneric<T> {
-   |                  - help: consider adding an explicit lifetime bound `T: 'static`...
-   |
-note: ...so that the type `T` will meet its required lifetime bounds
-  --> $DIR/existential_type.rs:78:1
-   |
-LL | existential type WrongGeneric<T>: 'static;
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error[E0308]: mismatched types
-  --> $DIR/existential_type.rs:93:27
-   |
-LL |     let _: &'static str = x; //~ mismatched types
-   |                           ^ expected reference, found anonymized type
-   |
-   = note: expected type `&'static str`
-              found type `NoReveal`
-
-error[E0605]: non-primitive cast: `NoReveal` as `&'static str`
-  --> $DIR/existential_type.rs:94:13
-   |
-LL |     let _ = x as &'static str; //~ non-primitive cast
-   |             ^^^^^^^^^^^^^^^^^
-   |
-   = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait
-
-error: could not find defining uses
-  --> $DIR/existential_type.rs:28:1
-   |
-LL | existential type Bar: std::fmt::Debug; //~ ERROR could not find defining uses
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error: could not find defining uses
-  --> $DIR/existential_type.rs:32:5
-   |
-LL |     pub existential type Boo: ::std::fmt::Debug; //~ ERROR could not find defining uses
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error: defining existential type use differs from previous
-  --> $DIR/existential_type.rs:74:1
-   |
-LL | / fn my_iter2<T>(t: T) -> MyIter<T> { //~ ERROR defining existential type use differs from previous
-LL | |     Some(t).into_iter()
-LL | | }
-   | |_^
-   |
-note: previous use here
-  --> $DIR/existential_type.rs:70:1
-   |
-LL | / fn my_iter<T>(t: T) -> MyIter<T> {
-LL | |     std::iter::once(t)
-LL | | }
-   | |_^
-
-error: aborting due to 11 previous errors
-
-Some errors occurred: E0277, E0308, E0310, E0605.
-For more information about an error, try `rustc --explain E0277`.
diff --git a/src/test/ui/existential_type2.rs b/src/test/ui/existential_type2.rs
deleted file mode 100644 (file)
index bffb6b5..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-
-#![feature(existential_type)]
-
-fn main() {}
-
-existential type Underconstrained<T: std::fmt::Debug>: 'static;
-//~^ ERROR `U` doesn't implement `std::fmt::Debug`
-
-// not a defining use, because it doesn't define *all* possible generics
-fn underconstrained<U>(_: U) -> Underconstrained<U> {
-    5u32
-}
-
-existential type Underconstrained2<T: std::fmt::Debug>: 'static;
-//~^ ERROR `V` doesn't implement `std::fmt::Debug`
-
-// not a defining use, because it doesn't define *all* possible generics
-fn underconstrained2<U, V>(_: U, _: V) -> Underconstrained2<V> {
-    5u32
-}
diff --git a/src/test/ui/existential_type2.stderr b/src/test/ui/existential_type2.stderr
deleted file mode 100644 (file)
index 53003a4..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-error[E0277]: `U` doesn't implement `std::fmt::Debug`
-  --> $DIR/existential_type2.rs:16:1
-   |
-LL | existential type Underconstrained<T: std::fmt::Debug>: 'static;
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `U` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`
-   |
-   = help: the trait `std::fmt::Debug` is not implemented for `U`
-   = help: consider adding a `where U: std::fmt::Debug` bound
-   = note: the return type of a function must have a statically known size
-
-error[E0277]: `V` doesn't implement `std::fmt::Debug`
-  --> $DIR/existential_type2.rs:24:1
-   |
-LL | existential type Underconstrained2<T: std::fmt::Debug>: 'static;
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `V` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`
-   |
-   = help: the trait `std::fmt::Debug` is not implemented for `V`
-   = help: consider adding a `where V: std::fmt::Debug` bound
-   = note: the return type of a function must have a statically known size
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/existential_type3.rs b/src/test/ui/existential_type3.rs
deleted file mode 100644 (file)
index b090cf2..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-
-#![feature(existential_type)]
-
-fn main() {}
-
-existential type WrongGeneric<T: 'static>: 'static;
-
-fn wrong_generic<U: 'static, V: 'static>(_: U, v: V) -> WrongGeneric<U> {
-//~^ ERROR type parameter `V` is part of concrete type but not used in parameter list
-    v
-}
diff --git a/src/test/ui/existential_type3.stderr b/src/test/ui/existential_type3.stderr
deleted file mode 100644 (file)
index 9080072..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-error: type parameter `V` is part of concrete type but not used in parameter list for existential type
-  --> $DIR/existential_type3.rs:18:73
-   |
-LL |   fn wrong_generic<U: 'static, V: 'static>(_: U, v: V) -> WrongGeneric<U> {
-   |  _________________________________________________________________________^
-LL | | //~^ ERROR type parameter `V` is part of concrete type but not used in parameter list
-LL | |     v
-LL | | }
-   | |_^
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/existential_type4.rs b/src/test/ui/existential_type4.rs
deleted file mode 100644 (file)
index a4b74d6..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-
-#![feature(existential_type)]
-
-fn main() {}
-
-existential type Cmp<T>: 'static;
-
-// not a defining use, because it doesn't define *all* possible generics
-fn cmp() -> Cmp<u32> { //~ ERROR non-defining existential type use in defining scope
-    5u32
-}
diff --git a/src/test/ui/existential_type4.stderr b/src/test/ui/existential_type4.stderr
deleted file mode 100644 (file)
index b119887..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-error: non-defining existential type use in defining scope
-  --> $DIR/existential_type4.rs:19:1
-   |
-LL | / fn cmp() -> Cmp<u32> { //~ ERROR non-defining existential type use in defining scope
-LL | |     5u32
-LL | | }
-   | |_^
-   |
-note: used non-generic type u32 for generic parameter
-  --> $DIR/existential_type4.rs:16:22
-   |
-LL | existential type Cmp<T>: 'static;
-   |                      ^
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/existential_types/existential-associated-type.rs b/src/test/ui/existential_types/existential-associated-type.rs
new file mode 100644 (file)
index 0000000..af393fe
--- /dev/null
@@ -0,0 +1,36 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(existential_type)]
+// compile-pass
+
+trait Bar {}
+struct Dummy;
+impl Bar for Dummy {}
+
+trait Foo {
+    type Assoc: Bar;
+    fn foo() -> Self::Assoc;
+    fn bar() -> Self::Assoc;
+}
+
+existential type Helper: Bar;
+
+impl Foo for i32 {
+    type Assoc = Helper;
+    fn foo() -> Helper {
+        Dummy
+    }
+    fn bar() -> Helper {
+        Dummy
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/existential_types/existential_type.nll.stderr b/src/test/ui/existential_types/existential_type.nll.stderr
new file mode 100644 (file)
index 0000000..90840bf
--- /dev/null
@@ -0,0 +1,111 @@
+error: defining existential type use differs from previous
+  --> $DIR/existential_type.rs:23:1
+   |
+LL | / fn bar() -> Foo { //~ ERROR defining existential type use differs from previous
+LL | |     42i32
+LL | | }
+   | |_^
+   |
+note: previous use here
+  --> $DIR/existential_type.rs:19:1
+   |
+LL | / fn foo() -> Foo {
+LL | |     ""
+LL | | }
+   | |_^
+
+error[E0308]: mismatched types
+  --> $DIR/existential_type.rs:36:5
+   |
+LL | fn bomp() -> boo::Boo {
+   |              -------- expected `Boo` because of return type
+LL |     "" //~ ERROR mismatched types
+   |     ^^ expected anonymized type, found reference
+   |
+   = note: expected type `Boo`
+              found type `&'static str`
+
+error[E0308]: mismatched types
+  --> $DIR/existential_type.rs:50:23
+   |
+LL |         let _: &str = bomp(); //~ ERROR mismatched types
+   |                       ^^^^^^ expected &str, found anonymized type
+   |
+   = note: expected type `&str`
+              found type `Boo`
+
+error[E0308]: mismatched types
+  --> $DIR/existential_type.rs:54:9
+   |
+LL |     fn bomp() -> boo::Boo {
+   |                  -------- expected `Boo` because of return type
+LL |         "" //~ ERROR mismatched types
+   |         ^^ expected anonymized type, found reference
+   |
+   = note: expected type `Boo`
+              found type `&'static str`
+
+error[E0277]: the trait bound `T: Trait` is not satisfied
+  --> $DIR/existential_type.rs:61:1
+   |
+LL | existential type Underconstrained<T: Trait>: 'static; //~ ERROR the trait bound `T: Trait`
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `T`
+   |
+   = help: consider adding a `where T: Trait` bound
+   = note: the return type of a function must have a statically known size
+
+warning: not reporting region error due to nll
+  --> $DIR/existential_type.rs:78:1
+   |
+LL | existential type WrongGeneric<T>: 'static;
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/existential_type.rs:93:27
+   |
+LL |     let _: &'static str = x; //~ mismatched types
+   |                           ^ expected reference, found anonymized type
+   |
+   = note: expected type `&'static str`
+              found type `NoReveal`
+
+error[E0605]: non-primitive cast: `NoReveal` as `&'static str`
+  --> $DIR/existential_type.rs:94:13
+   |
+LL |     let _ = x as &'static str; //~ non-primitive cast
+   |             ^^^^^^^^^^^^^^^^^
+   |
+   = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait
+
+error: could not find defining uses
+  --> $DIR/existential_type.rs:28:1
+   |
+LL | existential type Bar: std::fmt::Debug; //~ ERROR could not find defining uses
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: could not find defining uses
+  --> $DIR/existential_type.rs:32:5
+   |
+LL |     pub existential type Boo: ::std::fmt::Debug; //~ ERROR could not find defining uses
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: defining existential type use differs from previous
+  --> $DIR/existential_type.rs:74:1
+   |
+LL | / fn my_iter2<T>(t: T) -> MyIter<T> { //~ ERROR defining existential type use differs from previous
+LL | |     Some(t).into_iter()
+LL | | }
+   | |_^
+   |
+note: previous use here
+  --> $DIR/existential_type.rs:70:1
+   |
+LL | / fn my_iter<T>(t: T) -> MyIter<T> {
+LL | |     std::iter::once(t)
+LL | | }
+   | |_^
+
+error: aborting due to 10 previous errors
+
+Some errors occurred: E0277, E0308, E0605.
+For more information about an error, try `rustc --explain E0277`.
diff --git a/src/test/ui/existential_types/existential_type.rs b/src/test/ui/existential_types/existential_type.rs
new file mode 100644 (file)
index 0000000..6824d36
--- /dev/null
@@ -0,0 +1,95 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+
+#![feature(existential_type)]
+
+fn main() {}
+
+// two definitions with different types
+existential type Foo: std::fmt::Debug;
+
+fn foo() -> Foo {
+    ""
+}
+
+fn bar() -> Foo { //~ ERROR defining existential type use differs from previous
+    42i32
+}
+
+// declared but never defined
+existential type Bar: std::fmt::Debug; //~ ERROR could not find defining uses
+
+mod boo {
+    // declared in module but not defined inside of it
+    pub existential type Boo: ::std::fmt::Debug; //~ ERROR could not find defining uses
+}
+
+fn bomp() -> boo::Boo {
+    "" //~ ERROR mismatched types
+}
+
+mod boo2 {
+    mod boo {
+        pub existential type Boo: ::std::fmt::Debug;
+        fn bomp() -> Boo {
+            ""
+        }
+    }
+
+    // don't actually know the type here
+
+    fn bomp2() {
+        let _: &str = bomp(); //~ ERROR mismatched types
+    }
+
+    fn bomp() -> boo::Boo {
+        "" //~ ERROR mismatched types
+    }
+}
+
+// generics
+
+trait Trait {}
+existential type Underconstrained<T: Trait>: 'static; //~ ERROR the trait bound `T: Trait`
+
+// no `Trait` bound
+fn underconstrain<T>(_: T) -> Underconstrained<T> {
+    unimplemented!()
+}
+
+existential type MyIter<T>: Iterator<Item = T>;
+
+fn my_iter<T>(t: T) -> MyIter<T> {
+    std::iter::once(t)
+}
+
+fn my_iter2<T>(t: T) -> MyIter<T> { //~ ERROR defining existential type use differs from previous
+    Some(t).into_iter()
+}
+
+existential type WrongGeneric<T>: 'static;
+//~^ ERROR the parameter type `T` may not live long enough
+
+fn wrong_generic<T>(t: T) -> WrongGeneric<T> {
+    t
+}
+
+// don't reveal the concrete type
+existential type NoReveal: std::fmt::Debug;
+
+fn define_no_reveal() -> NoReveal {
+    ""
+}
+
+fn no_reveal(x: NoReveal) {
+    let _: &'static str = x; //~ mismatched types
+    let _ = x as &'static str; //~ non-primitive cast
+}
diff --git a/src/test/ui/existential_types/existential_type.stderr b/src/test/ui/existential_types/existential_type.stderr
new file mode 100644 (file)
index 0000000..3e74764
--- /dev/null
@@ -0,0 +1,120 @@
+error: defining existential type use differs from previous
+  --> $DIR/existential_type.rs:23:1
+   |
+LL | / fn bar() -> Foo { //~ ERROR defining existential type use differs from previous
+LL | |     42i32
+LL | | }
+   | |_^
+   |
+note: previous use here
+  --> $DIR/existential_type.rs:19:1
+   |
+LL | / fn foo() -> Foo {
+LL | |     ""
+LL | | }
+   | |_^
+
+error[E0308]: mismatched types
+  --> $DIR/existential_type.rs:36:5
+   |
+LL | fn bomp() -> boo::Boo {
+   |              -------- expected `Boo` because of return type
+LL |     "" //~ ERROR mismatched types
+   |     ^^ expected anonymized type, found reference
+   |
+   = note: expected type `Boo`
+              found type `&'static str`
+
+error[E0308]: mismatched types
+  --> $DIR/existential_type.rs:50:23
+   |
+LL |         let _: &str = bomp(); //~ ERROR mismatched types
+   |                       ^^^^^^ expected &str, found anonymized type
+   |
+   = note: expected type `&str`
+              found type `Boo`
+
+error[E0308]: mismatched types
+  --> $DIR/existential_type.rs:54:9
+   |
+LL |     fn bomp() -> boo::Boo {
+   |                  -------- expected `Boo` because of return type
+LL |         "" //~ ERROR mismatched types
+   |         ^^ expected anonymized type, found reference
+   |
+   = note: expected type `Boo`
+              found type `&'static str`
+
+error[E0277]: the trait bound `T: Trait` is not satisfied
+  --> $DIR/existential_type.rs:61:1
+   |
+LL | existential type Underconstrained<T: Trait>: 'static; //~ ERROR the trait bound `T: Trait`
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `T`
+   |
+   = help: consider adding a `where T: Trait` bound
+   = note: the return type of a function must have a statically known size
+
+error[E0310]: the parameter type `T` may not live long enough
+  --> $DIR/existential_type.rs:78:1
+   |
+LL | existential type WrongGeneric<T>: 'static;
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+...
+LL | fn wrong_generic<T>(t: T) -> WrongGeneric<T> {
+   |                  - help: consider adding an explicit lifetime bound `T: 'static`...
+   |
+note: ...so that the type `T` will meet its required lifetime bounds
+  --> $DIR/existential_type.rs:78:1
+   |
+LL | existential type WrongGeneric<T>: 'static;
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/existential_type.rs:93:27
+   |
+LL |     let _: &'static str = x; //~ mismatched types
+   |                           ^ expected reference, found anonymized type
+   |
+   = note: expected type `&'static str`
+              found type `NoReveal`
+
+error[E0605]: non-primitive cast: `NoReveal` as `&'static str`
+  --> $DIR/existential_type.rs:94:13
+   |
+LL |     let _ = x as &'static str; //~ non-primitive cast
+   |             ^^^^^^^^^^^^^^^^^
+   |
+   = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait
+
+error: could not find defining uses
+  --> $DIR/existential_type.rs:28:1
+   |
+LL | existential type Bar: std::fmt::Debug; //~ ERROR could not find defining uses
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: could not find defining uses
+  --> $DIR/existential_type.rs:32:5
+   |
+LL |     pub existential type Boo: ::std::fmt::Debug; //~ ERROR could not find defining uses
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: defining existential type use differs from previous
+  --> $DIR/existential_type.rs:74:1
+   |
+LL | / fn my_iter2<T>(t: T) -> MyIter<T> { //~ ERROR defining existential type use differs from previous
+LL | |     Some(t).into_iter()
+LL | | }
+   | |_^
+   |
+note: previous use here
+  --> $DIR/existential_type.rs:70:1
+   |
+LL | / fn my_iter<T>(t: T) -> MyIter<T> {
+LL | |     std::iter::once(t)
+LL | | }
+   | |_^
+
+error: aborting due to 11 previous errors
+
+Some errors occurred: E0277, E0308, E0310, E0605.
+For more information about an error, try `rustc --explain E0277`.
diff --git a/src/test/ui/existential_types/existential_type2.rs b/src/test/ui/existential_types/existential_type2.rs
new file mode 100644 (file)
index 0000000..bffb6b5
--- /dev/null
@@ -0,0 +1,30 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+
+#![feature(existential_type)]
+
+fn main() {}
+
+existential type Underconstrained<T: std::fmt::Debug>: 'static;
+//~^ ERROR `U` doesn't implement `std::fmt::Debug`
+
+// not a defining use, because it doesn't define *all* possible generics
+fn underconstrained<U>(_: U) -> Underconstrained<U> {
+    5u32
+}
+
+existential type Underconstrained2<T: std::fmt::Debug>: 'static;
+//~^ ERROR `V` doesn't implement `std::fmt::Debug`
+
+// not a defining use, because it doesn't define *all* possible generics
+fn underconstrained2<U, V>(_: U, _: V) -> Underconstrained2<V> {
+    5u32
+}
diff --git a/src/test/ui/existential_types/existential_type2.stderr b/src/test/ui/existential_types/existential_type2.stderr
new file mode 100644 (file)
index 0000000..53003a4
--- /dev/null
@@ -0,0 +1,23 @@
+error[E0277]: `U` doesn't implement `std::fmt::Debug`
+  --> $DIR/existential_type2.rs:16:1
+   |
+LL | existential type Underconstrained<T: std::fmt::Debug>: 'static;
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `U` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`
+   |
+   = help: the trait `std::fmt::Debug` is not implemented for `U`
+   = help: consider adding a `where U: std::fmt::Debug` bound
+   = note: the return type of a function must have a statically known size
+
+error[E0277]: `V` doesn't implement `std::fmt::Debug`
+  --> $DIR/existential_type2.rs:24:1
+   |
+LL | existential type Underconstrained2<T: std::fmt::Debug>: 'static;
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `V` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`
+   |
+   = help: the trait `std::fmt::Debug` is not implemented for `V`
+   = help: consider adding a `where V: std::fmt::Debug` bound
+   = note: the return type of a function must have a statically known size
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/existential_types/existential_type3.rs b/src/test/ui/existential_types/existential_type3.rs
new file mode 100644 (file)
index 0000000..b090cf2
--- /dev/null
@@ -0,0 +1,21 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+
+#![feature(existential_type)]
+
+fn main() {}
+
+existential type WrongGeneric<T: 'static>: 'static;
+
+fn wrong_generic<U: 'static, V: 'static>(_: U, v: V) -> WrongGeneric<U> {
+//~^ ERROR type parameter `V` is part of concrete type but not used in parameter list
+    v
+}
diff --git a/src/test/ui/existential_types/existential_type3.stderr b/src/test/ui/existential_types/existential_type3.stderr
new file mode 100644 (file)
index 0000000..9080072
--- /dev/null
@@ -0,0 +1,12 @@
+error: type parameter `V` is part of concrete type but not used in parameter list for existential type
+  --> $DIR/existential_type3.rs:18:73
+   |
+LL |   fn wrong_generic<U: 'static, V: 'static>(_: U, v: V) -> WrongGeneric<U> {
+   |  _________________________________________________________________________^
+LL | | //~^ ERROR type parameter `V` is part of concrete type but not used in parameter list
+LL | |     v
+LL | | }
+   | |_^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/existential_types/existential_type4.rs b/src/test/ui/existential_types/existential_type4.rs
new file mode 100644 (file)
index 0000000..a4b74d6
--- /dev/null
@@ -0,0 +1,21 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+
+#![feature(existential_type)]
+
+fn main() {}
+
+existential type Cmp<T>: 'static;
+
+// not a defining use, because it doesn't define *all* possible generics
+fn cmp() -> Cmp<u32> { //~ ERROR non-defining existential type use in defining scope
+    5u32
+}
diff --git a/src/test/ui/existential_types/existential_type4.stderr b/src/test/ui/existential_types/existential_type4.stderr
new file mode 100644 (file)
index 0000000..b119887
--- /dev/null
@@ -0,0 +1,16 @@
+error: non-defining existential type use in defining scope
+  --> $DIR/existential_type4.rs:19:1
+   |
+LL | / fn cmp() -> Cmp<u32> { //~ ERROR non-defining existential type use in defining scope
+LL | |     5u32
+LL | | }
+   | |_^
+   |
+note: used non-generic type u32 for generic parameter
+  --> $DIR/existential_type4.rs:16:22
+   |
+LL | existential type Cmp<T>: 'static;
+   |                      ^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/impl-trait/existential-associated-type.rs b/src/test/ui/impl-trait/existential-associated-type.rs
deleted file mode 100644 (file)
index af393fe..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#![feature(existential_type)]
-// compile-pass
-
-trait Bar {}
-struct Dummy;
-impl Bar for Dummy {}
-
-trait Foo {
-    type Assoc: Bar;
-    fn foo() -> Self::Assoc;
-    fn bar() -> Self::Assoc;
-}
-
-existential type Helper: Bar;
-
-impl Foo for i32 {
-    type Assoc = Helper;
-    fn foo() -> Helper {
-        Dummy
-    }
-    fn bar() -> Helper {
-        Dummy
-    }
-}
-
-fn main() {}