From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- .../e0119/auxiliary/complex_impl_support.rs | 22 +++++++++++++++ .../error-codes/e0119/auxiliary/issue-23563-a.rs | 25 +++++++++++++++++ src/test/ui/error-codes/e0119/complex-impl.rs | 11 ++++++++ src/test/ui/error-codes/e0119/complex-impl.stderr | 14 ++++++++++ src/test/ui/error-codes/e0119/conflict-with-std.rs | 26 ++++++++++++++++++ .../ui/error-codes/e0119/conflict-with-std.stderr | 32 ++++++++++++++++++++++ src/test/ui/error-codes/e0119/issue-23563.rs | 29 ++++++++++++++++++++ src/test/ui/error-codes/e0119/issue-23563.stderr | 13 +++++++++ src/test/ui/error-codes/e0119/issue-27403.rs | 11 ++++++++ src/test/ui/error-codes/e0119/issue-27403.stderr | 13 +++++++++ src/test/ui/error-codes/e0119/issue-28981.rs | 7 +++++ src/test/ui/error-codes/e0119/issue-28981.stderr | 12 ++++++++ src/test/ui/error-codes/e0119/so-37347311.rs | 17 ++++++++++++ src/test/ui/error-codes/e0119/so-37347311.stderr | 12 ++++++++ 14 files changed, 244 insertions(+) create mode 100644 src/test/ui/error-codes/e0119/auxiliary/complex_impl_support.rs create mode 100644 src/test/ui/error-codes/e0119/auxiliary/issue-23563-a.rs create mode 100644 src/test/ui/error-codes/e0119/complex-impl.rs create mode 100644 src/test/ui/error-codes/e0119/complex-impl.stderr create mode 100644 src/test/ui/error-codes/e0119/conflict-with-std.rs create mode 100644 src/test/ui/error-codes/e0119/conflict-with-std.stderr create mode 100644 src/test/ui/error-codes/e0119/issue-23563.rs create mode 100644 src/test/ui/error-codes/e0119/issue-23563.stderr create mode 100644 src/test/ui/error-codes/e0119/issue-27403.rs create mode 100644 src/test/ui/error-codes/e0119/issue-27403.stderr create mode 100644 src/test/ui/error-codes/e0119/issue-28981.rs create mode 100644 src/test/ui/error-codes/e0119/issue-28981.stderr create mode 100644 src/test/ui/error-codes/e0119/so-37347311.rs create mode 100644 src/test/ui/error-codes/e0119/so-37347311.stderr (limited to 'src/test/ui/error-codes/e0119') 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 000000000..ad5bb107f --- /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, + e: PhantomData, + f: PhantomData, +} + +impl<'a, 'b, 'c, T, U, V, W> External for (T, M<'a, 'b, 'c, Box, V, W>) +where + 'b: 'a, + T: 'a, + U: (FnOnce(T) -> V) + 'static, + V: Iterator + 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 000000000..141f36369 --- /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 { + fn convert_to(&self) -> T; +} + +pub trait LolInto: Sized { + fn convert_into(self) -> T; +} + +pub trait LolFrom { + fn from(_: T) -> Self; +} + +impl<'a, T: ?Sized, U> LolInto for &'a T where T: LolTo { + fn convert_into(self) -> U { + self.convert_to() + } +} + +impl LolFrom for U where T: LolInto { + 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 000000000..9149e4ce5 --- /dev/null +++ b/src/test/ui/error-codes/e0119/complex-impl.rs @@ -0,0 +1,11 @@ +// aux-build:complex_impl_support.rs + +extern crate complex_impl_support; + +use complex_impl_support::{External, M}; + +struct Q; + +impl External for (Q, R) {} //~ ERROR only traits defined + +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 000000000..654073eec --- /dev/null +++ b/src/test/ui/error-codes/e0119/complex-impl.stderr @@ -0,0 +1,14 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/complex-impl.rs:9:1 + | +LL | impl External for (Q, R) {} + | ^^^^^^^^^^^^^^^^^^^^^------ + | | | + | | this is not defined in the current crate because tuples are always foreign + | impl doesn't use only types from inside the current crate + | + = note: define and implement a trait or new type instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0117`. 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 000000000..c9db2bab1 --- /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 for Box { //~ ERROR conflicting implementations + fn as_ref(&self) -> &Q { + &**self + } +} + +struct S; +impl From for S { //~ ERROR conflicting implementations + fn from(s: S) -> S { + s + } +} + +struct X; +impl TryFrom for X { //~ ERROR conflicting implementations + type Error = (); + fn try_from(u: X) -> Result { + 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 000000000..3ff96a6a4 --- /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` for type `std::boxed::Box` + --> $DIR/conflict-with-std.rs:5:1 + | +LL | impl AsRef for Box { + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: conflicting implementation in crate `alloc`: + - impl AsRef for Box + where A: Allocator, T: ?Sized; + +error[E0119]: conflicting implementations of trait `std::convert::From` for type `S` + --> $DIR/conflict-with-std.rs:12:1 + | +LL | impl From for S { + | ^^^^^^^^^^^^^^^^^^ + | + = note: conflicting implementation in crate `core`: + - impl From for T; + +error[E0119]: conflicting implementations of trait `std::convert::TryFrom` for type `X` + --> $DIR/conflict-with-std.rs:19:1 + | +LL | impl TryFrom for X { + | ^^^^^^^^^^^^^^^^^^^^^ + | + = note: conflicting implementation in crate `core`: + - impl TryFrom for T + where U: Into; + +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 000000000..f578560c5 --- /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(Option); + +impl<'a, T> LolFrom<&'a [T]> for LocalType { //~ ERROR conflicting implementations of trait + fn from(_: &'a [T]) -> LocalType { LocalType(None) } +} + +impl LolInto> for LocalType { + fn convert_into(self) -> LocalType { + self + } +} + +impl LolTo> for [u8] { + fn convert_to(&self) -> LocalType { + 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 000000000..f149cef58 --- /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 { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: conflicting implementation in crate `issue_23563_a`: + - impl LolFrom for U + where T: LolInto; + +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 000000000..b03a564ff --- /dev/null +++ b/src/test/ui/error-codes/e0119/issue-27403.rs @@ -0,0 +1,11 @@ +pub struct GenX { + inner: S, +} + +impl Into for GenX { //~ 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 000000000..c11a50487 --- /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 Into for GenX { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: conflicting implementation in crate `core`: + - impl Into for T + where U: From; + +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 000000000..5fb7e9a99 --- /dev/null +++ b/src/test/ui/error-codes/e0119/issue-28981.rs @@ -0,0 +1,7 @@ +use std::ops::Deref; + +struct Foo; + +impl Deref for Foo { } //~ ERROR must be used + +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 000000000..97b570bc7 --- /dev/null +++ b/src/test/ui/error-codes/e0119/issue-28981.stderr @@ -0,0 +1,12 @@ +error[E0210]: type parameter `Foo` must be used as the type parameter for some local type (e.g., `MyStruct`) + --> $DIR/issue-28981.rs:5:6 + | +LL | impl Deref for Foo { } + | ^^^ type parameter `Foo` must be used as the type parameter for some local type + | + = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local + = note: only traits defined in the current crate can be implemented for a type parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0210`. 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 000000000..d5f624bc4 --- /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 { + StorageProblem(S::Error), +} + +impl From for MyError { //~ ERROR conflicting implementations + fn from(error: S::Error) -> MyError { + 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 000000000..f1c2b0d29 --- /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>` for type `MyError<_>` + --> $DIR/so-37347311.rs:11:1 + | +LL | impl From for MyError { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: conflicting implementation in crate `core`: + - impl From for T; + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. -- cgit v1.2.3