1 // revisions: rfail1 rfail2
2 // failure-status: 101
3 // error-pattern: not implemented
4 // needs-unwind -Cpanic=abort causes abort instead of exit(101)
5
6 pub trait Interner {
7 type InternedVariableKinds;
8 }
9
10 trait RustIrDatabase<I: Interner> {
associated_ty_data(&self) -> AssociatedTyDatum<I>11 fn associated_ty_data(&self) -> AssociatedTyDatum<I>;
impl_datum(&self) -> ImplDatum<I>12 fn impl_datum(&self) -> ImplDatum<I>;
13 }
14
15 trait Fold<I: Interner> {
16 type Result;
17 }
18 impl<T, I: Interner> Fold<I> for Binders<T>
19 where
20 T: HasInterner<Interner = I> + Fold<I>,
21 <T as Fold<I>>::Result: HasInterner<Interner = I>,
22 I: Interner,
23 {
24 type Result = Binders<T::Result>;
25 }
26 impl<I: Interner> Fold<I> for WhereClause<I> {
27 type Result = Binders<WhereClause<I>>;
28 }
29
30 trait HasInterner {
31 type Interner: Interner;
32 }
33 impl<T: HasInterner> HasInterner for Vec<T> {
34 type Interner = T::Interner;
35 }
36 impl<T: HasInterner + ?Sized> HasInterner for &T {
37 type Interner = T::Interner;
38 }
39
40 pub struct VariableKind<I: Interner> {
41 _marker: std::marker::PhantomData<I>,
42 }
43
44 struct VariableKinds<I: Interner> {
45 _interned: I::InternedVariableKinds,
46 }
47
48 struct WhereClause<I: Interner> {
49 _marker: std::marker::PhantomData<I>,
50 }
51 impl<I: Interner> HasInterner for WhereClause<I> {
52 type Interner = I;
53 }
54
55 struct Binders<T> {
56 _marker: std::marker::PhantomData<T>,
57 }
58 impl<T: HasInterner> HasInterner for Binders<T> {
59 type Interner = T::Interner;
60 }
61 impl<T> Binders<&T> {
cloned(self) -> Binders<T>62 fn cloned(self) -> Binders<T> {
63 unimplemented!()
64 }
65 }
66 impl<T: HasInterner> Binders<T> {
map_ref<'a, U, OP>(&'a self, _op: OP) -> Binders<U> where OP: FnOnce(&'a T) -> U, U: HasInterner<Interner = T::Interner>,67 fn map_ref<'a, U, OP>(&'a self, _op: OP) -> Binders<U>
68 where
69 OP: FnOnce(&'a T) -> U,
70 U: HasInterner<Interner = T::Interner>,
71 {
72 unimplemented!()
73 }
74 }
75 impl<T, I: Interner> Binders<T>
76 where
77 T: Fold<I> + HasInterner<Interner = I>,
78 I: Interner,
79 {
substitute(self) -> T::Result80 fn substitute(self) -> T::Result {
81 unimplemented!()
82 }
83 }
84 impl<V, U> IntoIterator for Binders<V>
85 where
86 V: HasInterner + IntoIterator<Item = U>,
87 U: HasInterner<Interner = V::Interner>,
88 {
89 type Item = Binders<U>;
90 type IntoIter = BindersIntoIterator<V>;
into_iter(self) -> Self::IntoIter91 fn into_iter(self) -> Self::IntoIter {
92 unimplemented!()
93 }
94 }
95 struct BindersIntoIterator<V: HasInterner> {
96 _binders: VariableKinds<V::Interner>,
97 }
98 impl<V> Iterator for BindersIntoIterator<V>
99 where
100 V: HasInterner + IntoIterator,
101 <V as IntoIterator>::Item: HasInterner<Interner = V::Interner>,
102 {
103 type Item = Binders<<V as IntoIterator>::Item>;
next(&mut self) -> Option<Self::Item>104 fn next(&mut self) -> Option<Self::Item> {
105 unimplemented!()
106 }
107 }
108
109 struct ImplDatum<I: Interner> {
110 binders: Binders<ImplDatumBound<I>>,
111 }
112 struct ImplDatumBound<I: Interner> {
113 where_clauses: Vec<Binders<WhereClause<I>>>,
114 }
115 impl<I: Interner> HasInterner for ImplDatumBound<I> {
116 type Interner = I;
117 }
118
119 struct AssociatedTyDatum<I: Interner> {
120 binders: Binders<AssociatedTyDatumBound<I>>,
121 }
122
123 struct AssociatedTyDatumBound<I: Interner> {
124 where_clauses: Vec<Binders<WhereClause<I>>>,
125 }
126 impl<I: Interner> HasInterner for AssociatedTyDatumBound<I> {
127 type Interner = I;
128 }
129
130 struct ClauseBuilder<'me, I: Interner> {
131 db: &'me dyn RustIrDatabase<I>,
132 }
133 impl<'me, I: Interner> ClauseBuilder<'me, I> {
new() -> Self134 fn new() -> Self {
135 unimplemented!()
136 }
push_clause(&mut self, _conditions: impl Iterator<Item = Binders<Binders<WhereClause<I>>>>)137 fn push_clause(&mut self, _conditions: impl Iterator<Item = Binders<Binders<WhereClause<I>>>>) {
138 unimplemented!()
139 }
140 }
141
142 pub(crate) struct Forest<I: Interner> {
143 _marker: std::marker::PhantomData<I>,
144 }
145
146 impl<I: Interner> Forest<I> {
iter_answers<'f>(&'f self)147 fn iter_answers<'f>(&'f self) {
148 let builder = &mut ClauseBuilder::<I>::new();
149 let impl_datum = builder.db.impl_datum();
150 let impl_where_clauses = impl_datum
151 .binders
152 .map_ref(|b| &b.where_clauses)
153 .into_iter()
154 .map(|wc| wc.cloned().substitute());
155 let associated_ty = builder.db.associated_ty_data();
156 let assoc_ty_where_clauses = associated_ty
157 .binders
158 .map_ref(|b| &b.where_clauses)
159 .into_iter()
160 .map(|wc| wc.cloned().substitute());
161 builder.push_clause(impl_where_clauses.chain(assoc_ty_where_clauses));
162 }
163 }
164
165 pub struct SLGSolver {
166 pub(crate) forest: Forest<ChalkIr>,
167 }
168 impl SLGSolver {
new() -> Self169 fn new() -> Self {
170 unimplemented!()
171 }
solve_multiple(&self)172 fn solve_multiple(&self) {
173 let _answers = self.forest.iter_answers();
174 }
175 }
176
177 pub struct ChalkIr;
178 impl Interner for ChalkIr {
179 type InternedVariableKinds = Vec<VariableKind<ChalkIr>>;
180 }
181
main()182 fn main() {
183 let solver = SLGSolver::new();
184 solver.solve_multiple();
185 }
186