Skip to content

Commit aa5c381

Browse files
Uplift super_combine
1 parent d02efe7 commit aa5c381

File tree

13 files changed

+376
-305
lines changed

13 files changed

+376
-305
lines changed

compiler/rustc_borrowck/src/type_check/relate_tys.rs

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use rustc_middle::span_bug;
1111
use rustc_middle::traits::ObligationCause;
1212
use rustc_middle::traits::query::NoSolution;
1313
use rustc_middle::ty::fold::FnMutDelegate;
14+
use rustc_middle::ty::relate::combine::InferCtxtCombineExt;
1415
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt};
1516
use rustc_span::symbol::sym;
1617
use rustc_span::{Span, Symbol};

compiler/rustc_infer/src/infer/context.rs

+65-4
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
///! Definition of `InferCtxtLike` from the librarified type layer.
22
use rustc_hir::def_id::{DefId, LocalDefId};
3+
use rustc_middle::infer::unify_key::EffectVarValue;
34
use rustc_middle::traits::ObligationCause;
45
use rustc_middle::traits::solve::{Goal, NoSolution, SolverMode};
56
use rustc_middle::ty::fold::TypeFoldable;
7+
use rustc_middle::ty::relate::combine::PredicateEmittingRelation;
8+
use rustc_middle::ty::relate::{Relate, RelateResult};
69
use rustc_middle::ty::{self, Ty, TyCtxt};
7-
use rustc_span::DUMMY_SP;
8-
use rustc_type_ir::InferCtxtLike;
9-
use rustc_type_ir::relate::Relate;
10+
use rustc_span::{DUMMY_SP, ErrorGuaranteed};
1011

1112
use super::{BoundRegionConversionTime, InferCtxt, SubregionOrigin};
1213

