Skip to content

Commit f3ca1e1

Browse files
committed
Auto merge of #156295 - ChayimFriedman2:for-each-impl-args, r=<try>
Pass the whole `GenericArgs` to `Interner::for_each_relevant_impl()`
2 parents 3e353d7 + c9f8bab commit f3ca1e1

6 files changed

Lines changed: 19 additions & 4 deletions

File tree

compiler/rustc_middle/src/ty/context/impl_interner.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,9 +525,10 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
525525
fn for_each_relevant_impl(
526526
self,
527527
trait_def_id: DefId,
528-
self_ty: Ty<'tcx>,
528+
args: ty::GenericArgsRef<'tcx>,
529529
mut f: impl FnMut(DefId),
530530
) {
531+
let self_ty = args.type_at(0);
531532
let tcx = self;
532533
let trait_impls = tcx.trait_impls_of(trait_def_id);
533534
let mut consider_impls_for_simplified_type = |simp| {

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ where
5050
{
5151
fn self_ty(self) -> I::Ty;
5252

53+
fn args(self) -> I::GenericArgs;
54+
5355
fn trait_ref(self, cx: I) -> ty::TraitRef<I>;
5456

5557
fn with_replaced_self_ty(self, cx: I, self_ty: I::Ty) -> Self;
@@ -533,7 +535,7 @@ where
533535
let cx = self.cx();
534536
cx.for_each_relevant_impl(
535537
goal.predicate.trait_def_id(cx),
536-
goal.predicate.self_ty(),
538+
goal.predicate.args(),
537539
|impl_def_id| {
538540
// For every `default impl`, there's always a non-default `impl`
539541
// that will *also* apply. There's no reason to register a candidate

compiler/rustc_next_trait_solver/src/solve/effect_goals.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ where
2525
self.self_ty()
2626
}
2727

28+
fn args(self) -> I::GenericArgs {
29+
self.trait_ref.args
30+
}
31+
2832
fn trait_ref(self, _: I) -> ty::TraitRef<I> {
2933
self.trait_ref
3034
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ where
140140
self.self_ty()
141141
}
142142

143+
fn args(self) -> I::GenericArgs {
144+
self.alias.args
145+
}
146+
143147
fn trait_ref(self, cx: I) -> ty::TraitRef<I> {
144148
self.alias.trait_ref(cx)
145149
}

compiler/rustc_next_trait_solver/src/solve/trait_goals.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ where
3535
self.self_ty()
3636
}
3737

38+
fn args(self) -> I::GenericArgs {
39+
self.trait_ref.args
40+
}
41+
3842
fn trait_ref(self, _: I) -> ty::TraitRef<I> {
3943
self.trait_ref
4044
}
@@ -1230,7 +1234,7 @@ where
12301234
let mut disqualifying_impl = None;
12311235
self.cx().for_each_relevant_impl(
12321236
goal.predicate.def_id(),
1233-
goal.predicate.self_ty(),
1237+
goal.predicate.trait_ref.args,
12341238
|impl_def_id| {
12351239
disqualifying_impl = Some(impl_def_id);
12361240
},

compiler/rustc_type_ir/src/interner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ pub trait Interner:
404404
fn for_each_relevant_impl(
405405
self,
406406
trait_def_id: Self::TraitId,
407-
self_ty: Self::Ty,
407+
args: Self::GenericArgs,
408408
f: impl FnMut(Self::ImplId),
409409
);
410410
fn for_each_blanket_impl(self, trait_def_id: Self::TraitId, f: impl FnMut(Self::ImplId));

0 commit comments

Comments
 (0)