summaryrefslogtreecommitdiffstats
path: root/src/test/ui/coherence/auxiliary
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /src/test/ui/coherence/auxiliary
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/coherence/auxiliary')
-rw-r--r--src/test/ui/coherence/auxiliary/coherence_copy_like_lib.rs10
-rw-r--r--src/test/ui/coherence/auxiliary/coherence_fundamental_trait_lib.rs7
-rw-r--r--src/test/ui/coherence/auxiliary/coherence_inherent_cc_lib.rs11
-rw-r--r--src/test/ui/coherence/auxiliary/coherence_lib.rs15
-rw-r--r--src/test/ui/coherence/auxiliary/coherence_orphan_lib.rs3
-rw-r--r--src/test/ui/coherence/auxiliary/error_lib.rs6
-rw-r--r--src/test/ui/coherence/auxiliary/go_trait.rs43
-rw-r--r--src/test/ui/coherence/auxiliary/option_future.rs8
-rw-r--r--src/test/ui/coherence/auxiliary/re_rebalance_coherence_lib-rpass.rs31
-rw-r--r--src/test/ui/coherence/auxiliary/re_rebalance_coherence_lib.rs22
-rw-r--r--src/test/ui/coherence/auxiliary/trait_impl_conflict.rs6
11 files changed, 162 insertions, 0 deletions
diff --git a/src/test/ui/coherence/auxiliary/coherence_copy_like_lib.rs b/src/test/ui/coherence/auxiliary/coherence_copy_like_lib.rs
new file mode 100644
index 000000000..b5b4802c1
--- /dev/null
+++ b/src/test/ui/coherence/auxiliary/coherence_copy_like_lib.rs
@@ -0,0 +1,10 @@
+#![crate_type = "rlib"]
+#![feature(fundamental)]
+
+pub trait MyCopy { }
+impl MyCopy for i32 { }
+
+pub struct MyStruct<T>(T);
+
+#[fundamental]
+pub struct MyFundamentalStruct<T>(T);
diff --git a/src/test/ui/coherence/auxiliary/coherence_fundamental_trait_lib.rs b/src/test/ui/coherence/auxiliary/coherence_fundamental_trait_lib.rs
new file mode 100644
index 000000000..21aaea479
--- /dev/null
+++ b/src/test/ui/coherence/auxiliary/coherence_fundamental_trait_lib.rs
@@ -0,0 +1,7 @@
+#![crate_type = "rlib"]
+#![feature(fundamental)]
+
+pub trait Misc {}
+
+#[fundamental]
+pub trait Fundamental<T> {}
diff --git a/src/test/ui/coherence/auxiliary/coherence_inherent_cc_lib.rs b/src/test/ui/coherence/auxiliary/coherence_inherent_cc_lib.rs
new file mode 100644
index 000000000..08d22fbed
--- /dev/null
+++ b/src/test/ui/coherence/auxiliary/coherence_inherent_cc_lib.rs
@@ -0,0 +1,11 @@
+// See coherence_inherent_cc.rs
+
+pub trait TheTrait {
+ fn the_fn(&self);
+}
+
+pub struct TheStruct;
+
+impl TheTrait for TheStruct {
+ fn the_fn(&self) {}
+}
diff --git a/src/test/ui/coherence/auxiliary/coherence_lib.rs b/src/test/ui/coherence/auxiliary/coherence_lib.rs
new file mode 100644
index 000000000..c22819831
--- /dev/null
+++ b/src/test/ui/coherence/auxiliary/coherence_lib.rs
@@ -0,0 +1,15 @@
+#![crate_type="lib"]
+
+pub trait Remote {
+ fn foo(&self) { }
+}
+
+pub trait Remote1<T> {
+ fn foo(&self, _t: T) { }
+}
+
+pub trait Remote2<T, U> {
+ fn foo(&self, _t: T, _u: U) { }
+}
+
+pub struct Pair<T,U>(T,U);
diff --git a/src/test/ui/coherence/auxiliary/coherence_orphan_lib.rs b/src/test/ui/coherence/auxiliary/coherence_orphan_lib.rs
new file mode 100644
index 000000000..2664ef550
--- /dev/null
+++ b/src/test/ui/coherence/auxiliary/coherence_orphan_lib.rs
@@ -0,0 +1,3 @@
+pub trait TheTrait<T> {
+ fn the_fn(&self);
+}
diff --git a/src/test/ui/coherence/auxiliary/error_lib.rs b/src/test/ui/coherence/auxiliary/error_lib.rs
new file mode 100644
index 000000000..19ff9ae62
--- /dev/null
+++ b/src/test/ui/coherence/auxiliary/error_lib.rs
@@ -0,0 +1,6 @@
+#![crate_type = "lib"]
+#![feature(negative_impls)]
+#![feature(with_negative_coherence)]
+
+pub trait Error {}
+impl !Error for &str {}
diff --git a/src/test/ui/coherence/auxiliary/go_trait.rs b/src/test/ui/coherence/auxiliary/go_trait.rs
new file mode 100644
index 000000000..aa0ec2289
--- /dev/null
+++ b/src/test/ui/coherence/auxiliary/go_trait.rs
@@ -0,0 +1,43 @@
+#![feature(specialization)]
+
+// Common code used for tests that model the Fn/FnMut/FnOnce hierarchy.
+
+pub trait Go {
+ fn go(&self, arg: isize);
+}
+
+pub fn go<G:Go>(this: &G, arg: isize) {
+ this.go(arg)
+}
+
+pub trait GoMut {
+ fn go_mut(&mut self, arg: isize);
+}
+
+pub fn go_mut<G:GoMut>(this: &mut G, arg: isize) {
+ this.go_mut(arg)
+}
+
+pub trait GoOnce {
+ fn go_once(self, arg: isize);
+}
+
+pub fn go_once<G:GoOnce>(this: G, arg: isize) {
+ this.go_once(arg)
+}
+
+impl<G> GoMut for G
+ where G : Go
+{
+ default fn go_mut(&mut self, arg: isize) {
+ go(&*self, arg)
+ }
+}
+
+impl<G> GoOnce for G
+ where G : GoMut
+{
+ default fn go_once(mut self, arg: isize) {
+ go_mut(&mut self, arg)
+ }
+}
diff --git a/src/test/ui/coherence/auxiliary/option_future.rs b/src/test/ui/coherence/auxiliary/option_future.rs
new file mode 100644
index 000000000..067de1cd8
--- /dev/null
+++ b/src/test/ui/coherence/auxiliary/option_future.rs
@@ -0,0 +1,8 @@
+#![crate_type = "lib"]
+#![feature(negative_impls)]
+#![feature(rustc_attrs)]
+#![feature(with_negative_coherence)]
+
+pub trait Future {}
+
+impl<E> !Future for Option<E> where E: Sized {}
diff --git a/src/test/ui/coherence/auxiliary/re_rebalance_coherence_lib-rpass.rs b/src/test/ui/coherence/auxiliary/re_rebalance_coherence_lib-rpass.rs
new file mode 100644
index 000000000..9a191bad8
--- /dev/null
+++ b/src/test/ui/coherence/auxiliary/re_rebalance_coherence_lib-rpass.rs
@@ -0,0 +1,31 @@
+pub trait Backend {}
+pub trait SupportsDefaultKeyword {}
+
+impl SupportsDefaultKeyword for Postgres {}
+
+pub struct Postgres;
+
+impl Backend for Postgres {}
+
+pub struct AstPass<DB>(::std::marker::PhantomData<DB>);
+
+pub trait QueryFragment<DB: Backend> {}
+
+
+#[derive(Debug, Clone, Copy)]
+pub struct BatchInsert<'a, T: 'a, Tab> {
+ _marker: ::std::marker::PhantomData<(&'a T, Tab)>,
+}
+
+impl<'a, T:'a, Tab, DB> QueryFragment<DB> for BatchInsert<'a, T, Tab>
+where DB: SupportsDefaultKeyword + Backend,
+{}
+
+pub trait LibToOwned {
+ type Owned;
+}
+
+pub struct LibCow<T: LibToOwned, Owned = <T as LibToOwned>::Owned> {
+ pub t: T,
+ pub o: Owned,
+}
diff --git a/src/test/ui/coherence/auxiliary/re_rebalance_coherence_lib.rs b/src/test/ui/coherence/auxiliary/re_rebalance_coherence_lib.rs
new file mode 100644
index 000000000..41b9d64d5
--- /dev/null
+++ b/src/test/ui/coherence/auxiliary/re_rebalance_coherence_lib.rs
@@ -0,0 +1,22 @@
+pub trait Backend {}
+pub trait SupportsDefaultKeyword {}
+
+impl SupportsDefaultKeyword for Postgres {}
+
+pub struct Postgres;
+
+impl Backend for Postgres {}
+
+pub struct AstPass<DB>(::std::marker::PhantomData<DB>);
+
+pub trait QueryFragment<DB: Backend> {}
+
+
+#[derive(Debug, Clone, Copy)]
+pub struct BatchInsert<'a, T: 'a, Tab> {
+ _marker: ::std::marker::PhantomData<(&'a T, Tab)>,
+}
+
+impl<'a, T:'a, Tab, DB> QueryFragment<DB> for BatchInsert<'a, T, Tab>
+where DB: SupportsDefaultKeyword + Backend,
+{}
diff --git a/src/test/ui/coherence/auxiliary/trait_impl_conflict.rs b/src/test/ui/coherence/auxiliary/trait_impl_conflict.rs
new file mode 100644
index 000000000..5e5f017ed
--- /dev/null
+++ b/src/test/ui/coherence/auxiliary/trait_impl_conflict.rs
@@ -0,0 +1,6 @@
+pub trait Foo {
+ fn foo() {}
+}
+
+impl Foo for isize {
+}