@@ -261,9 +261,14 @@ impl<'tcx, O: Elaboratable<'tcx>> Elaborator<'tcx, O> {
261261 fn elaborate ( & mut self , elaboratable : & O ) {
262262 let tcx = self . visited . tcx ;
263263
264- let bound_predicate = elaboratable. predicate ( ) . kind ( ) ;
265- match bound_predicate. skip_binder ( ) {
266- ty:: PredicateKind :: Clause ( ty:: ClauseKind :: Trait ( data) ) => {
264+ // We only elaborate clauses.
265+ let Some ( clause) = elaboratable. predicate ( ) . as_clause ( ) else {
266+ return ;
267+ } ;
268+
269+ let bound_clause = clause. kind ( ) ;
270+ match bound_clause. skip_binder ( ) {
271+ ty:: ClauseKind :: Trait ( data) => {
267272 // Negative trait bounds do not imply any supertrait bounds
268273 if data. polarity == ty:: ImplPolarity :: Negative {
269274 return ;
@@ -280,49 +285,16 @@ impl<'tcx, O: Elaboratable<'tcx>> Elaborator<'tcx, O> {
280285 let obligations =
281286 predicates. predicates . iter ( ) . enumerate ( ) . map ( |( index, & ( clause, span) ) | {
282287 elaboratable. child_with_derived_cause (
283- clause. subst_supertrait ( tcx, & bound_predicate . rebind ( data. trait_ref ) ) ,
288+ clause. subst_supertrait ( tcx, & bound_clause . rebind ( data. trait_ref ) ) ,
284289 span,
285- bound_predicate . rebind ( data) ,
290+ bound_clause . rebind ( data) ,
286291 index,
287292 )
288293 } ) ;
289294 debug ! ( ?data, ?obligations, "super_predicates" ) ;
290295 self . extend_deduped ( obligations) ;
291296 }
292- ty:: PredicateKind :: Clause ( ty:: ClauseKind :: WellFormed ( ..) ) => {
293- // Currently, we do not elaborate WF predicates,
294- // although we easily could.
295- }
296- ty:: PredicateKind :: ObjectSafe ( ..) => {
297- // Currently, we do not elaborate object-safe
298- // predicates.
299- }
300- ty:: PredicateKind :: Subtype ( ..) => {
301- // Currently, we do not "elaborate" predicates like `X <: Y`,
302- // though conceivably we might.
303- }
304- ty:: PredicateKind :: Coerce ( ..) => {
305- // Currently, we do not "elaborate" predicates like `X -> Y`,
306- // though conceivably we might.
307- }
308- ty:: PredicateKind :: Clause ( ty:: ClauseKind :: Projection ( ..) ) => {
309- // Nothing to elaborate in a projection predicate.
310- }
311- ty:: PredicateKind :: Clause ( ty:: ClauseKind :: ConstEvaluatable ( ..) ) => {
312- // Currently, we do not elaborate const-evaluatable
313- // predicates.
314- }
315- ty:: PredicateKind :: ConstEquate ( ..) => {
316- // Currently, we do not elaborate const-equate
317- // predicates.
318- }
319- ty:: PredicateKind :: Clause ( ty:: ClauseKind :: RegionOutlives ( ..) ) => {
320- // Nothing to elaborate from `'a: 'b`.
321- }
322- ty:: PredicateKind :: Clause ( ty:: ClauseKind :: TypeOutlives ( ty:: OutlivesPredicate (
323- ty_max,
324- r_min,
325- ) ) ) => {
297+ ty:: ClauseKind :: TypeOutlives ( ty:: OutlivesPredicate ( ty_max, r_min) ) => {
326298 // We know that `T: 'a` for some type `T`. We can
327299 // often elaborate this. For example, if we know that
328300 // `[U]: 'a`, that implies that `U: 'a`. Similarly, if
@@ -385,15 +357,25 @@ impl<'tcx, O: Elaboratable<'tcx>> Elaborator<'tcx, O> {
385357 }
386358 } )
387359 . map ( |clause| {
388- elaboratable. child ( bound_predicate . rebind ( clause) . to_predicate ( tcx) )
360+ elaboratable. child ( bound_clause . rebind ( clause) . to_predicate ( tcx) )
389361 } ) ,
390362 ) ;
391363 }
392- ty:: PredicateKind :: Ambiguous => { }
393- ty:: PredicateKind :: AliasRelate ( ..) => {
394- // No
364+ ty:: ClauseKind :: RegionOutlives ( ..) => {
365+ // Nothing to elaborate from `'a: 'b`.
366+ }
367+ ty:: ClauseKind :: WellFormed ( ..) => {
368+ // Currently, we do not elaborate WF predicates,
369+ // although we easily could.
370+ }
371+ ty:: ClauseKind :: Projection ( ..) => {
372+ // Nothing to elaborate in a projection predicate.
373+ }
374+ ty:: ClauseKind :: ConstEvaluatable ( ..) => {
375+ // Currently, we do not elaborate const-evaluatable
376+ // predicates.
395377 }
396- ty:: PredicateKind :: Clause ( ty :: ClauseKind :: ConstArgHasType ( ..) ) => {
378+ ty:: ClauseKind :: ConstArgHasType ( ..) => {
397379 // Nothing to elaborate
398380 }
399381 }
0 commit comments