about summary refs log tree commit diff
path: root/src/test/ui/error-codes/e0119
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2019-05-24 22:07:35 +0100
committervarkor <github@varkor.com>2019-05-24 22:07:35 +0100
commitaea04009e47195caaf13701fbb042f9e7c6828bd (patch)
tree87aa4d25813420bde744d0ab0e0f2b57cecac89a /src/test/ui/error-codes/e0119
parentcb7e0d0dd3d3af62f76190d3f5f03332bb191023 (diff)
downloadrust-aea04009e47195caaf13701fbb042f9e7c6828bd.tar.gz
rust-aea04009e47195caaf13701fbb042f9e7c6828bd.zip
Move error code tests to error code folder
Diffstat (limited to 'src/test/ui/error-codes/e0119')
-rw-r--r--src/test/ui/error-codes/e0119/auxiliary/complex_impl_support.rs22
-rw-r--r--src/test/ui/error-codes/e0119/auxiliary/issue-23563-a.rs25
-rw-r--r--src/test/ui/error-codes/e0119/complex-impl.rs12
-rw-r--r--src/test/ui/error-codes/e0119/complex-impl.stderr22
-rw-r--r--src/test/ui/error-codes/e0119/conflict-with-std.rs26
-rw-r--r--src/test/ui/error-codes/e0119/conflict-with-std.stderr32
-rw-r--r--src/test/ui/error-codes/e0119/issue-23563.rs29
-rw-r--r--src/test/ui/error-codes/e0119/issue-23563.stderr13
-rw-r--r--src/test/ui/error-codes/e0119/issue-27403.rs11
-rw-r--r--src/test/ui/error-codes/e0119/issue-27403.stderr13
-rw-r--r--src/test/ui/error-codes/e0119/issue-28981.rs8
-rw-r--r--src/test/ui/error-codes/e0119/issue-28981.stderr22
-rw-r--r--src/test/ui/error-codes/e0119/so-37347311.rs17
-rw-r--r--src/test/ui/error-codes/e0119/so-37347311.stderr12
14 files changed, 264 insertions, 0 deletions
diff --git a/src/test/ui/error-codes/e0119/auxiliary/complex_impl_support.rs b/src/test/ui/error-codes/e0119/auxiliary/complex_impl_support.rs
new file mode 100644
index 00000000000..ad5bb107fc6
--- /dev/null
+++ b/src/test/ui/error-codes/e0119/auxiliary/complex_impl_support.rs
@@ -0,0 +1,22 @@
+use std::marker::PhantomData;
+
+pub trait External {}
+
+pub struct M<'a, 'b, 'c, T, U, V> {
+    a: PhantomData<&'a ()>,
+    b: PhantomData<&'b ()>,
+    c: PhantomData<&'c ()>,
+    d: PhantomData<T>,
+    e: PhantomData<U>,
+    f: PhantomData<V>,
+}
+
+impl<'a, 'b, 'c, T, U, V, W> External for (T, M<'a, 'b, 'c, Box<U>, V, W>)
+where
+    'b: 'a,
+    T: 'a,
+    U: (FnOnce(T) -> V) + 'static,
+    V: Iterator<Item=T> + Clone,
+    W: std::ops::Add,
+    W::Output: Copy,
+{}
diff --git a/src/test/ui/error-codes/e0119/auxiliary/issue-23563-a.rs b/src/test/ui/error-codes/e0119/auxiliary/issue-23563-a.rs
new file mode 100644
index 00000000000..4e85bcc4ba6
--- /dev/null
+++ b/src/test/ui/error-codes/e0119/auxiliary/issue-23563-a.rs
@@ -0,0 +1,25 @@
+// Ref: https://github.com/rust-lang/rust/issues/23563#issuecomment-260751672
+
+pub trait LolTo<T> {
+    fn convert_to(&self) -> T;
+}
+
+pub trait LolInto<T>: Sized {
+    fn convert_into(self) -> T;
+}
+
+pub trait LolFrom<T> {
+    fn from(T) -> Self;
+}
+
+impl<'a, T: ?Sized, U> LolInto<U> for &'a T where T: LolTo<U> {
+    fn convert_into(self) -> U {
+        self.convert_to()
+    }
+}
+
+impl<T, U> LolFrom<T> for U where T: LolInto<U> {
+    fn from(t: T) -> U {
+        t.convert_into()
+    }
+}
diff --git a/src/test/ui/error-codes/e0119/complex-impl.rs b/src/test/ui/error-codes/e0119/complex-impl.rs
new file mode 100644
index 00000000000..3cba39ecbf9
--- /dev/null
+++ b/src/test/ui/error-codes/e0119/complex-impl.rs
@@ -0,0 +1,12 @@
+// aux-build:complex_impl_support.rs
+
+extern crate complex_impl_support;
+
+use complex_impl_support::{External, M};
+
+struct Q;
+
+impl<R> External for (Q, R) {} //~ ERROR must be used
+//~^ ERROR conflicting implementations of trait
+
+fn main() {}
diff --git a/src/test/ui/error-codes/e0119/complex-impl.stderr b/src/test/ui/error-codes/e0119/complex-impl.stderr
new file mode 100644
index 00000000000..7ed89a5b1ae
--- /dev/null
+++ b/src/test/ui/error-codes/e0119/complex-impl.stderr
@@ -0,0 +1,22 @@
+error[E0119]: conflicting implementations of trait `complex_impl_support::External` for type `(Q, complex_impl_support::M<'_, '_, '_, std::boxed::Box<_>, _, _>)`:
+  --> $DIR/complex-impl.rs:9:1
+   |
+LL | impl<R> External for (Q, R) {}
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: conflicting implementation in crate `complex_impl_support`:
+           - impl<'a, 'b, 'c, T, U, V, W> complex_impl_support::External for (T, complex_impl_support::M<'a, 'b, 'c, std::boxed::Box<U>, V, W>)
+             where <U as std::ops::FnOnce<(T,)>>::Output == V, <V as std::iter::Iterator>::Item == T, 'b : 'a, T : 'a, U: std::ops::FnOnce<(T,)>, U : 'static, V: std::iter::Iterator, V: std::clone::Clone, W: std::ops::Add, <W as std::ops::Add>::Output: std::marker::Copy;
+
+error[E0210]: type parameter `R` must be used as the type parameter for some local type (e.g., `MyStruct<R>`)
+  --> $DIR/complex-impl.rs:9:1
+   |
+LL | impl<R> External for (Q, R) {}
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `R` must be used as the type parameter for some local type
+   |
+   = note: only traits defined in the current crate can be implemented for a type parameter
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0119, E0210.
+For more information about an error, try `rustc --explain E0119`.
diff --git a/src/test/ui/error-codes/e0119/conflict-with-std.rs b/src/test/ui/error-codes/e0119/conflict-with-std.rs
new file mode 100644
index 00000000000..c9db2bab183
--- /dev/null
+++ b/src/test/ui/error-codes/e0119/conflict-with-std.rs
@@ -0,0 +1,26 @@
+use std::marker::PhantomData;
+use std::convert::{TryFrom, AsRef};
+
+struct Q;
+impl AsRef<Q> for Box<Q> { //~ ERROR conflicting implementations
+    fn as_ref(&self) -> &Q {
+        &**self
+    }
+}
+
+struct S;
+impl From<S> for S { //~ ERROR conflicting implementations
+    fn from(s: S) -> S {
+        s
+    }
+}
+
+struct X;
+impl TryFrom<X> for X { //~ ERROR conflicting implementations
+    type Error = ();
+    fn try_from(u: X) -> Result<X, ()> {
+        Ok(u)
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/error-codes/e0119/conflict-with-std.stderr b/src/test/ui/error-codes/e0119/conflict-with-std.stderr
new file mode 100644
index 00000000000..3e0c71e9074
--- /dev/null
+++ b/src/test/ui/error-codes/e0119/conflict-with-std.stderr
@@ -0,0 +1,32 @@
+error[E0119]: conflicting implementations of trait `std::convert::AsRef<Q>` for type `std::boxed::Box<Q>`:
+  --> $DIR/conflict-with-std.rs:5:1
+   |
+LL | impl AsRef<Q> for Box<Q> {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: conflicting implementation in crate `alloc`:
+           - impl<T> std::convert::AsRef<T> for std::boxed::Box<T>
+             where T: ?Sized;
+
+error[E0119]: conflicting implementations of trait `std::convert::From<S>` for type `S`:
+  --> $DIR/conflict-with-std.rs:12:1
+   |
+LL | impl From<S> for S {
+   | ^^^^^^^^^^^^^^^^^^
+   |
+   = note: conflicting implementation in crate `core`:
+           - impl<T> std::convert::From<T> for T;
+
+error[E0119]: conflicting implementations of trait `std::convert::TryFrom<X>` for type `X`:
+  --> $DIR/conflict-with-std.rs:19:1
+   |
+LL | impl TryFrom<X> for X {
+   | ^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: conflicting implementation in crate `core`:
+           - impl<T, U> std::convert::TryFrom<U> for T
+             where U: std::convert::Into<T>;
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0119`.
diff --git a/src/test/ui/error-codes/e0119/issue-23563.rs b/src/test/ui/error-codes/e0119/issue-23563.rs
new file mode 100644
index 00000000000..f578560c552
--- /dev/null
+++ b/src/test/ui/error-codes/e0119/issue-23563.rs
@@ -0,0 +1,29 @@
+// aux-build:issue-23563-a.rs
+
+// Ref: https://github.com/rust-lang/rust/issues/23563#issuecomment-260751672
+
+extern crate issue_23563_a as a;
+
+use a::LolFrom;
+use a::LolInto;
+use a::LolTo;
+
+struct LocalType<T>(Option<T>);
+
+impl<'a, T> LolFrom<&'a [T]> for LocalType<T> { //~ ERROR conflicting implementations of trait
+    fn from(_: &'a [T]) -> LocalType<T> { LocalType(None) }
+}
+
+impl<T> LolInto<LocalType<T>> for LocalType<T> {
+    fn convert_into(self) -> LocalType<T> {
+        self
+    }
+}
+
+impl LolTo<LocalType<u8>> for [u8] {
+    fn convert_to(&self) -> LocalType<u8> {
+        LocalType(None)
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/error-codes/e0119/issue-23563.stderr b/src/test/ui/error-codes/e0119/issue-23563.stderr
new file mode 100644
index 00000000000..8011689880d
--- /dev/null
+++ b/src/test/ui/error-codes/e0119/issue-23563.stderr
@@ -0,0 +1,13 @@
+error[E0119]: conflicting implementations of trait `a::LolFrom<&[_]>` for type `LocalType<_>`:
+  --> $DIR/issue-23563.rs:13:1
+   |
+LL | impl<'a, T> LolFrom<&'a [T]> for LocalType<T> {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: conflicting implementation in crate `issue_23563_a`:
+           - impl<T, U> a::LolFrom<T> for U
+             where T: a::LolInto<U>;
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0119`.
diff --git a/src/test/ui/error-codes/e0119/issue-27403.rs b/src/test/ui/error-codes/e0119/issue-27403.rs
new file mode 100644
index 00000000000..b03a564ffd4
--- /dev/null
+++ b/src/test/ui/error-codes/e0119/issue-27403.rs
@@ -0,0 +1,11 @@
+pub struct GenX<S> {
+    inner: S,
+}
+
+impl<S> Into<S> for GenX<S> { //~ ERROR conflicting implementations
+    fn into(self) -> S {
+        self.inner
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/error-codes/e0119/issue-27403.stderr b/src/test/ui/error-codes/e0119/issue-27403.stderr
new file mode 100644
index 00000000000..cba10432a93
--- /dev/null
+++ b/src/test/ui/error-codes/e0119/issue-27403.stderr
@@ -0,0 +1,13 @@
+error[E0119]: conflicting implementations of trait `std::convert::Into<_>` for type `GenX<_>`:
+  --> $DIR/issue-27403.rs:5:1
+   |
+LL | impl<S> Into<S> for GenX<S> {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: conflicting implementation in crate `core`:
+           - impl<T, U> std::convert::Into<U> for T
+             where U: std::convert::From<T>;
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0119`.
diff --git a/src/test/ui/error-codes/e0119/issue-28981.rs b/src/test/ui/error-codes/e0119/issue-28981.rs
new file mode 100644
index 00000000000..c31b212b25a
--- /dev/null
+++ b/src/test/ui/error-codes/e0119/issue-28981.rs
@@ -0,0 +1,8 @@
+use std::ops::Deref;
+
+struct Foo;
+
+impl<Foo> Deref for Foo { } //~ ERROR must be used
+//~^ ERROR conflicting implementations
+
+fn main() {}
diff --git a/src/test/ui/error-codes/e0119/issue-28981.stderr b/src/test/ui/error-codes/e0119/issue-28981.stderr
new file mode 100644
index 00000000000..70c83e1412d
--- /dev/null
+++ b/src/test/ui/error-codes/e0119/issue-28981.stderr
@@ -0,0 +1,22 @@
+error[E0119]: conflicting implementations of trait `std::ops::Deref` for type `&_`:
+  --> $DIR/issue-28981.rs:5:1
+   |
+LL | impl<Foo> Deref for Foo { }
+   | ^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: conflicting implementation in crate `core`:
+           - impl<T> std::ops::Deref for &T
+             where T: ?Sized;
+
+error[E0210]: type parameter `Foo` must be used as the type parameter for some local type (e.g., `MyStruct<Foo>`)
+  --> $DIR/issue-28981.rs:5:1
+   |
+LL | impl<Foo> Deref for Foo { }
+   | ^^^^^^^^^^^^^^^^^^^^^^^ type parameter `Foo` must be used as the type parameter for some local type
+   |
+   = note: only traits defined in the current crate can be implemented for a type parameter
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0119, E0210.
+For more information about an error, try `rustc --explain E0119`.
diff --git a/src/test/ui/error-codes/e0119/so-37347311.rs b/src/test/ui/error-codes/e0119/so-37347311.rs
new file mode 100644
index 00000000000..d5f624bc4d9
--- /dev/null
+++ b/src/test/ui/error-codes/e0119/so-37347311.rs
@@ -0,0 +1,17 @@
+// Ref: https://stackoverflow.com/q/37347311
+
+trait Storage {
+    type Error;
+}
+
+enum MyError<S: Storage> {
+    StorageProblem(S::Error),
+}
+
+impl<S: Storage> From<S::Error> for MyError<S> { //~ ERROR conflicting implementations
+    fn from(error: S::Error) -> MyError<S> {
+        MyError::StorageProblem(error)
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/error-codes/e0119/so-37347311.stderr b/src/test/ui/error-codes/e0119/so-37347311.stderr
new file mode 100644
index 00000000000..f2166de71f8
--- /dev/null
+++ b/src/test/ui/error-codes/e0119/so-37347311.stderr
@@ -0,0 +1,12 @@
+error[E0119]: conflicting implementations of trait `std::convert::From<MyError<_>>` for type `MyError<_>`:
+  --> $DIR/so-37347311.rs:11:1
+   |
+LL | impl<S: Storage> From<S::Error> for MyError<S> {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: conflicting implementation in crate `core`:
+           - impl<T> std::convert::From<T> for T;
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0119`.