Skip to content

Commit 6c4b5a2

Browse files
authored
Rollup merge of rust-lang#105081 - weiznich:regression_test_for_104322, r=compiler-errors
Add a regression test for rust-lang#104322 r? ``@compiler-errors``
2 parents c56c377 + 42ff718 commit 6c4b5a2

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

src/test/ui/traits/issue-104322.rs

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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+
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+
80+
fn main() {}

0 commit comments

Comments
 (0)