File tree 1 file changed +20
-3
lines changed
src/librustc_traits/chalk_context 1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -155,12 +155,29 @@ impl context::AggregateOps<ChalkArenas<'gcx>> for ChalkContext<'cx, 'gcx> {
155
155
}
156
156
157
157
impl context:: ContextOps < ChalkArenas < ' gcx > > for ChalkContext < ' cx , ' gcx > {
158
- /// True if this is a coinductive goal -- e.g., proving an auto trait.
158
+ /// True if this is a coinductive goal: basically proving that an auto trait
159
+ /// is implemented or proving that a trait reference is well-formed.
159
160
fn is_coinductive (
160
161
& self ,
161
- _goal : & Canonical < ' gcx , InEnvironment < ' gcx , Goal < ' gcx > > >
162
+ goal : & Canonical < ' gcx , InEnvironment < ' gcx , Goal < ' gcx > > >
162
163
) -> bool {
163
- unimplemented ! ( )
164
+ use rustc:: traits:: { WellFormed , WhereClause } ;
165
+
166
+ let mut goal = goal. value . goal ;
167
+ loop {
168
+ match goal {
169
+ GoalKind :: DomainGoal ( domain_goal) => match domain_goal {
170
+ DomainGoal :: WellFormed ( WellFormed :: Trait ( ..) ) => return true ,
171
+ DomainGoal :: Holds ( WhereClause :: Implemented ( trait_predicate) ) => {
172
+ return self . tcx . trait_is_auto ( trait_predicate. def_id ( ) ) ;
173
+ }
174
+ _ => return false ,
175
+ }
176
+
177
+ GoalKind :: Quantified ( _, bound_goal) => goal = * bound_goal. skip_binder ( ) ,
178
+ _ => return false ,
179
+ }
180
+ }
164
181
}
165
182
166
183
/// Create an inference table for processing a new goal and instantiate that goal
You can’t perform that action at this time.
0 commit comments