Skip to content

Commit a9e453e

Browse files
committed
Initial changes to rename proj type to term
This just changes the name of projection type to term, which highlights where other changes to using a term should go.
1 parent e0ade19 commit a9e453e

36 files changed

+152
-147
lines changed

chalk-engine/src/slg.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -306,15 +306,15 @@ impl<I: Interner> MayInvalidate<I> {
306306

307307
fn aggregate_projection_tys(
308308
&mut self,
309-
new: &ProjectionTy<I>,
310-
current: &ProjectionTy<I>,
309+
new: &ProjectionTerm<I>,
310+
current: &ProjectionTerm<I>,
311311
) -> bool {
312-
let ProjectionTy {
313-
associated_ty_id: new_name,
312+
let ProjectionTerm {
313+
associated_term_id: new_name,
314314
substitution: new_substitution,
315315
} = new;
316-
let ProjectionTy {
317-
associated_ty_id: current_name,
316+
let ProjectionTerm {
317+
associated_term_id: current_name,
318318
substitution: current_substitution,
319319
} = current;
320320

chalk-engine/src/slg/aggregate.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -382,23 +382,23 @@ impl<I: Interner> AntiUnifier<'_, I> {
382382

383383
fn aggregate_projection_tys(
384384
&mut self,
385-
proj1: &ProjectionTy<I>,
386-
proj2: &ProjectionTy<I>,
385+
proj1: &ProjectionTerm<I>,
386+
proj2: &ProjectionTerm<I>,
387387
) -> Ty<I> {
388388
let interner = self.interner;
389-
let ProjectionTy {
390-
associated_ty_id: name1,
389+
let ProjectionTerm {
390+
associated_term_id: name1,
391391
substitution: substitution1,
392392
} = proj1;
393-
let ProjectionTy {
394-
associated_ty_id: name2,
393+
let ProjectionTerm {
394+
associated_term_id: name2,
395395
substitution: substitution2,
396396
} = proj2;
397397

398398
self.aggregate_name_and_substs(name1, substitution1, name2, substitution2)
399-
.map(|(&associated_ty_id, substitution)| {
400-
TyKind::Alias(AliasTy::Projection(ProjectionTy {
401-
associated_ty_id,
399+
.map(|(&associated_term_id, substitution)| {
400+
TyKind::Alias(AliasTy::Projection(ProjectionTerm {
401+
associated_term_id,
402402
substitution,
403403
}))
404404
.intern(interner)

chalk-integration/src/db.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::{
77
tls, SolverChoice,
88
};
99
use chalk_ir::{
10-
AdtId, AssocTypeId, Binders, Canonical, CanonicalVarKinds, ClosureId, ConstrainedSubst,
10+
AdtId, AssocItemId, Binders, Canonical, CanonicalVarKinds, ClosureId, ConstrainedSubst,
1111
Environment, FnDefId, GeneratorId, GenericArg, Goal, ImplId, InEnvironment, OpaqueTyId,
1212
ProgramClause, ProgramClauses, Substitution, TraitId, Ty, TyKind, UCanonical,
1313
UnificationDatabase, Variances,
@@ -87,7 +87,7 @@ impl RustIrDatabase<ChalkIr> for ChalkDatabase {
8787
self.program_ir().unwrap().custom_clauses()
8888
}
8989

90-
fn associated_ty_data(&self, ty: AssocTypeId<ChalkIr>) -> Arc<AssociatedTyDatum<ChalkIr>> {
90+
fn associated_ty_data(&self, ty: AssocItemId<ChalkIr>) -> Arc<AssociatedTyDatum<ChalkIr>> {
9191
self.program_ir().unwrap().associated_ty_data(ty)
9292
}
9393

@@ -235,7 +235,7 @@ impl RustIrDatabase<ChalkIr> for ChalkDatabase {
235235
self.program_ir().unwrap().adt_name(struct_id)
236236
}
237237

238-
fn assoc_type_name(&self, assoc_ty_id: AssocTypeId<ChalkIr>) -> String {
238+
fn assoc_type_name(&self, assoc_ty_id: AssocItemId<ChalkIr>) -> String {
239239
self.program_ir().unwrap().assoc_type_name(assoc_ty_id)
240240
}
241241

chalk-integration/src/interner.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ use chalk_ir::{
44
TyKind,
55
};
66
use chalk_ir::{
7-
AdtId, AliasTy, AssocTypeId, CanonicalVarKind, CanonicalVarKinds, ConstData, Constraint,
7+
AdtId, AliasTy, AssocItemId, CanonicalVarKind, CanonicalVarKinds, ConstData, Constraint,
88
Constraints, FnDefId, Goals, InEnvironment, Lifetime, OpaqueTy, OpaqueTyId,
9-
ProgramClauseImplication, ProgramClauses, ProjectionTy, QuantifiedWhereClauses,
9+
ProgramClauseImplication, ProgramClauses, ProjectionTerm, QuantifiedWhereClauses,
1010
SeparatorTraitRef, Substitution, TraitId, Ty, TyData, VariableKind, VariableKinds, Variances,
1111
};
1212
use chalk_ir::{
@@ -91,7 +91,7 @@ impl Interner for ChalkIr {
9191
}
9292

9393
fn debug_assoc_type_id(
94-
id: AssocTypeId<ChalkIr>,
94+
id: AssocItemId<ChalkIr>,
9595
fmt: &mut fmt::Formatter<'_>,
9696
) -> Option<fmt::Result> {
9797
tls::with_current_program(|prog| Some(prog?.debug_assoc_type_id(id, fmt)))
@@ -113,7 +113,7 @@ impl Interner for ChalkIr {
113113
}
114114

115115
fn debug_projection_ty(
116-
proj: &ProjectionTy<ChalkIr>,
116+
proj: &ProjectionTerm<ChalkIr>,
117117
fmt: &mut fmt::Formatter<'_>,
118118
) -> Option<fmt::Result> {
119119
tls::with_current_program(|prog| Some(prog?.debug_projection_ty(proj, fmt)))

chalk-integration/src/lowering.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -618,11 +618,11 @@ impl Lower for TraitFlags {
618618
}
619619
}
620620

621-
impl LowerWithEnv for ProjectionTy {
622-
type Lowered = chalk_ir::ProjectionTy<ChalkIr>;
621+
impl LowerWithEnv for ProjectionTerm {
622+
type Lowered = chalk_ir::ProjectionTerm<ChalkIr>;
623623

624624
fn lower(&self, env: &Env) -> LowerResult<Self::Lowered> {
625-
let ProjectionTy {
625+
let ProjectionTerm {
626626
ref trait_ref,
627627
ref name,
628628
ref args,
@@ -658,8 +658,8 @@ impl LowerWithEnv for ProjectionTy {
658658

659659
args.extend(trait_substitution.iter(interner).cloned());
660660

661-
Ok(chalk_ir::ProjectionTy {
662-
associated_ty_id: lookup.id,
661+
Ok(chalk_ir::ProjectionTerm {
662+
associated_term_id: lookup.id,
663663
substitution: chalk_ir::Substitution::from_iter(interner, args),
664664
})
665665
}

chalk-integration/src/lowering/env.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ pub struct Env<'k> {
7171
/// ```
7272
#[derive(Debug, PartialEq, Eq)]
7373
pub struct AssociatedTyLookup {
74-
pub id: chalk_ir::AssocTypeId<ChalkIr>,
74+
pub id: chalk_ir::AssocItemId<ChalkIr>,
7575
pub addl_variable_kinds: Vec<chalk_ir::VariableKind<ChalkIr>>,
7676
}
7777

chalk-integration/src/lowering/program_lowerer.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use chalk_ir::cast::Cast;
22
use chalk_ir::{
3-
self, AdtId, AssocTypeId, BoundVar, ClosureId, DebruijnIndex, FnDefId, ForeignDefId,
3+
self, AdtId, AssocItemId, BoundVar, ClosureId, DebruijnIndex, FnDefId, ForeignDefId,
44
GeneratorId, ImplId, OpaqueTyId, TraitId, TyVariableKind, VariableKinds,
55
};
66
use chalk_parse::ast::*;
@@ -64,7 +64,7 @@ impl ProgramLowerer {
6464
for defn in &d.assoc_ty_defns {
6565
let addl_variable_kinds = defn.all_parameters();
6666
let lookup = AssociatedTyLookup {
67-
id: AssocTypeId(self.next_item_id()),
67+
id: AssocItemId(self.next_item_id()),
6868
addl_variable_kinds: addl_variable_kinds.anonymize(),
6969
};
7070
self.associated_ty_lookups

chalk-integration/src/program.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ use crate::{tls, Identifier, TypeKind};
33
use chalk_ir::{could_match::CouldMatch, UnificationDatabase};
44
use chalk_ir::{debug::Angle, Variance};
55
use chalk_ir::{
6-
debug::SeparatorTraitRef, AdtId, AliasTy, AssocTypeId, Binders, CanonicalVarKinds, ClosureId,
6+
debug::SeparatorTraitRef, AdtId, AliasTy, AssocItemId, Binders, CanonicalVarKinds, ClosureId,
77
FnDefId, ForeignDefId, GeneratorId, GenericArg, Goal, Goals, ImplId, IntTy, Lifetime, OpaqueTy,
8-
OpaqueTyId, ProgramClause, ProgramClauseImplication, ProgramClauses, ProjectionTy, Scalar,
8+
OpaqueTyId, ProgramClause, ProgramClauseImplication, ProgramClauses, ProjectionTerm, Scalar,
99
Substitution, TraitId, Ty, TyKind, UintTy, Variances,
1010
};
1111
use chalk_solve::rust_ir::{
@@ -97,7 +97,7 @@ pub struct Program {
9797
pub well_known_traits: BTreeMap<WellKnownTrait, TraitId<ChalkIr>>,
9898

9999
/// For each associated ty declaration `type Foo` found in a trait:
100-
pub associated_ty_data: BTreeMap<AssocTypeId<ChalkIr>, Arc<AssociatedTyDatum<ChalkIr>>>,
100+
pub associated_ty_data: BTreeMap<AssocItemId<ChalkIr>, Arc<AssociatedTyDatum<ChalkIr>>>,
101101

102102
/// For each user-specified clause
103103
pub custom_clauses: Vec<ProgramClause<ChalkIr>>,
@@ -151,13 +151,13 @@ impl tls::DebugContext for Program {
151151

152152
fn debug_assoc_type_id(
153153
&self,
154-
assoc_type_id: AssocTypeId<ChalkIr>,
154+
assoc_type_id: AssocItemId<ChalkIr>,
155155
fmt: &mut fmt::Formatter<'_>,
156156
) -> Result<(), fmt::Error> {
157157
if let Some(d) = self.associated_ty_data.get(&assoc_type_id) {
158158
write!(fmt, "({:?}::{})", d.trait_id, d.name)
159159
} else {
160-
fmt.debug_struct("InvalidAssocTypeId")
160+
fmt.debug_struct("InvalidAssocItemId")
161161
.field("index", &assoc_type_id.0)
162162
.finish()
163163
}
@@ -204,7 +204,7 @@ impl tls::DebugContext for Program {
204204

205205
fn debug_projection_ty(
206206
&self,
207-
projection_ty: &ProjectionTy<ChalkIr>,
207+
projection_ty: &ProjectionTerm<ChalkIr>,
208208
fmt: &mut fmt::Formatter<'_>,
209209
) -> Result<(), fmt::Error> {
210210
let (associated_ty_data, trait_params, other_params) = self.split_projection(projection_ty);
@@ -386,7 +386,7 @@ impl RustIrDatabase<ChalkIr> for Program {
386386
self.custom_clauses.clone()
387387
}
388388

389-
fn associated_ty_data(&self, ty: AssocTypeId<ChalkIr>) -> Arc<AssociatedTyDatum<ChalkIr>> {
389+
fn associated_ty_data(&self, ty: AssocItemId<ChalkIr>) -> Arc<AssociatedTyDatum<ChalkIr>> {
390390
self.associated_ty_data[&ty].clone()
391391
}
392392

@@ -587,7 +587,7 @@ impl RustIrDatabase<ChalkIr> for Program {
587587
// normally acceptable, but causes the re-parse tests for the .chalk syntax
588588
// writer to fail. This is because they use the `Eq` implementation on
589589
// Program, which checks for name equality.
590-
fn assoc_type_name(&self, assoc_type_id: AssocTypeId<ChalkIr>) -> String {
590+
fn assoc_type_name(&self, assoc_type_id: AssocItemId<ChalkIr>) -> String {
591591
self.associated_ty_data
592592
.get(&assoc_type_id)
593593
.unwrap()

chalk-integration/src/test_macros.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ macro_rules! ty {
3939
};
4040

4141
(projection (item $n:tt) $($arg:tt)*) => {
42-
chalk_ir::AliasTy::Projection(chalk_ir::ProjectionTy {
43-
associated_ty_id: AssocTypeId(chalk_integration::interner::RawId { index: $n }),
42+
chalk_ir::AliasTy::Projection(chalk_ir::ProjectionTerm {
43+
associated_term_id: AssocItemId(chalk_integration::interner::RawId { index: $n }),
4444
substitution: chalk_ir::Substitution::from_iter(
4545
chalk_integration::interner::ChalkIr,
4646
vec![$(arg!($arg)),*] as Vec<chalk_ir::GenericArg<_>>

chalk-integration/src/tls.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use crate::interner::ChalkIr;
22
use chalk_ir::{
3-
debug::SeparatorTraitRef, AdtId, AliasTy, AssocTypeId, CanonicalVarKinds, Constraints, FnDefId,
3+
debug::SeparatorTraitRef, AdtId, AliasTy, AssocItemId, CanonicalVarKinds, Constraints, FnDefId,
44
GenericArg, Goal, Goals, Lifetime, OpaqueTy, OpaqueTyId, ProgramClause,
5-
ProgramClauseImplication, ProgramClauses, ProjectionTy, QuantifiedWhereClauses, Substitution,
5+
ProgramClauseImplication, ProgramClauses, ProjectionTerm, QuantifiedWhereClauses, Substitution,
66
TraitId, Ty, VariableKinds, Variances,
77
};
88
use std::cell::RefCell;
@@ -28,7 +28,7 @@ pub trait DebugContext {
2828

2929
fn debug_assoc_type_id(
3030
&self,
31-
id: AssocTypeId<ChalkIr>,
31+
id: AssocItemId<ChalkIr>,
3232
fmt: &mut fmt::Formatter<'_>,
3333
) -> Result<(), fmt::Error>;
3434

@@ -58,7 +58,7 @@ pub trait DebugContext {
5858

5959
fn debug_projection_ty(
6060
&self,
61-
proj: &ProjectionTy<ChalkIr>,
61+
proj: &ProjectionTerm<ChalkIr>,
6262
fmt: &mut fmt::Formatter<'_>,
6363
) -> Result<(), fmt::Error>;
6464

chalk-ir/src/debug.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ impl<I: Interner> Debug for AdtId<I> {
3030
}
3131
}
3232

33-
impl<I: Interner> Debug for AssocTypeId<I> {
33+
impl<I: Interner> Debug for AssocItemId<I> {
3434
fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error> {
3535
I::debug_assoc_type_id(*self, fmt)
36-
.unwrap_or_else(|| write!(fmt, "AssocTypeId({:?})", self.0))
36+
.unwrap_or_else(|| write!(fmt, "AssocItemId({:?})", self.0))
3737
}
3838
}
3939

@@ -150,10 +150,10 @@ impl<I: Interner> Debug for QuantifiedWhereClauses<I> {
150150
}
151151
}
152152

153-
impl<I: Interner> Debug for ProjectionTy<I> {
153+
impl<I: Interner> Debug for ProjectionTerm<I> {
154154
fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error> {
155155
I::debug_projection_ty(self, fmt).unwrap_or_else(|| {
156-
unimplemented!("cannot format ProjectionTy without setting Program in tls")
156+
unimplemented!("cannot format ProjectionTerm without setting Program in tls")
157157
})
158158
}
159159
}
@@ -694,30 +694,30 @@ impl<I: Interner> Debug for TypeOutlives<I> {
694694

695695
/// Helper struct for showing debug output for projection types.
696696
pub struct ProjectionTyDebug<'a, I: Interner> {
697-
projection_ty: &'a ProjectionTy<I>,
697+
projection_term: &'a ProjectionTerm<I>,
698698
interner: I,
699699
}
700700

701701
impl<'a, I: Interner> Debug for ProjectionTyDebug<'a, I> {
702702
fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error> {
703703
let ProjectionTyDebug {
704-
projection_ty,
704+
projection_term,
705705
interner,
706706
} = self;
707707
write!(
708708
fmt,
709709
"({:?}){:?}",
710-
projection_ty.associated_ty_id,
711-
projection_ty.substitution.with_angle(*interner)
710+
projection_term.associated_term_id,
711+
projection_term.substitution.with_angle(*interner)
712712
)
713713
}
714714
}
715715

716-
impl<I: Interner> ProjectionTy<I> {
716+
impl<I: Interner> ProjectionTerm<I> {
717717
/// Show debug output for the projection type.
718718
pub fn debug(&self, interner: I) -> ProjectionTyDebug<'_, I> {
719719
ProjectionTyDebug {
720-
projection_ty: self,
720+
projection_term: self,
721721
interner,
722722
}
723723
}

chalk-ir/src/fold/boring_impls.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ macro_rules! id_fold {
213213
id_fold!(ImplId);
214214
id_fold!(AdtId);
215215
id_fold!(TraitId);
216-
id_fold!(AssocTypeId);
216+
id_fold!(AssocItemId);
217217
id_fold!(OpaqueTyId);
218218
id_fold!(FnDefId);
219219
id_fold!(ClosureId);

chalk-ir/src/interner.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Encapsulates the concrete representation of core types such as types and goals.
22
use crate::AliasTy;
3-
use crate::AssocTypeId;
3+
use crate::AssocItemId;
44
use crate::CanonicalVarKind;
55
use crate::CanonicalVarKinds;
66
use crate::ClosureId;
@@ -23,7 +23,7 @@ use crate::ProgramClause;
2323
use crate::ProgramClauseData;
2424
use crate::ProgramClauseImplication;
2525
use crate::ProgramClauses;
26-
use crate::ProjectionTy;
26+
use crate::ProjectionTerm;
2727
use crate::QuantifiedWhereClause;
2828
use crate::QuantifiedWhereClauses;
2929
use crate::SeparatorTraitRef;
@@ -221,7 +221,7 @@ pub trait Interner: Debug + Copy + Eq + Hash + Sized {
221221
/// Returns `None` to fallback to the default debug output.
222222
#[allow(unused_variables)]
223223
fn debug_assoc_type_id(
224-
type_id: AssocTypeId<Self>,
224+
type_id: AssocItemId<Self>,
225225
fmt: &mut fmt::Formatter<'_>,
226226
) -> Option<fmt::Result> {
227227
None
@@ -289,11 +289,11 @@ pub trait Interner: Debug + Copy + Eq + Hash + Sized {
289289
None
290290
}
291291

292-
/// Prints the debug representation of a ProjectionTy.
292+
/// Prints the debug representation of a ProjectionTerm.
293293
/// Returns `None` to fallback to the default debug output.
294294
#[allow(unused_variables)]
295295
fn debug_projection_ty(
296-
projection_ty: &ProjectionTy<Self>,
296+
projection_ty: &ProjectionTerm<Self>,
297297
fmt: &mut fmt::Formatter<'_>,
298298
) -> Option<fmt::Result> {
299299
None

0 commit comments

Comments
 (0)