Skip to content

Commit a80542c

Browse files
Rename some things
1 parent 41a3960 commit a80542c

File tree

10 files changed

+46
-44
lines changed

10 files changed

+46
-44
lines changed

compiler/rustc_borrowck/src/type_check/relate_tys.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use rustc_data_structures::fx::FxHashMap;
22
use rustc_errors::ErrorGuaranteed;
3-
use rustc_infer::infer::relate::{ObligationEmittingRelation, StructurallyRelateAliases};
3+
use rustc_infer::infer::relate::{PredicateEmittingRelation, StructurallyRelateAliases};
44
use rustc_infer::infer::relate::{Relate, RelateResult, TypeRelation};
55
use rustc_infer::infer::NllRegionVariableOrigin;
66
use rustc_infer::traits::solve::Goal;
@@ -155,7 +155,7 @@ impl<'me, 'bccx, 'tcx> NllTypeRelating<'me, 'bccx, 'tcx> {
155155
),
156156
};
157157
let cause = ObligationCause::dummy_with_span(self.span());
158-
self.register_obligations(
158+
self.register_goals(
159159
infcx
160160
.handle_opaque_type(a, b, &cause, self.param_env())?
161161
.obligations
@@ -539,7 +539,7 @@ impl<'bccx, 'tcx> TypeRelation<TyCtxt<'tcx>> for NllTypeRelating<'_, 'bccx, 'tcx
539539
}
540540
}
541541

