Skip to content

Commit 0b5ce54

Browse files
Fix relations
1 parent 8d90f44 commit 0b5ce54

File tree

9 files changed

+25
-25
lines changed

9 files changed

+25
-25
lines changed

compiler/rustc_borrowck/src/type_check/relate_tys.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ impl<'me, 'bccx, 'tcx> NllTypeRelating<'me, 'bccx, 'tcx> {
309309
}
310310

311311
impl<'bccx, 'tcx> TypeRelation<TyCtxt<'tcx>> for NllTypeRelating<'_, 'bccx, 'tcx> {
312-
fn tcx(&self) -> TyCtxt<'tcx> {
312+
fn cx(&self) -> TyCtxt<'tcx> {
313313
self.type_checker.infcx.tcx
314314
}
315315

@@ -370,7 +370,7 @@ impl<'bccx, 'tcx> TypeRelation<TyCtxt<'tcx>> for NllTypeRelating<'_, 'bccx, 'tcx
370370
// shouldn't ever fail. Instead, it unconditionally emits an
371371
// alias-relate goal.
372372
assert!(!self.type_checker.infcx.next_trait_solver());
373-
self.tcx().dcx().span_delayed_bug(
373+
self.cx().dcx().span_delayed_bug(
374374
self.span(),
375375
"failure to relate an opaque to itself should result in an error later on",
376376
);
@@ -540,7 +540,7 @@ impl<'bccx, 'tcx> PredicateEmittingRelation<InferCtxt<'tcx>> for NllTypeRelating
540540
&mut self,
541541
obligations: impl IntoIterator<Item: ty::Upcast<TyCtxt<'tcx>, ty::Predicate<'tcx>>>,
542542
) {
543-
let tcx = self.tcx();
543+
let tcx = self.cx();
544544
let param_env = self.param_env();
545545
self.register_goals(
546546
obligations.into_iter().map(|to_pred| Goal::new(tcx, param_env, to_pred)),
@@ -559,7 +559,7 @@ impl<'bccx, 'tcx> PredicateEmittingRelation<InferCtxt<'tcx>> for NllTypeRelating
559559
.into_iter()
560560
.map(|goal| {
561561
Obligation::new(
562-
self.tcx(),
562+
self.cx(),
563563
ObligationCause::dummy_with_span(self.span()),
564564
goal.param_env,
565565
goal.predicate,

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1930,7 +1930,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
19301930
struct SameTypeModuloInfer<'a, 'tcx>(&'a InferCtxt<'tcx>);
19311931

19321932
impl<'tcx> TypeRelation<TyCtxt<'tcx>> for SameTypeModuloInfer<'_, 'tcx> {
1933-
fn tcx(&self) -> TyCtxt<'tcx> {
1933+
fn cx(&self) -> TyCtxt<'tcx> {
19341934
self.0.tcx
19351935
}
19361936

compiler/rustc_infer/src/infer/outlives/test_type_match.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for MatchAgainstHigherRankedOutlives<'tcx>
137137
"MatchAgainstHigherRankedOutlives"
138138
}
139139

140-
fn tcx(&self) -> TyCtxt<'tcx> {
140+
fn cx(&self) -> TyCtxt<'tcx> {
141141
self.tcx
142142
}
143143

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ impl<'tcx> Generalizer<'_, 'tcx> {
372372

373373
let is_nested_alias = mem::replace(&mut self.in_alias, true);
374374
let result = match self.relate(alias, alias) {
375-
Ok(alias) => Ok(alias.to_ty(self.tcx())),
375+
Ok(alias) => Ok(alias.to_ty(self.cx())),
376376
Err(e) => {
377377
if is_nested_alias {
378378
return Err(e);
@@ -397,7 +397,7 @@ impl<'tcx> Generalizer<'_, 'tcx> {
397397
}
398398

399399
impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Generalizer<'_, 'tcx> {
400-
fn tcx(&self) -> TyCtxt<'tcx> {
400+
fn cx(&self) -> TyCtxt<'tcx> {
401401
self.infcx.tcx
402402
}
403403

@@ -417,7 +417,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Generalizer<'_, 'tcx> {
417417
// (e.g., #41849).
418418
relate::relate_args_invariantly(self, a_arg, b_arg)
419419
} else {
420-
let tcx = self.tcx();
420+
let tcx = self.cx();
421421
let opt_variances = tcx.variances_of(item_def_id);
422422
relate::relate_args_with_variances(
423423
self,
@@ -525,7 +525,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Generalizer<'_, 'tcx> {
525525
}
526526

527527
debug!("replacing original vid={:?} with new={:?}", vid, new_var_id);
528-
Ok(Ty::new_var(self.tcx(), new_var_id))
528+
Ok(Ty::new_var(self.cx(), new_var_id))
529529
}
530530
}
531531
}
@@ -654,7 +654,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Generalizer<'_, 'tcx> {
654654
{
655655
variable_table.union(vid, new_var_id);
656656
}
657-
Ok(ty::Const::new_var(self.tcx(), new_var_id))
657+
Ok(ty::Const::new_var(self.cx(), new_var_id))
658658
}
659659
}
660660
}
@@ -672,7 +672,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Generalizer<'_, 'tcx> {
672672
args,
673673
args,
674674
)?;
675-
Ok(ty::Const::new_unevaluated(self.tcx(), ty::UnevaluatedConst { def, args }))
675+
Ok(ty::Const::new_unevaluated(self.cx(), ty::UnevaluatedConst { def, args }))
676676
}
677677
ty::ConstKind::Placeholder(placeholder) => {
678678
if self.for_universe.can_name(placeholder.universe) {

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Glb<'_, '_, 'tcx> {
2727
"Glb"
2828
}
2929

30-
fn tcx(&self) -> TyCtxt<'tcx> {
30+
fn cx(&self) -> TyCtxt<'tcx> {
3131
self.fields.tcx()
3232
}
3333

@@ -61,7 +61,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Glb<'_, '_, 'tcx> {
6161
let origin = SubregionOrigin::Subtype(Box::new(self.fields.trace.clone()));
6262
// GLB(&'static u8, &'a u8) == &RegionLUB('static, 'a) u8 == &'static u8
6363
Ok(self.fields.infcx.inner.borrow_mut().unwrap_region_constraints().lub_regions(
64-
self.tcx(),
64+
self.cx(),
6565
origin,
6666
a,
6767
b,

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Lub<'_, '_, 'tcx> {
2727
"Lub"
2828
}
2929

30-
fn tcx(&self) -> TyCtxt<'tcx> {
30+
fn cx(&self) -> TyCtxt<'tcx> {
3131
self.fields.tcx()
3232
}
3333

@@ -61,7 +61,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Lub<'_, '_, 'tcx> {
6161
let origin = SubregionOrigin::Subtype(Box::new(self.fields.trace.clone()));
6262
// LUB(&'static u8, &'a u8) == &RegionGLB('static, 'a) u8 == &'a u8
6363
Ok(self.fields.infcx.inner.borrow_mut().unwrap_region_constraints().glb_regions(
64-
self.tcx(),
64+
self.cx(),
6565
origin,
6666
a,
6767
b,

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for TypeRelating<'_, '_, 'tcx> {
3232
"TypeRelating"
3333
}
3434

35-
fn tcx(&self) -> TyCtxt<'tcx> {
35+
fn cx(&self) -> TyCtxt<'tcx> {
3636
self.fields.infcx.tcx
3737
}
3838

@@ -48,7 +48,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for TypeRelating<'_, '_, 'tcx> {
4848
// (e.g., #41849).
4949
relate_args_invariantly(self, a_arg, b_arg)
5050
} else {
51-
let tcx = self.tcx();
51+
let tcx = self.cx();
5252
let opt_variances = tcx.variances_of(item_def_id);
5353
relate_args_with_variances(self, item_def_id, opt_variances, a_arg, b_arg, false)
5454
}
@@ -88,7 +88,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for TypeRelating<'_, '_, 'tcx> {
8888
// can't make progress on `A <: B` if both A and B are
8989
// type variables, so record an obligation.
9090
self.fields.goals.push(Goal::new(
91-
self.tcx(),
91+
self.cx(),
9292
self.fields.param_env,
9393
ty::Binder::dummy(ty::PredicateKind::Subtype(ty::SubtypePredicate {
9494
a_is_expected: true,
@@ -101,7 +101,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for TypeRelating<'_, '_, 'tcx> {
101101
// can't make progress on `B <: A` if both A and B are
102102
// type variables, so record an obligation.
103103
self.fields.goals.push(Goal::new(
104-
self.tcx(),
104+
self.cx(),
105105
self.fields.param_env,
106106
ty::Binder::dummy(ty::PredicateKind::Subtype(ty::SubtypePredicate {
107107
a_is_expected: false,
@@ -134,7 +134,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for TypeRelating<'_, '_, 'tcx> {
134134

135135
(&ty::Error(e), _) | (_, &ty::Error(e)) => {
136136
infcx.set_tainted_by_errors(e);
137-
return Ok(Ty::new_error(self.tcx(), e));
137+
return Ok(Ty::new_error(self.cx(), e));
138138
}
139139

140140
(

compiler/rustc_middle/src/ty/relate.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl<'tcx> Relate<TyCtxt<'tcx>> for ty::Pattern<'tcx> {
6969
if inc_a != inc_b {
7070
todo!()
7171
}
72-
Ok(relation.tcx().mk_pat(ty::PatternKind::Range { start, end, include_end: inc_a }))
72+
Ok(relation.cx().mk_pat(ty::PatternKind::Range { start, end, include_end: inc_a }))
7373
}
7474
}
7575
}
@@ -81,7 +81,7 @@ impl<'tcx> Relate<TyCtxt<'tcx>> for &'tcx ty::List<ty::PolyExistentialPredicate<
8181
a: Self,
8282
b: Self,
8383
) -> RelateResult<'tcx, Self> {
84-
let tcx = relation.tcx();
84+
let tcx = relation.cx();
8585

8686
// FIXME: this is wasteful, but want to do a perf run to see how slow it is.
8787
// We need to perform this deduplication as we sometimes generate duplicate projections

compiler/rustc_trait_selection/src/traits/select/_match.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for MatchAgainstFreshVars<'tcx> {
3636
"MatchAgainstFreshVars"
3737
}
3838

39-
fn tcx(&self) -> TyCtxt<'tcx> {
39+
fn cx(&self) -> TyCtxt<'tcx> {
4040
self.tcx
4141
}
4242

@@ -77,7 +77,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for MatchAgainstFreshVars<'tcx> {
7777
Err(TypeError::Sorts(ExpectedFound::new(true, a, b)))
7878
}
7979

80-
(&ty::Error(guar), _) | (_, &ty::Error(guar)) => Ok(Ty::new_error(self.tcx(), guar)),
80+
(&ty::Error(guar), _) | (_, &ty::Error(guar)) => Ok(Ty::new_error(self.cx(), guar)),
8181

8282
_ => structurally_relate_tys(self, a, b),
8383
}

0 commit comments

Comments
 (0)