From 218caa410aa38c29984be31a5229b9fa717560ee Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:13 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- .../coherence/auxiliary/coherence_copy_like_lib.rs | 10 +++++ .../auxiliary/coherence_fundamental_trait_lib.rs | 7 ++++ .../auxiliary/coherence_inherent_cc_lib.rs | 11 ++++++ tests/ui/coherence/auxiliary/coherence_lib.rs | 15 ++++++++ .../ui/coherence/auxiliary/coherence_orphan_lib.rs | 3 ++ tests/ui/coherence/auxiliary/error_lib.rs | 6 +++ tests/ui/coherence/auxiliary/go_trait.rs | 43 ++++++++++++++++++++++ tests/ui/coherence/auxiliary/option_future.rs | 8 ++++ .../auxiliary/re_rebalance_coherence_lib-rpass.rs | 31 ++++++++++++++++ .../auxiliary/re_rebalance_coherence_lib.rs | 22 +++++++++++ .../coherence/auxiliary/trait-with-const-param.rs | 1 + .../ui/coherence/auxiliary/trait_impl_conflict.rs | 6 +++ 12 files changed, 163 insertions(+) create mode 100644 tests/ui/coherence/auxiliary/coherence_copy_like_lib.rs create mode 100644 tests/ui/coherence/auxiliary/coherence_fundamental_trait_lib.rs create mode 100644 tests/ui/coherence/auxiliary/coherence_inherent_cc_lib.rs create mode 100644 tests/ui/coherence/auxiliary/coherence_lib.rs create mode 100644 tests/ui/coherence/auxiliary/coherence_orphan_lib.rs create mode 100644 tests/ui/coherence/auxiliary/error_lib.rs create mode 100644 tests/ui/coherence/auxiliary/go_trait.rs create mode 100644 tests/ui/coherence/auxiliary/option_future.rs create mode 100644 tests/ui/coherence/auxiliary/re_rebalance_coherence_lib-rpass.rs create mode 100644 tests/ui/coherence/auxiliary/re_rebalance_coherence_lib.rs create mode 100644 tests/ui/coherence/auxiliary/trait-with-const-param.rs create mode 100644 tests/ui/coherence/auxiliary/trait_impl_conflict.rs (limited to 'tests/ui/coherence/auxiliary') diff --git a/tests/ui/coherence/auxiliary/coherence_copy_like_lib.rs b/tests/ui/coherence/auxiliary/coherence_copy_like_lib.rs new file mode 100644 index 000000000..b5b4802c1 --- /dev/null +++ b/tests/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); + +#[fundamental] +pub struct MyFundamentalStruct(T); diff --git a/tests/ui/coherence/auxiliary/coherence_fundamental_trait_lib.rs b/tests/ui/coherence/auxiliary/coherence_fundamental_trait_lib.rs new file mode 100644 index 000000000..21aaea479 --- /dev/null +++ b/tests/ui/coherence/auxiliary/coherence_fundamental_trait_lib.rs @@ -0,0 +1,7 @@ +#![crate_type = "rlib"] +#![feature(fundamental)] + +pub trait Misc {} + +#[fundamental] +pub trait Fundamental {} diff --git a/tests/ui/coherence/auxiliary/coherence_inherent_cc_lib.rs b/tests/ui/coherence/auxiliary/coherence_inherent_cc_lib.rs new file mode 100644 index 000000000..08d22fbed --- /dev/null +++ b/tests/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/tests/ui/coherence/auxiliary/coherence_lib.rs b/tests/ui/coherence/auxiliary/coherence_lib.rs new file mode 100644 index 000000000..c22819831 --- /dev/null +++ b/tests/ui/coherence/auxiliary/coherence_lib.rs @@ -0,0 +1,15 @@ +#![crate_type="lib"] + +pub trait Remote { + fn foo(&self) { } +} + +pub trait Remote1 { + fn foo(&self, _t: T) { } +} + +pub trait Remote2 { + fn foo(&self, _t: T, _u: U) { } +} + +pub struct Pair(T,U); diff --git a/tests/ui/coherence/auxiliary/coherence_orphan_lib.rs b/tests/ui/coherence/auxiliary/coherence_orphan_lib.rs new file mode 100644 index 000000000..2664ef550 --- /dev/null +++ b/tests/ui/coherence/auxiliary/coherence_orphan_lib.rs @@ -0,0 +1,3 @@ +pub trait TheTrait { + fn the_fn(&self); +} diff --git a/tests/ui/coherence/auxiliary/error_lib.rs b/tests/ui/coherence/auxiliary/error_lib.rs new file mode 100644 index 000000000..19ff9ae62 --- /dev/null +++ b/tests/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/tests/ui/coherence/auxiliary/go_trait.rs b/tests/ui/coherence/auxiliary/go_trait.rs new file mode 100644 index 000000000..aa0ec2289 --- /dev/null +++ b/tests/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(this: &G, arg: isize) { + this.go(arg) +} + +pub trait GoMut { + fn go_mut(&mut self, arg: isize); +} + +pub fn go_mut(this: &mut G, arg: isize) { + this.go_mut(arg) +} + +pub trait GoOnce { + fn go_once(self, arg: isize); +} + +pub fn go_once(this: G, arg: isize) { + this.go_once(arg) +} + +impl GoMut for G + where G : Go +{ + default fn go_mut(&mut self, arg: isize) { + go(&*self, arg) + } +} + +impl GoOnce for G + where G : GoMut +{ + default fn go_once(mut self, arg: isize) { + go_mut(&mut self, arg) + } +} diff --git a/tests/ui/coherence/auxiliary/option_future.rs b/tests/ui/coherence/auxiliary/option_future.rs new file mode 100644 index 000000000..067de1cd8 --- /dev/null +++ b/tests/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 !Future for Option where E: Sized {} diff --git a/tests/ui/coherence/auxiliary/re_rebalance_coherence_lib-rpass.rs b/tests/ui/coherence/auxiliary/re_rebalance_coherence_lib-rpass.rs new file mode 100644 index 000000000..9a191bad8 --- /dev/null +++ b/tests/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(::std::marker::PhantomData); + +pub trait QueryFragment {} + + +#[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 for BatchInsert<'a, T, Tab> +where DB: SupportsDefaultKeyword + Backend, +{} + +pub trait LibToOwned { + type Owned; +} + +pub struct LibCow::Owned> { + pub t: T, + pub o: Owned, +} diff --git a/tests/ui/coherence/auxiliary/re_rebalance_coherence_lib.rs b/tests/ui/coherence/auxiliary/re_rebalance_coherence_lib.rs new file mode 100644 index 000000000..41b9d64d5 --- /dev/null +++ b/tests/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(::std::marker::PhantomData); + +pub trait QueryFragment {} + + +#[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 for BatchInsert<'a, T, Tab> +where DB: SupportsDefaultKeyword + Backend, +{} diff --git a/tests/ui/coherence/auxiliary/trait-with-const-param.rs b/tests/ui/coherence/auxiliary/trait-with-const-param.rs new file mode 100644 index 000000000..a44eb14f8 --- /dev/null +++ b/tests/ui/coherence/auxiliary/trait-with-const-param.rs @@ -0,0 +1 @@ +pub trait Trait {} diff --git a/tests/ui/coherence/auxiliary/trait_impl_conflict.rs b/tests/ui/coherence/auxiliary/trait_impl_conflict.rs new file mode 100644 index 000000000..5e5f017ed --- /dev/null +++ b/tests/ui/coherence/auxiliary/trait_impl_conflict.rs @@ -0,0 +1,6 @@ +pub trait Foo { + fn foo() {} +} + +impl Foo for isize { +} -- cgit v1.2.3