@@ -19,6 +19,11 @@ use crate::solve::{
19
19
MaybeCause , NoSolution , QueryResult ,
20
20
} ;
21
21
22
+ enum AliasBoundKind {
23
+ SelfBounds ,
24
+ NonSelfBounds ,
25
+ }
26
+
22
27
/// A candidate is a possible way to prove a goal.
23
28
///
24
29
/// It consists of both the `source`, which describes how that goal would be proven,
@@ -510,7 +515,12 @@ where
510
515
candidates : & mut Vec < Candidate < I > > ,
511
516
) {
512
517
let ( ) = self . probe ( |_| ProbeKind :: NormalizedSelfTyAssembly ) . enter ( |ecx| {
513
- ecx. assemble_alias_bound_candidates_recur ( goal. predicate . self_ty ( ) , goal, candidates) ;
518
+ ecx. assemble_alias_bound_candidates_recur (
519
+ goal. predicate . self_ty ( ) ,
520
+ goal,
521
+ candidates,
522
+ AliasBoundKind :: SelfBounds ,
523
+ ) ;
514
524
} ) ;
515
525
}
516
526
@@ -528,6 +538,7 @@ where
528
538
self_ty : I :: Ty ,
529
539
goal : Goal < I , G > ,
530
540
candidates : & mut Vec < Candidate < I > > ,
541
+ consider_self_bounds : AliasBoundKind ,
531
542
) {
532
543
let ( kind, alias_ty) = match self_ty. kind ( ) {
533
544
ty:: Bool
@@ -580,16 +591,37 @@ where
580
591
}
581
592
} ;
582
593
583
- for assumption in
584
- self . cx ( ) . item_bounds ( alias_ty. def_id ) . iter_instantiated ( self . cx ( ) , alias_ty. args )
585
- {
586
- candidates. extend ( G :: probe_and_consider_implied_clause (
587
- self ,
588
- CandidateSource :: AliasBound ,
589
- goal,
590
- assumption,
591
- [ ] ,
592
- ) ) ;
594
+ match consider_self_bounds {
595
+ AliasBoundKind :: SelfBounds => {
596
+ for assumption in self
597
+ . cx ( )
598
+ . item_self_bounds ( alias_ty. def_id )
599
+ . iter_instantiated ( self . cx ( ) , alias_ty. args )
600
+ {
601
+ candidates. extend ( G :: probe_and_consider_implied_clause (
602
+ self ,
603
+ CandidateSource :: AliasBound ,
604
+ goal,
605
+ assumption,
606
+ [ ] ,
607
+ ) ) ;
608
+ }
609
+ }
610
+ AliasBoundKind :: NonSelfBounds => {
611
+ for assumption in self
612
+ . cx ( )
613
+ . item_non_self_bounds ( alias_ty. def_id )
614
+ . iter_instantiated ( self . cx ( ) , alias_ty. args )
615
+ {
616
+ candidates. extend ( G :: probe_and_consider_implied_clause (
617
+ self ,
618
+ CandidateSource :: AliasBound ,
619
+ goal,
620
+ assumption,
621
+ [ ] ,
622
+ ) ) ;
623
+ }
624
+ }
593
625
}
594
626
595
627
candidates. extend ( G :: consider_additional_alias_assumptions ( self , goal, alias_ty) ) ;
@@ -600,9 +632,12 @@ where
600
632
601
633
// Recurse on the self type of the projection.
602
634
match self . structurally_normalize_ty ( goal. param_env , alias_ty. self_ty ( ) ) {
603
- Ok ( next_self_ty) => {
604
- self . assemble_alias_bound_candidates_recur ( next_self_ty, goal, candidates)
605
- }
635
+ Ok ( next_self_ty) => self . assemble_alias_bound_candidates_recur (
636
+ next_self_ty,
637
+ goal,
638
+ candidates,
639
+ AliasBoundKind :: NonSelfBounds ,
640
+ ) ,
606
641
Err ( NoSolution ) => { }
607
642
}
608
643
}
0 commit comments