13-
impl<'tcx> InferCtxtLike for InferCtxt<'tcx> {
14+
impl<'tcx> rustc_type_ir::InferCtxtLike for InferCtxt<'tcx> {
1415
type Interner = TyCtxt<'tcx>;
1516

1617
fn cx(&self) -> TyCtxt<'tcx> {
1718
self.tcx
1819
}
1920

21+
fn next_trait_solver(&self) -> bool {
22+
self.next_trait_solver
23+
}
24+
2025
fn solver_mode(&self) -> ty::solve::SolverMode {
2126
match self.intercrate {
2227
true => SolverMode::Coherence,
@@ -131,6 +136,59 @@ impl<'tcx> InferCtxtLike for InferCtxt<'tcx> {
131136
self.enter_forall(value, f)
132137
}
133138

139+
fn equate_int_vids_raw(&self, a: rustc_type_ir::IntVid, b: rustc_type_ir::IntVid) {
140+
self.inner.borrow_mut().int_unification_table().union(a, b);
141+
}
142+
143+
fn equate_float_vids_raw(&self, a: rustc_type_ir::FloatVid, b: rustc_type_ir::FloatVid) {
144+
self.inner.borrow_mut().float_unification_table().union(a, b);
145+
}
146+
147+
fn equate_const_vids_raw(&self, a: rustc_type_ir::ConstVid, b: rustc_type_ir::ConstVid) {
148+
self.inner.borrow_mut().const_unification_table().union(a, b);
149+
}
150+
151+
fn equate_effect_vids_raw(&self, a: rustc_type_ir::EffectVid, b: rustc_type_ir::EffectVid) {
152+
self.inner.borrow_mut().effect_unification_table().union(a, b);
153+
}
154+
155+
fn instantiate_int_var_raw(
156+
&self,
157+
vid: rustc_type_ir::IntVid,
158+
value: rustc_type_ir::IntVarValue,
159+
) {
160+
self.inner.borrow_mut().int_unification_table().union_value(vid, value);
161+
}
162+
163+
fn instantiate_float_var_raw(
164+
&self,
165+
vid: rustc_type_ir::FloatVid,
166+
value: rustc_type_ir::FloatVarValue,
167+
) {
168+
self.inner.borrow_mut().float_unification_table().union_value(vid, value);
169+
}
170+
171+
fn instantiate_effect_var_raw(&self, vid: rustc_type_ir::EffectVid, value: ty::Const<'tcx>) {
172+
self.inner
173+
.borrow_mut()
174+
.effect_unification_table()
175+
.union_value(vid, EffectVarValue::Known(value));
176+
}
177+
178+
fn instantiate_const_var_raw<R: PredicateEmittingRelation<Self>>(
179+
&self,
180+
relation: &mut R,
181+
target_is_expected: bool,
182+
target_vid: rustc_type_ir::ConstVid,
183+
source_ct: ty::Const<'tcx>,
184+
) -> RelateResult<'tcx, ()> {
185+
self.instantiate_const_var(relation, target_is_expected, target_vid, source_ct)
186+
}
187+
188+
fn set_tainted_by_errors(&self, e: ErrorGuaranteed) {
189+
self.set_tainted_by_errors(e)
190+
}
191+
134192
fn relate<T: Relate<TyCtxt<'tcx>>>(
135193
&self,
136194
param_env: ty::ParamEnv<'tcx>,
@@ -154,6 +212,9 @@ impl<'tcx> InferCtxtLike for InferCtxt<'tcx> {
154212
fn shallow_resolve(&self, ty: Ty<'tcx>) -> Ty<'tcx> {
155213
self.shallow_resolve(ty)
156214
}
215+
fn shallow_resolve_const(&self, ct: ty::Const<'tcx>) -> ty::Const<'tcx> {
216+
self.shallow_resolve_const(ct)
217+
}
157218

158219
fn resolve_vars_if_possible<T>(&self, value: T) -> T
159220
where

compiler/rustc_infer/src/infer/relate/combine.rs

-245
This file was deleted.

compiler/rustc_infer/src/infer/relate/generalize.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ impl<'tcx> InferCtxt<'tcx> {
181181
///
182182
/// See `tests/ui/const-generics/occurs-check/` for more examples where this is relevant.
183183
#[instrument(level = "debug", skip(self, relation))]
184-
pub(super) fn instantiate_const_var<R: PredicateEmittingRelation<InferCtxt<'tcx>>>(
184+
pub(crate) fn instantiate_const_var<R: PredicateEmittingRelation<InferCtxt<'tcx>>>(
185185
&self,
186186
relation: &mut R,
187187
target_is_expected: bool,

compiler/rustc_infer/src/infer/relate/lattice.rs

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
//! [lattices]: https://en.wikipedia.org/wiki/Lattice_(order)
1919
2020
use rustc_middle::traits::solve::Goal;
21+
use rustc_middle::ty::relate::combine::InferCtxtCombineExt;
2122
use rustc_middle::ty::relate::{Relate, RelateResult, TypeRelation};
2223
use rustc_middle::ty::{self, Ty, TyCtxt, TyVar, TypeVisitableExt};
2324
use rustc_span::Span;

compiler/rustc_infer/src/infer/relate/mod.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33
//! As well as the implementation of `Relate` for interned things (`Ty`/`Const`/etc).
44
55
pub use rustc_middle::ty::relate::RelateResult;
6-
pub use rustc_next_trait_solver::relate::*;
7-
8-
pub use self::combine::PredicateEmittingRelation;
6+
pub use rustc_type_ir::relate::combine::PredicateEmittingRelation;
7+
pub use rustc_type_ir::relate::*;
98

109
#[allow(hidden_glob_reexports)]
11-
pub(super) mod combine;
1210
mod generalize;
1311
mod higher_ranked;
1412
pub(super) mod lattice;

compiler/rustc_infer/src/infer/relate/type_relating.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use rustc_middle::traits::solve::Goal;
2+
use rustc_middle::ty::relate::combine::InferCtxtCombineExt;
23
use rustc_middle::ty::relate::{
34
Relate, RelateResult, TypeRelation, relate_args_invariantly, relate_args_with_variances,
45
};

0 commit comments

Comments
 (0)