about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-11-30 19:53:20 +0100
committerGitHub <noreply@github.com>2022-11-30 19:53:20 +0100
commit6c4b5a2bdbe2b7ea4590c4715b9ede4a95e665c5 (patch)
treefd73ee2af33392fe662c993dd8f7e2cf031c7e3e /src/test
parentc56c377183a0d5e35cb1b3fa59f6adf62a3e6280 (diff)
parent42ff718d0fbc6f3c9a3386e65a16ab6c4ae89480 (diff)
downloadrust-6c4b5a2bdbe2b7ea4590c4715b9ede4a95e665c5.tar.gz
rust-6c4b5a2bdbe2b7ea4590c4715b9ede4a95e665c5.zip
Rollup merge of #105081 - weiznich:regression_test_for_104322, r=compiler-errors
Add a regression test for #104322

r? ``@compiler-errors``
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/traits/issue-104322.rs80
1 files changed, 80 insertions, 0 deletions
diff --git a/src/test/ui/traits/issue-104322.rs b/src/test/ui/traits/issue-104322.rs
new file mode 100644
index 00000000000..dcc27f1f03a
--- /dev/null
+++ b/src/test/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() {}