Skip to content

Commit

Permalink
Make super combine into fns
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Oct 10, 2024
1 parent a4cd220 commit 8715bfb
Show file tree
Hide file tree
Showing 5 changed files with 193 additions and 202 deletions.
8 changes: 4 additions & 4 deletions compiler/rustc_borrowck/src/type_check/relate_tys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use rustc_middle::span_bug;
use rustc_middle::traits::ObligationCause;
use rustc_middle::traits::query::NoSolution;
use rustc_middle::ty::fold::FnMutDelegate;
use rustc_middle::ty::relate::combine::InferCtxtCombineExt;
use rustc_middle::ty::relate::combine::{super_combine_consts, super_combine_tys};
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt};
use rustc_span::symbol::sym;
use rustc_span::{Span, Symbol};
Expand Down Expand Up @@ -363,7 +363,7 @@ impl<'b, 'tcx> TypeRelation<TyCtxt<'tcx>> for NllTypeRelating<'_, 'b, 'tcx> {
&ty::Alias(ty::Opaque, ty::AliasTy { def_id: a_def_id, .. }),
&ty::Alias(ty::Opaque, ty::AliasTy { def_id: b_def_id, .. }),
) if a_def_id == b_def_id || infcx.next_trait_solver() => {
infcx.super_combine_tys(self, a, b).map(|_| ()).or_else(|err| {
super_combine_tys(&infcx.infcx, self, a, b).map(|_| ()).or_else(|err| {
// This behavior is only there for the old solver, the new solver
// shouldn't ever fail. Instead, it unconditionally emits an
// alias-relate goal.
Expand All @@ -386,7 +386,7 @@ impl<'b, 'tcx> TypeRelation<TyCtxt<'tcx>> for NllTypeRelating<'_, 'b, 'tcx> {
debug!(?a, ?b, ?self.ambient_variance);

// Will also handle unification of `IntVar` and `FloatVar`.
self.type_checker.infcx.super_combine_tys(self, a, b)?;
super_combine_tys(&self.type_checker.infcx.infcx, self, a, b)?;
}
}

Expand Down Expand Up @@ -423,7 +423,7 @@ impl<'b, 'tcx> TypeRelation<TyCtxt<'tcx>> for NllTypeRelating<'_, 'b, 'tcx> {
assert!(!a.has_non_region_infer(), "unexpected inference var {:?}", a);
assert!(!b.has_non_region_infer(), "unexpected inference var {:?}", b);

self.type_checker.infcx.super_combine_consts(self, a, b)
super_combine_consts(&self.type_checker.infcx.infcx, self, a, b)
}

#[instrument(skip(self), level = "trace")]
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_infer/src/infer/relate/lattice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
//! [lattices]: https://en.wikipedia.org/wiki/Lattice_(order)
use rustc_middle::traits::solve::Goal;
use rustc_middle::ty::relate::combine::InferCtxtCombineExt;
use rustc_middle::ty::relate::combine::{super_combine_consts, super_combine_tys};
use rustc_middle::ty::relate::{Relate, RelateResult, TypeRelation};
use rustc_middle::ty::{self, Ty, TyCtxt, TyVar, TypeVisitableExt};
use rustc_span::Span;
Expand Down Expand Up @@ -149,7 +149,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for LatticeOp<'_, 'tcx> {
(
&ty::Alias(ty::Opaque, ty::AliasTy { def_id: a_def_id, .. }),
&ty::Alias(ty::Opaque, ty::AliasTy { def_id: b_def_id, .. }),
) if a_def_id == b_def_id => infcx.super_combine_tys(self, a, b),
) if a_def_id == b_def_id => super_combine_tys(infcx, self, a, b),

(&ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }), _)
| (_, &ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }))
Expand All @@ -164,7 +164,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for LatticeOp<'_, 'tcx> {
Ok(a)
}

_ => infcx.super_combine_tys(self, a, b),
_ => super_combine_tys(infcx, self, a, b),
}
}

Expand Down Expand Up @@ -192,7 +192,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for LatticeOp<'_, 'tcx> {
a: ty::Const<'tcx>,
b: ty::Const<'tcx>,
) -> RelateResult<'tcx, ty::Const<'tcx>> {
self.infcx.super_combine_consts(self, a, b)
super_combine_consts(self.infcx, self, a, b)
}

fn binders<T>(
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_infer/src/infer/relate/type_relating.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use rustc_middle::traits::solve::Goal;
use rustc_middle::ty::relate::combine::InferCtxtCombineExt;
use rustc_middle::ty::relate::combine::{super_combine_consts, super_combine_tys};
use rustc_middle::ty::relate::{
Relate, RelateResult, TypeRelation, relate_args_invariantly, relate_args_with_variances,
};
Expand Down Expand Up @@ -186,7 +186,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for TypeRelating<'_, 'tcx> {
&ty::Alias(ty::Opaque, ty::AliasTy { def_id: a_def_id, .. }),
&ty::Alias(ty::Opaque, ty::AliasTy { def_id: b_def_id, .. }),
) if a_def_id == b_def_id => {
infcx.super_combine_tys(self, a, b)?;
super_combine_tys(infcx, self, a, b)?;
}

(&ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }), _)
Expand All @@ -202,7 +202,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for TypeRelating<'_, 'tcx> {
}

_ => {
infcx.super_combine_tys(self, a, b)?;
super_combine_tys(infcx, self, a, b)?;
}
}

Expand Down Expand Up @@ -257,7 +257,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for TypeRelating<'_, 'tcx> {
a: ty::Const<'tcx>,
b: ty::Const<'tcx>,
) -> RelateResult<'tcx, ty::Const<'tcx>> {
self.infcx.super_combine_consts(self, a, b)
super_combine_consts(self.infcx, self, a, b)
}

fn binders<T>(
Expand Down
Loading

0 comments on commit 8715bfb

Please sign in to comment.