Skip to content

Commit 275d922

Browse files
Rename tcx to cx
1 parent c290e9d commit 275d922

File tree

13 files changed

+333
-347
lines changed

13 files changed

+333
-347
lines changed

compiler/rustc_next_trait_solver/src/solve/alias_relate.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ where
3232
&mut self,
3333
goal: Goal<I, (I::Term, I::Term, ty::AliasRelationDirection)>,
3434
) -> QueryResult<I> {
35-
let tcx = self.cx();
35+
let cx = self.cx();
3636
let Goal { param_env, predicate: (lhs, rhs, direction) } = goal;
3737
debug_assert!(lhs.to_alias_term().is_some() || rhs.to_alias_term().is_some());
3838

3939
// Structurally normalize the lhs.
4040
let lhs = if let Some(alias) = lhs.to_alias_term() {
4141
let term = self.next_term_infer_of_kind(lhs);
42-
self.add_normalizes_to_goal(goal.with(tcx, ty::NormalizesTo { alias, term }));
42+
self.add_normalizes_to_goal(goal.with(cx, ty::NormalizesTo { alias, term }));
4343
term
4444
} else {
4545
lhs
@@ -48,7 +48,7 @@ where
4848
// Structurally normalize the rhs.
4949
let rhs = if let Some(alias) = rhs.to_alias_term() {
5050
let term = self.next_term_infer_of_kind(rhs);
51-
self.add_normalizes_to_goal(goal.with(tcx, ty::NormalizesTo { alias, term }));
51+
self.add_normalizes_to_goal(goal.with(cx, ty::NormalizesTo { alias, term }));
5252
term
5353
} else {
5454
rhs

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

+42-43
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ where
3636
{
3737
fn self_ty(self) -> I::Ty;
3838

39-
fn trait_ref(self, tcx: I) -> ty::TraitRef<I>;
39+
fn trait_ref(self, cx: I) -> ty::TraitRef<I>;
4040

41-
fn with_self_ty(self, tcx: I, self_ty: I::Ty) -> Self;
41+
fn with_self_ty(self, cx: I, self_ty: I::Ty) -> Self;
4242

43-
fn trait_def_id(self, tcx: I) -> I::DefId;
43+
fn trait_def_id(self, cx: I) -> I::DefId;
4444

4545
/// Try equating an assumption predicate against a goal's predicate. If it
4646
/// holds, then execute the `then` callback, which should do any additional
@@ -82,7 +82,7 @@ where
8282
assumption: I::Clause,
8383
) -> Result<Candidate<I>, NoSolution> {
8484
Self::probe_and_match_goal_against_assumption(ecx, source, goal, assumption, |ecx| {
85-
let tcx = ecx.cx();
85+
let cx = ecx.cx();
8686
let ty::Dynamic(bounds, _, _) = goal.predicate.self_ty().kind() else {
8787
panic!("expected object type in `probe_and_consider_object_bound_candidate`");
8888
};
@@ -91,7 +91,7 @@ where
9191
structural_traits::predicates_for_object_candidate(
9292
ecx,
9393
goal.param_env,
94-
goal.predicate.trait_ref(tcx),
94+
goal.predicate.trait_ref(cx),
9595
bounds,
9696
),
9797
);
@@ -340,15 +340,15 @@ where
340340
goal: Goal<I, G>,
341341
candidates: &mut Vec<Candidate<I>>,
342342
) {
343-
let tcx = self.cx();
344-
tcx.for_each_relevant_impl(
345-
goal.predicate.trait_def_id(tcx),
343+
let cx = self.cx();
344+
cx.for_each_relevant_impl(
345+
goal.predicate.trait_def_id(cx),
346346
goal.predicate.self_ty(),
347347
|impl_def_id| {
348348
// For every `default impl`, there's always a non-default `impl`
349349
// that will *also* apply. There's no reason to register a candidate
350350
// for this impl, since it is *not* proof that the trait goal holds.
351-
if tcx.impl_is_default(impl_def_id) {
351+
if cx.impl_is_default(impl_def_id) {
352352
return;
353353
}
354354

@@ -366,8 +366,8 @@ where
366366
goal: Goal<I, G>,
367367
candidates: &mut Vec<Candidate<I>>,
368368
) {
369-
let tcx = self.cx();
370-
let trait_def_id = goal.predicate.trait_def_id(tcx);
369+
let cx = self.cx();
370+
let trait_def_id = goal.predicate.trait_def_id(cx);
371371

372372
// N.B. When assembling built-in candidates for lang items that are also
373373
// `auto` traits, then the auto trait candidate that is assembled in
@@ -378,47 +378,47 @@ where
378378
// `solve::trait_goals` instead.
379379
let result = if let Err(guar) = goal.predicate.error_reported() {
380380
G::consider_error_guaranteed_candidate(self, guar)
381-
} else if tcx.trait_is_auto(trait_def_id) {
381+
} else if cx.trait_is_auto(trait_def_id) {
382382
G::consider_auto_trait_candidate(self, goal)
383-
} else if tcx.trait_is_alias(trait_def_id) {
383+
} else if cx.trait_is_alias(trait_def_id) {
384384
G::consider_trait_alias_candidate(self, goal)
385-
} else if tcx.is_lang_item(trait_def_id, TraitSolverLangItem::Sized) {
385+
} else if cx.is_lang_item(trait_def_id, TraitSolverLangItem::Sized) {
386386
G::consider_builtin_sized_candidate(self, goal)
387-
} else if tcx.is_lang_item(trait_def_id, TraitSolverLangItem::Copy)
388-
|| tcx.is_lang_item(trait_def_id, TraitSolverLangItem::Clone)
387+
} else if cx.is_lang_item(trait_def_id, TraitSolverLangItem::Copy)
388+
|| cx.is_lang_item(trait_def_id, TraitSolverLangItem::Clone)
389389
{
390390
G::consider_builtin_copy_clone_candidate(self, goal)
391-
} else if tcx.is_lang_item(trait_def_id, TraitSolverLangItem::PointerLike) {
391+
} else if cx.is_lang_item(trait_def_id, TraitSolverLangItem::PointerLike) {
392392
G::consider_builtin_pointer_like_candidate(self, goal)
393-
} else if tcx.is_lang_item(trait_def_id, TraitSolverLangItem::FnPtrTrait) {
393+
} else if cx.is_lang_item(trait_def_id, TraitSolverLangItem::FnPtrTrait) {
394394
G::consider_builtin_fn_ptr_trait_candidate(self, goal)
395395
} else if let Some(kind) = self.cx().fn_trait_kind_from_def_id(trait_def_id) {
396396
G::consider_builtin_fn_trait_candidates(self, goal, kind)
397397
} else if let Some(kind) = self.cx().async_fn_trait_kind_from_def_id(trait_def_id) {
398398
G::consider_builtin_async_fn_trait_candidates(self, goal, kind)
399-
} else if tcx.is_lang_item(trait_def_id, TraitSolverLangItem::AsyncFnKindHelper) {
399+
} else if cx.is_lang_item(trait_def_id, TraitSolverLangItem::AsyncFnKindHelper) {
400400
G::consider_builtin_async_fn_kind_helper_candidate(self, goal)
401-
} else if tcx.is_lang_item(trait_def_id, TraitSolverLangItem::Tuple) {
401+
} else if cx.is_lang_item(trait_def_id, TraitSolverLangItem::Tuple) {
402402
G::consider_builtin_tuple_candidate(self, goal)
403-
} else if tcx.is_lang_item(trait_def_id, TraitSolverLangItem::PointeeTrait) {
403+
} else if cx.is_lang_item(trait_def_id, TraitSolverLangItem::PointeeTrait) {
404404
G::consider_builtin_pointee_candidate(self, goal)
405-
} else if tcx.is_lang_item(trait_def_id, TraitSolverLangItem::Future) {
405+
} else if cx.is_lang_item(trait_def_id, TraitSolverLangItem::Future) {
406406
G::consider_builtin_future_candidate(self, goal)
407-
} else if tcx.is_lang_item(trait_def_id, TraitSolverLangItem::Iterator) {
407+
} else if cx.is_lang_item(trait_def_id, TraitSolverLangItem::Iterator) {
408408
G::consider_builtin_iterator_candidate(self, goal)
409-
} else if tcx.is_lang_item(trait_def_id, TraitSolverLangItem::FusedIterator) {
409+
} else if cx.is_lang_item(trait_def_id, TraitSolverLangItem::FusedIterator) {
410410
G::consider_builtin_fused_iterator_candidate(self, goal)
411-
} else if tcx.is_lang_item(trait_def_id, TraitSolverLangItem::AsyncIterator) {
411+
} else if cx.is_lang_item(trait_def_id, TraitSolverLangItem::AsyncIterator) {
412412
G::consider_builtin_async_iterator_candidate(self, goal)
413-
} else if tcx.is_lang_item(trait_def_id, TraitSolverLangItem::Coroutine) {
413+
} else if cx.is_lang_item(trait_def_id, TraitSolverLangItem::Coroutine) {
414414
G::consider_builtin_coroutine_candidate(self, goal)
415-
} else if tcx.is_lang_item(trait_def_id, TraitSolverLangItem::DiscriminantKind) {
415+
} else if cx.is_lang_item(trait_def_id, TraitSolverLangItem::DiscriminantKind) {
416416
G::consider_builtin_discriminant_kind_candidate(self, goal)
417-
} else if tcx.is_lang_item(trait_def_id, TraitSolverLangItem::AsyncDestruct) {
417+
} else if cx.is_lang_item(trait_def_id, TraitSolverLangItem::AsyncDestruct) {
418418
G::consider_builtin_async_destruct_candidate(self, goal)
419-
} else if tcx.is_lang_item(trait_def_id, TraitSolverLangItem::Destruct) {
419+
} else if cx.is_lang_item(trait_def_id, TraitSolverLangItem::Destruct) {
420420
G::consider_builtin_destruct_candidate(self, goal)
421-
} else if tcx.is_lang_item(trait_def_id, TraitSolverLangItem::TransmuteTrait) {
421+
} else if cx.is_lang_item(trait_def_id, TraitSolverLangItem::TransmuteTrait) {
422422
G::consider_builtin_transmute_candidate(self, goal)
423423
} else {
424424
Err(NoSolution)
@@ -428,7 +428,7 @@ where
428428

429429
// There may be multiple unsize candidates for a trait with several supertraits:
430430
// `trait Foo: Bar<A> + Bar<B>` and `dyn Foo: Unsize<dyn Bar<_>>`
431-
if tcx.is_lang_item(trait_def_id, TraitSolverLangItem::Unsize) {
431+
if cx.is_lang_item(trait_def_id, TraitSolverLangItem::Unsize) {
432432
candidates.extend(G::consider_structural_builtin_unsize_candidates(self, goal));
433433
}
434434
}
@@ -557,8 +557,8 @@ where
557557
goal: Goal<I, G>,
558558
candidates: &mut Vec<Candidate<I>>,
559559
) {
560-
let tcx = self.cx();
561-
if !tcx.trait_may_be_implemented_via_object(goal.predicate.trait_def_id(tcx)) {
560+
let cx = self.cx();
561+
if !cx.trait_may_be_implemented_via_object(goal.predicate.trait_def_id(cx)) {
562562
return;
563563
}
564564

@@ -596,7 +596,7 @@ where
596596
};
597597

598598
// Do not consider built-in object impls for non-object-safe types.
599-
if bounds.principal_def_id().is_some_and(|def_id| !tcx.trait_is_object_safe(def_id)) {
599+
if bounds.principal_def_id().is_some_and(|def_id| !cx.trait_is_object_safe(def_id)) {
600600
return;
601601
}
602602

@@ -614,7 +614,7 @@ where
614614
self,
615615
CandidateSource::BuiltinImpl(BuiltinImplSource::Misc),
616616
goal,
617-
bound.with_self_ty(tcx, self_ty),
617+
bound.with_self_ty(cx, self_ty),
618618
));
619619
}
620620
}
@@ -624,14 +624,13 @@ where
624624
// since we don't need to look at any supertrait or anything if we are doing
625625
// a projection goal.
626626
if let Some(principal) = bounds.principal() {
627-
let principal_trait_ref = principal.with_self_ty(tcx, self_ty);
628-
for (idx, assumption) in D::elaborate_supertraits(tcx, principal_trait_ref).enumerate()
629-
{
627+
let principal_trait_ref = principal.with_self_ty(cx, self_ty);
628+
for (idx, assumption) in D::elaborate_supertraits(cx, principal_trait_ref).enumerate() {
630629
candidates.extend(G::probe_and_consider_object_bound_candidate(
631630
self,
632631
CandidateSource::BuiltinImpl(BuiltinImplSource::Object(idx)),
633632
goal,
634-
assumption.upcast(tcx),
633+
assumption.upcast(cx),
635634
));
636635
}
637636
}
@@ -649,11 +648,11 @@ where
649648
goal: Goal<I, G>,
650649
candidates: &mut Vec<Candidate<I>>,
651650
) {
652-
let tcx = self.cx();
651+
let cx = self.cx();
653652

654653
candidates.extend(self.probe_trait_candidate(CandidateSource::CoherenceUnknowable).enter(
655654
|ecx| {
656-
let trait_ref = goal.predicate.trait_ref(tcx);
655+
let trait_ref = goal.predicate.trait_ref(cx);
657656
if ecx.trait_ref_is_knowable(goal.param_env, trait_ref)? {
658657
Err(NoSolution)
659658
} else {
@@ -678,9 +677,9 @@ where
678677
goal: Goal<I, G>,
679678
candidates: &mut Vec<Candidate<I>>,
680679
) {
681-
let tcx = self.cx();
680+
let cx = self.cx();
682681
let trait_goal: Goal<I, ty::TraitPredicate<I>> =
683-
goal.with(tcx, goal.predicate.trait_ref(tcx));
682+
goal.with(cx, goal.predicate.trait_ref(cx));
684683

685684
let mut trait_candidates_from_env = vec![];
686685
self.probe(|_| ProbeKind::ShadowedEnvProbing).enter(|ecx| {

0 commit comments

Comments
 (0)