542-
impl<'bccx, 'tcx> ObligationEmittingRelation<'tcx> for NllTypeRelating<'_, 'bccx, 'tcx> {
542+
impl<'bccx, 'tcx> PredicateEmittingRelation<'tcx> for NllTypeRelating<'_, 'bccx, 'tcx> {
543543
fn span(&self) -> Span {
544544
self.locations.span(self.type_checker.body)
545545
}
@@ -558,12 +558,12 @@ impl<'bccx, 'tcx> ObligationEmittingRelation<'tcx> for NllTypeRelating<'_, 'bccx
558558
) {
559559
let tcx = self.tcx();
560560
let param_env = self.param_env();
561-
self.register_obligations(
561+
self.register_goals(
562562
obligations.into_iter().map(|to_pred| Goal::new(tcx, param_env, to_pred)),
563563
);
564564
}
565565

566-
fn register_obligations(
566+
fn register_goals(
567567
&mut self,
568568
obligations: impl IntoIterator<Item = Goal<'tcx, ty::Predicate<'tcx>>>,
569569
) {
@@ -589,7 +589,7 @@ impl<'bccx, 'tcx> ObligationEmittingRelation<'tcx> for NllTypeRelating<'_, 'bccx
589589
);
590590
}
591591

592-
fn register_type_relate_obligation(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) {
592+
fn register_alias_relate_predicate(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) {
593593
self.register_predicates([ty::Binder::dummy(match self.ambient_variance {
594594
ty::Variance::Covariant => ty::PredicateKind::AliasRelate(
595595
a.into(),

compiler/rustc_infer/src/infer/at.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ impl<'a, 'tcx> At<'a, 'tcx> {
165165
Ok(InferOk {
166166
value: (),
167167
obligations: fields
168-
.obligations
168+
.goals
169169
.into_iter()
170170
.map(|goal| {
171171
Obligation::new(

compiler/rustc_infer/src/infer/mod.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
pub use at::DefineOpaqueTypes;
22
pub use freshen::TypeFreshener;
33
pub use lexical_region_resolve::RegionResolutionError;
4+
pub use relate::combine::CombineFields;
5+
pub use relate::combine::PredicateEmittingRelation;
6+
pub use relate::StructurallyRelateAliases;
47
pub use rustc_macros::{TypeFoldable, TypeVisitable};
58
pub use rustc_middle::ty::IntVarValue;
69
pub use BoundRegionConversionTime::*;
710
pub use RegionVariableOrigin::*;
811
pub use SubregionOrigin::*;
912
pub use ValuePairs::*;
1013

11-
use crate::infer::relate::{CombineFields, RelateResult};
14+
use crate::infer::relate::RelateResult;
1215
use crate::traits::{self, ObligationCause, ObligationInspector, PredicateObligation, TraitEngine};
1316
use error_reporting::TypeErrCtxt;
1417
use free_regions::RegionRelations;

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

+13-14
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub struct CombineFields<'infcx, 'tcx> {
3939
pub infcx: &'infcx InferCtxt<'tcx>,
4040
pub trace: TypeTrace<'tcx>,
4141
pub param_env: ty::ParamEnv<'tcx>,
42-
pub obligations: Vec<Goal<'tcx, ty::Predicate<'tcx>>>,
42+
pub goals: Vec<Goal<'tcx, ty::Predicate<'tcx>>>,
4343
pub define_opaque_types: DefineOpaqueTypes,
4444
}
4545

@@ -50,11 +50,11 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
5050
param_env: ty::ParamEnv<'tcx>,
5151
define_opaque_types: DefineOpaqueTypes,
5252
) -> Self {
53-
Self { infcx, trace, param_env, define_opaque_types, obligations: vec![] }
53+
Self { infcx, trace, param_env, define_opaque_types, goals: vec![] }
5454
}
5555

5656
pub(crate) fn into_obligations(self) -> Vec<PredicateObligation<'tcx>> {
57-
self.obligations
57+
self.goals
5858
.into_iter()
5959
.map(|goal| {
6060
Obligation::new(
@@ -76,7 +76,7 @@ impl<'tcx> InferCtxt<'tcx> {
7676
b: Ty<'tcx>,
7777
) -> RelateResult<'tcx, Ty<'tcx>>
7878
where
79-
R: ObligationEmittingRelation<'tcx>,
79+
R: PredicateEmittingRelation<'tcx>,
8080
{
8181
debug_assert!(!a.has_escaping_bound_vars());
8282
debug_assert!(!b.has_escaping_bound_vars());
@@ -140,7 +140,7 @@ impl<'tcx> InferCtxt<'tcx> {
140140
relate::structurally_relate_tys(relation, a, b)
141141
}
142142
StructurallyRelateAliases::No => {
143-
relation.register_type_relate_obligation(a, b);
143+
relation.register_alias_relate_predicate(a, b);
144144
Ok(a)
145145
}
146146
}
@@ -171,7 +171,7 @@ impl<'tcx> InferCtxt<'tcx> {
171171
b: ty::Const<'tcx>,
172172
) -> RelateResult<'tcx, ty::Const<'tcx>>
173173
where
174-
R: ObligationEmittingRelation<'tcx>,
174+
R: PredicateEmittingRelation<'tcx>,
175175
{
176176
debug!("{}.consts({:?}, {:?})", relation.tag(), a, b);
177177
debug_assert!(!a.has_escaping_bound_vars());
@@ -309,22 +309,22 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
309309
&mut self,
310310
obligations: impl IntoIterator<Item = Goal<'tcx, ty::Predicate<'tcx>>>,
311311
) {
312-
self.obligations.extend(obligations);
312+
self.goals.extend(obligations);
313313
}
314314

315315
pub fn register_predicates(
316316
&mut self,
317317
obligations: impl IntoIterator<Item: Upcast<TyCtxt<'tcx>, ty::Predicate<'tcx>>>,
318318
) {
319-
self.obligations.extend(
319+
self.goals.extend(
320320
obligations
321321
.into_iter()
322322
.map(|to_pred| Goal::new(self.infcx.tcx, self.param_env, to_pred)),
323323
)
324324
}
325325
}
326326

327-
pub trait ObligationEmittingRelation<'tcx>: TypeRelation<TyCtxt<'tcx>> {
327+
pub trait PredicateEmittingRelation<'tcx>: TypeRelation<TyCtxt<'tcx>> {
328328
fn span(&self) -> Span;
329329

330330
fn param_env(&self) -> ty::ParamEnv<'tcx>;
@@ -335,19 +335,18 @@ pub trait ObligationEmittingRelation<'tcx>: TypeRelation<TyCtxt<'tcx>> {
335335
fn structurally_relate_aliases(&self) -> StructurallyRelateAliases;
336336

337337
/// Register obligations that must hold in order for this relation to hold
338-
fn register_obligations(
338+
fn register_goals(
339339
&mut self,
340340
obligations: impl IntoIterator<Item = Goal<'tcx, ty::Predicate<'tcx>>>,
341341
);
342342

343-
/// Register predicates that must hold in order for this relation to hold. Uses
344-
/// a default obligation cause, [`ObligationEmittingRelation::register_obligations`] should
345-
/// be used if control over the obligation causes is required.
343+
/// Register predicates that must hold in order for this relation to hold.
344+
/// This uses the default `param_env` of the obligation.
346345
fn register_predicates(
347346
&mut self,
348347
obligations: impl IntoIterator<Item: Upcast<TyCtxt<'tcx>, ty::Predicate<'tcx>>>,
349348
);
350349

351350
/// Register `AliasRelate` obligation(s) that both types must be related to each other.
352-
fn register_type_relate_obligation(&mut self, a: Ty<'tcx>, b: Ty<'tcx>);
351+
fn register_alias_relate_predicate(&mut self, a: Ty<'tcx>, b: Ty<'tcx>);
353352
}

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::mem;
22

33
use super::StructurallyRelateAliases;
4-
use super::{ObligationEmittingRelation, Relate, RelateResult, TypeRelation};
4+
use super::{PredicateEmittingRelation, Relate, RelateResult, TypeRelation};
55
use crate::infer::relate;
66
use crate::infer::type_variable::TypeVariableValue;
77
use crate::infer::{InferCtxt, RegionVariableOrigin};
@@ -30,7 +30,7 @@ impl<'tcx> InferCtxt<'tcx> {
3030
/// `TypeRelation`. Do not use this, and instead please use `At::eq`, for all
3131
/// other usecases (i.e. setting the value of a type var).
3232
#[instrument(level = "debug", skip(self, relation))]
33-
pub fn instantiate_ty_var<R: ObligationEmittingRelation<'tcx>>(
33+
pub fn instantiate_ty_var<R: PredicateEmittingRelation<'tcx>>(
3434
&self,
3535
relation: &mut R,
3636
target_is_expected: bool,
@@ -178,7 +178,7 @@ impl<'tcx> InferCtxt<'tcx> {
178178
///
179179
/// See `tests/ui/const-generics/occurs-check/` for more examples where this is relevant.
180180
#[instrument(level = "debug", skip(self, relation))]
181-
pub(super) fn instantiate_const_var<R: ObligationEmittingRelation<'tcx>>(
181+
pub(super) fn instantiate_const_var<R: PredicateEmittingRelation<'tcx>>(
182182
&self,
183183
relation: &mut R,
184184
target_is_expected: bool,

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_middle::ty::relate::{Relate, RelateResult, TypeRelation};
55
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt};
66
use rustc_span::Span;
77

8-
use super::combine::{CombineFields, ObligationEmittingRelation};
8+
use super::combine::{CombineFields, PredicateEmittingRelation};
99
use super::lattice::{self, LatticeDir};
1010
use super::StructurallyRelateAliases;
1111
use crate::infer::{DefineOpaqueTypes, InferCtxt, SubregionOrigin};
@@ -128,7 +128,7 @@ impl<'combine, 'infcx, 'tcx> LatticeDir<'infcx, 'tcx> for Glb<'combine, 'infcx,
128128
}
129129
}
130130

131-
impl<'tcx> ObligationEmittingRelation<'tcx> for Glb<'_, '_, 'tcx> {
131+
impl<'tcx> PredicateEmittingRelation<'tcx> for Glb<'_, '_, 'tcx> {
132132
fn span(&self) -> Span {
133133
self.fields.trace.span()
134134
}
@@ -148,14 +148,14 @@ impl<'tcx> ObligationEmittingRelation<'tcx> for Glb<'_, '_, 'tcx> {
148148
self.fields.register_predicates(obligations);
149149
}
150150

151-
fn register_obligations(
151+
fn register_goals(
152152
&mut self,
153153
obligations: impl IntoIterator<Item = Goal<'tcx, ty::Predicate<'tcx>>>,
154154
) {
155155
self.fields.register_obligations(obligations);
156156
}
157157

158-
fn register_type_relate_obligation(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) {
158+
fn register_alias_relate_predicate(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) {
159159
self.register_predicates([ty::Binder::dummy(ty::PredicateKind::AliasRelate(
160160
a.into(),
161161
b.into(),

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
//!
1818
//! [lattices]: https://en.wikipedia.org/wiki/Lattice_(order)
1919
20-
use super::combine::ObligationEmittingRelation;
20+
use super::combine::PredicateEmittingRelation;
2121
use crate::infer::{DefineOpaqueTypes, InferCtxt};
2222
use crate::traits::ObligationCause;
2323

@@ -31,7 +31,7 @@ use rustc_middle::ty::{self, Ty};
3131
///
3232
/// GLB moves "down" the lattice (to smaller values); LUB moves
3333
/// "up" the lattice (to bigger values).
34-
pub trait LatticeDir<'f, 'tcx>: ObligationEmittingRelation<'tcx> {
34+
pub trait LatticeDir<'f, 'tcx>: PredicateEmittingRelation<'tcx> {
3535
fn infcx(&self) -> &'f InferCtxt<'tcx>;
3636

3737
fn cause(&self) -> &ObligationCause<'tcx>;
@@ -109,7 +109,7 @@ where
109109
&& def_id.is_local()
110110
&& !this.infcx().next_trait_solver() =>
111111
{
112-
this.register_obligations(
112+
this.register_goals(
113113
infcx
114114
.handle_opaque_type(a, b, this.cause(), this.param_env())?
115115
.obligations

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Least upper bound. See [`lattice`].
22
3-
use super::combine::{CombineFields, ObligationEmittingRelation};
3+
use super::combine::{CombineFields, PredicateEmittingRelation};
44
use super::lattice::{self, LatticeDir};
55
use super::StructurallyRelateAliases;
66
use crate::infer::{DefineOpaqueTypes, InferCtxt, SubregionOrigin};
@@ -128,7 +128,7 @@ impl<'combine, 'infcx, 'tcx> LatticeDir<'infcx, 'tcx> for Lub<'combine, 'infcx,
128128
}
129129
}
130130

131-
impl<'tcx> ObligationEmittingRelation<'tcx> for Lub<'_, '_, 'tcx> {
131+
impl<'tcx> PredicateEmittingRelation<'tcx> for Lub<'_, '_, 'tcx> {
132132
fn span(&self) -> Span {
133133
self.fields.trace.span()
134134
}
@@ -148,14 +148,14 @@ impl<'tcx> ObligationEmittingRelation<'tcx> for Lub<'_, '_, 'tcx> {
148148
self.fields.register_predicates(obligations);
149149
}
150150

151-
fn register_obligations(
151+
fn register_goals(
152152
&mut self,
153153
obligations: impl IntoIterator<Item = Goal<'tcx, ty::Predicate<'tcx>>>,
154154
) {
155155
self.fields.register_obligations(obligations)
156156
}
157157

158-
fn register_type_relate_obligation(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) {
158+
fn register_alias_relate_predicate(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) {
159159
self.register_predicates([ty::Binder::dummy(ty::PredicateKind::AliasRelate(
160160
a.into(),
161161
b.into(),

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub use rustc_middle::ty::relate::*;
66

77
pub use self::_match::MatchAgainstFreshVars;
88
pub use self::combine::CombineFields;
9-
pub use self::combine::ObligationEmittingRelation;
9+
pub use self::combine::PredicateEmittingRelation;
1010

1111
pub mod _match;
1212
pub(super) mod combine;

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

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use super::combine::CombineFields;
2-
use crate::infer::relate::{ObligationEmittingRelation, StructurallyRelateAliases};
2+
use crate::infer::relate::{PredicateEmittingRelation, StructurallyRelateAliases};
33
use crate::infer::BoundRegionConversionTime::HigherRankedType;
44
use crate::infer::{DefineOpaqueTypes, SubregionOrigin};
55
use rustc_middle::traits::solve::Goal;
@@ -87,7 +87,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for TypeRelating<'_, '_, 'tcx> {
8787
ty::Covariant => {
8888
// can't make progress on `A <: B` if both A and B are
8989
// type variables, so record an obligation.
90-
self.fields.obligations.push(Goal::new(
90+
self.fields.goals.push(Goal::new(
9191
self.tcx(),
9292
self.fields.param_env,
9393
ty::Binder::dummy(ty::PredicateKind::Subtype(ty::SubtypePredicate {
@@ -100,7 +100,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for TypeRelating<'_, '_, 'tcx> {
100100
ty::Contravariant => {
101101
// can't make progress on `B <: A` if both A and B are
102102
// type variables, so record an obligation.
103-
self.fields.obligations.push(Goal::new(
103+
self.fields.goals.push(Goal::new(
104104
self.tcx(),
105105
self.fields.param_env,
106106
ty::Binder::dummy(ty::PredicateKind::Subtype(ty::SubtypePredicate {
@@ -151,7 +151,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for TypeRelating<'_, '_, 'tcx> {
151151
&& !infcx.next_trait_solver() =>
152152
{
153153
// FIXME: Don't shuttle between Goal and Obligation
154-
self.fields.obligations.extend(
154+
self.fields.goals.extend(
155155
infcx
156156
.handle_opaque_type(a, b, &self.fields.trace.cause, self.param_env())?
157157
.obligations
@@ -298,7 +298,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for TypeRelating<'_, '_, 'tcx> {
298298
}
299299
}
300300

301-
impl<'tcx> ObligationEmittingRelation<'tcx> for TypeRelating<'_, '_, 'tcx> {
301+
impl<'tcx> PredicateEmittingRelation<'tcx> for TypeRelating<'_, '_, 'tcx> {
302302
fn span(&self) -> Span {
303303
self.fields.trace.span()
304304
}
@@ -318,14 +318,14 @@ impl<'tcx> ObligationEmittingRelation<'tcx> for TypeRelating<'_, '_, 'tcx> {
318318
self.fields.register_predicates(obligations);
319319
}
320320

321-
fn register_obligations(
321+
fn register_goals(
322322
&mut self,
323323
obligations: impl IntoIterator<Item = Goal<'tcx, ty::Predicate<'tcx>>>,
324324
) {
325325
self.fields.register_obligations(obligations);
326326
}
327327

328-
fn register_type_relate_obligation(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) {
328+
fn register_alias_relate_predicate(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) {
329329
self.register_predicates([ty::Binder::dummy(match self.ambient_variance {
330330
ty::Variance::Covariant => ty::PredicateKind::AliasRelate(
331331
a.into(),

0 commit comments

Comments
 (0)