summaryrefslogtreecommitdiffstats
path: root/tests/ui/traits/issue-104322.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
commit64d98f8ee037282c35007b64c2649055c56af1db (patch)
tree5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /tests/ui/traits/issue-104322.rs
parentAdding debian version 1.67.1+dfsg1-1. (diff)
downloadrustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz
rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/traits/issue-104322.rs')
-rw-r--r--tests/ui/traits/issue-104322.rs80
1 files changed, 80 insertions, 0 deletions
diff --git a/tests/ui/traits/issue-104322.rs b/tests/ui/traits/issue-104322.rs
new file mode 100644
index 000000000..dcc27f1f0
--- /dev/null
+++ b/tests/ui/traits/issue-104322.rs
@@ -0,0 +1,80 @@
+// build-pass
+//
+// Tests that overflows do not occur in certain situations
+// related to generic diesel code
+
+use mini_diesel::*;
+
+pub trait HandleDelete<K> {}
+
+pub fn handle_delete<D, R>()
+where
+ R: HasTable,
+ R::Table: HandleDelete<D> + 'static,
+{
+}
+
+impl<K, T> HandleDelete<K> for T
+where
+ T: Table + HasTable<Table = T> + 'static,
+ K: 'static,
+ &'static K: Identifiable<Table = T>,
+ T::PrimaryKey: EqAll<<&'static K as Identifiable>::Id>,
+ T::Query: FilterDsl<<T::PrimaryKey as EqAll<<&'static K as Identifiable>::Id>>::Output>,
+ Filter<T::Query, <T::PrimaryKey as EqAll<<&'static K as Identifiable>::Id>>::Output>:
+ IntoUpdateTarget<Table = T>,
+{
+}
+
+mod mini_diesel {
+ pub trait HasTable {
+ type Table: Table;
+ }
+
+ pub trait Identifiable: HasTable {
+ type Id;
+ }
+
+ pub trait EqAll<Rhs> {
+ type Output;
+ }
+
+ pub trait IntoUpdateTarget: HasTable {
+ type WhereClause;
+ }
+
+ pub trait Query {
+ type SqlType;
+ }
+
+ pub trait AsQuery {
+ type Query: Query;
+ }
+ impl<T: Query> AsQuery for T {
+ type Query = Self;
+ }
+
+ pub trait FilterDsl<Predicate> {
+ type Output;
+ }
+
+ impl<T, Predicate> FilterDsl<Predicate> for T
+ where
+ T: Table,
+ T::Query: FilterDsl<Predicate>,
+ {
+ type Output = Filter<T::Query, Predicate>;
+ }
+
+ pub trait QuerySource {
+ type FromClause;
+ }
+
+ pub trait Table: QuerySource + AsQuery + Sized {
+ type PrimaryKey;
+ }
+
+ pub type Filter<Source, Predicate> = <Source as FilterDsl<Predicate>>::Output;
+}
+
+fn main() {}