Skip to content

Commit ee22f44

Browse files
committed
i dunno
1 parent 25e8aa3 commit ee22f44

File tree

1 file changed

+40
-25
lines changed
  • compiler/rustc_next_trait_solver/src/solve/assembly

1 file changed

+40
-25
lines changed

compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs

Lines changed: 40 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ use rustc_type_ir::inherent::*;
88
use rustc_type_ir::lang_items::TraitSolverLangItem;
99
use rustc_type_ir::solve::inspect;
1010
use rustc_type_ir::visit::TypeVisitableExt as _;
11-
use rustc_type_ir::{self as ty, Interner, TypingMode, Upcast as _, elaborate};
11+
use rustc_type_ir::{
12+
self as ty, AliasTy, EarlyBinder, Interner, TypingMode, Upcast as _, elaborate,
13+
};
1214
use tracing::{debug, instrument};
1315

1416
use super::trait_goals::TraitGoalProvenVia;
@@ -594,36 +596,49 @@ where
594596
}
595597
};
596598

597-
match consider_self_bounds {
598-
AliasBoundKind::SelfBounds => {
599-
for assumption in self
600-
.cx()
601-
.item_self_bounds(alias_ty.def_id)
602-
.iter_instantiated(self.cx(), alias_ty.args)
603-
{
604-
candidates.extend(G::probe_and_consider_implied_clause(
605-
self,
599+
fn probe_and_consider_implied_clause<'e, 'd, D, I, G, C, B>(
600+
ecx: &'e mut EvalCtxt<'d, D, I>,
601+
alias_ty: AliasTy<I>,
602+
bounds: B,
603+
goal: Goal<I, G>,
604+
) -> impl Iterator<Item = Candidate<I>> + use<'e, 'd, D, I, G, C, B>
605+
where
606+
D: SolverDelegate<Interner = I>,
607+
I: Interner,
608+
G: GoalKind<D>,
609+
C: IntoIterator<Item = I::Clause>,
610+
B: Fn(I, I::DefId) -> EarlyBinder<I, C>,
611+
{
612+
bounds(ecx.cx(), alias_ty.def_id).iter_instantiated(ecx.cx(), alias_ty.args).filter_map(
613+
move |assumption| {
614+
G::probe_and_consider_implied_clause(
615+
ecx,
606616
CandidateSource::AliasBound,
607617
goal,
608618
assumption,
609619
[],
610-
));
611-
}
620+
)
621+
.ok()
622+
},
623+
)
624+
}
625+
626+
match consider_self_bounds {
627+
AliasBoundKind::SelfBounds => {
628+
candidates.extend(probe_and_consider_implied_clause(
629+
self,
630+
alias_ty,
631+
Interner::item_self_bounds,
632+
goal,
633+
));
612634
}
613635
AliasBoundKind::NonSelfBounds => {
614-
for assumption in self
615-
.cx()
616-
.item_non_self_bounds(alias_ty.def_id)
617-
.iter_instantiated(self.cx(), alias_ty.args)
618-
{
619-
candidates.extend(G::probe_and_consider_implied_clause(
620-
self,
621-
CandidateSource::AliasBound,
622-
goal,
623-
assumption,
624-
[],
625-
));
626-
}
636+
candidates.extend(probe_and_consider_implied_clause(
637+
self,
638+
alias_ty,
639+
Interner::item_non_self_bounds,
640+
goal,
641+
));
627642
}
628643
}
629644

0 commit comments

Comments
 (0)