Skip to content

Commit efb1c23

Browse files
Introduce SolverRelating
1 parent ce7a61b commit efb1c23

8 files changed

Lines changed: 387 additions & 4 deletions

File tree

‎compiler/rustc_infer/src/infer/context.rs‎

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ impl<'tcx> rustc_type_ir::InferCtxtLike for InferCtxt<'tcx> {
136136
self.enter_forall(value, f)
137137
}
138138

139+
fnequate_ty_vids_raw(&self,a: rustc_type_ir::TyVid,b: rustc_type_ir::TyVid){
140+
self.inner.borrow_mut().type_variables().equate(a, b);
141+
}
142+
139143
fnequate_int_vids_raw(&self,a: rustc_type_ir::IntVid,b: rustc_type_ir::IntVid){
140144
self.inner.borrow_mut().int_unification_table().union(a, b);
141145
}
@@ -152,6 +156,23 @@ impl<'tcx> rustc_type_ir::InferCtxtLike for InferCtxt<'tcx> {
152156
self.inner.borrow_mut().effect_unification_table().union(a, b);
153157
}
154158

159+
fninstantiate_ty_var_raw<R:PredicateEmittingRelation<Self>>(
160+
&self,
161+
relation:&mutR,
162+
target_is_expected:bool,
163+
target_vid: rustc_type_ir::TyVid,
164+
instantiation_variance: rustc_type_ir::Variance,
165+
source_ty:Ty<'tcx>,
166+
) -> RelateResult<'tcx,()>{
167+
self.instantiate_ty_var(
168+
relation,
169+
target_is_expected,
170+
target_vid,
171+
instantiation_variance,
172+
source_ty,
173+
)
174+
}
175+
155176
fninstantiate_int_var_raw(
156177
&self,
157178
vid: rustc_type_ir::IntVid,
@@ -228,7 +249,19 @@ impl<'tcx> rustc_type_ir::InferCtxtLike for InferCtxt<'tcx> {
228249
}
229250

230251
fnsub_regions(&self,sub: ty::Region<'tcx>,sup: ty::Region<'tcx>){
231-
self.sub_regions(SubregionOrigin::RelateRegionParamBound(DUMMY_SP,None), sub, sup)
252+
self.inner.borrow_mut().unwrap_region_constraints().make_subregion(
253+
SubregionOrigin::RelateRegionParamBound(DUMMY_SP,None),
254+
sub,
255+
sup,
256+
);
257+
}
258+
259+
fnequate_regions(&self,a: ty::Region<'tcx>,b: ty::Region<'tcx>){
260+
self.inner.borrow_mut().unwrap_region_constraints().make_eqregion(
261+
SubregionOrigin::RelateRegionParamBound(DUMMY_SP,None),
262+
a,
263+
b,
264+
);
232265
}
233266

234267
fnregister_ty_outlives(&self,ty:Ty<'tcx>,r: ty::Region<'tcx>){

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,12 @@ impl<'tcx> rustc_type_ir::inherent::Features<TyCtxt<'tcx>> for &'tcx rustc_featu
698698
}
699699
}
700700

701+
impl<'tcx> rustc_type_ir::inherent::Span<TyCtxt<'tcx>>forSpan{
702+
fndummy() -> Self{
703+
DUMMY_SP
704+
}
705+
}
706+
701707
typeInternedSet<'tcx,T> = ShardedHashMap<InternedInSet<'tcx,T>,()>;
702708

703709
pubstructCtxtInterners<'tcx>{

‎compiler/rustc_type_ir/src/infer_ctxt.rs‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,20 @@ pub trait InferCtxtLike: Sized {
6767
f:implFnOnce(T) -> U,
6868
) -> U;
6969

70+
fnequate_ty_vids_raw(&self,a: ty::TyVid,b: ty::TyVid);
7071
fnequate_int_vids_raw(&self,a: ty::IntVid,b: ty::IntVid);
7172
fnequate_float_vids_raw(&self,a: ty::FloatVid,b: ty::FloatVid);
7273
fnequate_const_vids_raw(&self,a: ty::ConstVid,b: ty::ConstVid);
7374
fnequate_effect_vids_raw(&self,a: ty::EffectVid,b: ty::EffectVid);
7475

76+
fninstantiate_ty_var_raw<R:PredicateEmittingRelation<Self>>(
77+
&self,
78+
relation:&mutR,
79+
target_is_expected:bool,
80+
target_vid: ty::TyVid,
81+
instantiation_variance: ty::Variance,
82+
source_ty: <Self::InternerasInterner>::Ty,
83+
) -> RelateResult<Self::Interner,()>;
7584
fninstantiate_int_var_raw(&self,vid: ty::IntVid,value: ty::IntVarValue);
7685
fninstantiate_float_var_raw(&self,vid: ty::FloatVid,value: ty::FloatVarValue);
7786
fninstantiate_effect_var_raw(
@@ -125,6 +134,12 @@ pub trait InferCtxtLike: Sized {
125134
sup: <Self::InternerasInterner>::Region,
126135
);
127136

137+
fnequate_regions(
138+
&self,
139+
a: <Self::InternerasInterner>::Region,
140+
b: <Self::InternerasInterner>::Region,
141+
);
142+
128143
fnregister_ty_outlives(
129144
&self,
130145
ty: <Self::InternerasInterner>::Ty,

‎compiler/rustc_type_ir/src/inherent.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,10 @@ pub trait BoundExistentialPredicates<I: Interner>:
565565
) -> implIntoIterator<Item = ty::Binder<I, ty::ExistentialProjection<I>>>;
566566
}
567567

568+
pubtraitSpan<I:Interner>:Copy + Debug + Hash + Eq + TypeFoldable<I>{
569+
fndummy() -> Self;
570+
}
571+
568572
pubtraitSliceLike:Sized + Copy{
569573
typeItem:Copy;
570574
typeIntoIter:Iterator<Item = Self::Item>;

‎compiler/rustc_type_ir/src/interner.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub trait Interner:
3636
{
3737
typeDefId:DefId<Self>;
3838
typeLocalDefId:Copy + Debug + Hash + Eq + Into<Self::DefId> + TypeFoldable<Self>;
39-
typeSpan:Copy + Debug + Hash + Eq + TypeFoldable<Self>;
39+
typeSpan:Span<Self>;
4040

4141
typeGenericArgs:GenericArgs<Self>;
4242
typeGenericArgsSlice:Copy + Debug + Hash + Eq + SliceLike<Item = Self::GenericArg>;

‎compiler/rustc_type_ir/src/lib.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ pub fn debug_bound_var<T: std::fmt::Write>(
206206
}
207207
}
208208

209-
#[derive(Copy,Clone,PartialEq,Eq)]
210-
#[cfg_attr(feature = "nightly", derive(Decodable,Encodable,Hash,HashStable_NoContext))]
209+
#[derive(Copy,Clone,PartialEq,Eq,Hash)]
210+
#[cfg_attr(feature = "nightly", derive(Decodable,Encodable,HashStable_NoContext))]
211211
#[cfg_attr(feature = "nightly", rustc_pass_by_value)]
212212
pubenumVariance{
213213
Covariant,// T<A> <: T<B> iff A <: B -- e.g., function return type

‎compiler/rustc_type_ir/src/relate.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use crate::inherent::*;
1010
usecrate::{selfas ty,Interner};
1111

1212
pubmod combine;
13+
pubmod solver_relating;
1314

1415
pubtypeRelateResult<I,T> = Result<T,TypeError<I>>;
1516

0 commit comments

Comments
 (0)