• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // build-pass
2 //
3 // Tests that overflows do not occur in certain situations
4 // related to generic diesel code
5 
6 use mini_diesel::*;
7 
8 pub trait HandleDelete<K> {}
9 
handle_delete<D, R>() where R: HasTable, R::Table: HandleDelete<D> + 'static,10 pub fn handle_delete<D, R>()
11 where
12     R: HasTable,
13     R::Table: HandleDelete<D> + 'static,
14 {
15 }
16 
17 impl<K, T> HandleDelete<K> for T
18 where
19     T: Table + HasTable<Table = T> + 'static,
20     K: 'static,
21     &'static K: Identifiable<Table = T>,
22     T::PrimaryKey: EqAll<<&'static K as Identifiable>::Id>,
23     T::Query: FilterDsl<<T::PrimaryKey as EqAll<<&'static K as Identifiable>::Id>>::Output>,
24     Filter<T::Query, <T::PrimaryKey as EqAll<<&'static K as Identifiable>::Id>>::Output>:
25         IntoUpdateTarget<Table = T>,
26 {
27 }
28 
29 mod mini_diesel {
30     pub trait HasTable {
31         type Table: Table;
32     }
33 
34     pub trait Identifiable: HasTable {
35         type Id;
36     }
37 
38     pub trait EqAll<Rhs> {
39         type Output;
40     }
41 
42     pub trait IntoUpdateTarget: HasTable {
43         type WhereClause;
44     }
45 
46     pub trait Query {
47         type SqlType;
48     }
49 
50     pub trait AsQuery {
51         type Query: Query;
52     }
53     impl<T: Query> AsQuery for T {
54         type Query = Self;
55     }
56 
57     pub trait FilterDsl<Predicate> {
58         type Output;
59     }
60 
61     impl<T, Predicate> FilterDsl<Predicate> for T
62     where
63         T: Table,
64         T::Query: FilterDsl<Predicate>,
65     {
66         type Output = Filter<T::Query, Predicate>;
67     }
68 
69     pub trait QuerySource {
70         type FromClause;
71     }
72 
73     pub trait Table: QuerySource + AsQuery + Sized {
74         type PrimaryKey;
75     }
76 
77     pub type Filter<Source, Predicate> = <Source as FilterDsl<Predicate>>::Output;
78 }
79 
main()80 fn main() {}
81