Skip to content

Commit c93db52

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 f47846d commit c93db52

32 files changed

+144
-139
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

@@ -231,7 +231,7 @@ impl RustIrDatabase<ChalkIr> for ChalkDatabase {
231231
self.program_ir().unwrap().adt_name(struct_id)
232232
}
233233

234-
fn assoc_type_name(&self, assoc_ty_id: AssocTypeId<ChalkIr>) -> String {
234+
fn assoc_type_name(&self, assoc_ty_id: AssocItemId<ChalkIr>) -> String {
235235
self.program_ir().unwrap().assoc_type_name(assoc_ty_id)
236236
}
237237

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
@@ -610,11 +610,11 @@ impl Lower for TraitFlags {
610610
}
611611
}
612612

613-
impl LowerWithEnv for ProjectionTy {
614-
type Lowered = chalk_ir::ProjectionTy<ChalkIr>;
613+
impl LowerWithEnv for ProjectionTerm {
614+
type Lowered = chalk_ir::ProjectionTerm<ChalkIr>;
615615

616616
fn lower(&self, env: &Env) -> LowerResult<Self::Lowered> {
617-
let ProjectionTy {
617+
let ProjectionTerm {
618618
ref trait_ref,
619619
ref name,
620620
ref args,
@@ -650,8 +650,8 @@ impl LowerWithEnv for ProjectionTy {
650650

651651
args.extend(trait_substitution.iter(interner).cloned());
652652

653-
Ok(chalk_ir::ProjectionTy {
654-
associated_ty_id: lookup.id,
653+
Ok(chalk_ir::ProjectionTerm {
654+
associated_term_id: lookup.id,
655655
substitution: chalk_ir::Substitution::from_iter(interner, args),
656656
})
657657
}

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::{
@@ -95,7 +95,7 @@ pub struct Program {
9595
pub well_known_traits: BTreeMap<WellKnownTrait, TraitId<ChalkIr>>,
9696

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

100100
/// For each user-specified clause
101101
pub custom_clauses: Vec<ProgramClause<ChalkIr>>,
@@ -149,13 +149,13 @@ impl tls::DebugContext for Program {
149149

150150
fn debug_assoc_type_id(
151151
&self,
152-
assoc_type_id: AssocTypeId<ChalkIr>,
152+
assoc_type_id: AssocItemId<ChalkIr>,
153153
fmt: &mut fmt::Formatter<'_>,
154154
) -> Result<(), fmt::Error> {
155155
if let Some(d) = self.associated_ty_data.get(&assoc_type_id) {
156156
write!(fmt, "({:?}::{})", d.trait_id, d.name)
157157
} else {
158-
fmt.debug_struct("InvalidAssocTypeId")
158+
fmt.debug_struct("InvalidAssocItemId")
159159
.field("index", &assoc_type_id.0)
160160
.finish()
161161
}
@@ -202,7 +202,7 @@ impl tls::DebugContext for Program {
202202

203203
fn debug_projection_ty(
204204
&self,
205-
projection_ty: &ProjectionTy<ChalkIr>,
205+
projection_ty: &ProjectionTerm<ChalkIr>,
206206
fmt: &mut fmt::Formatter<'_>,
207207
) -> Result<(), fmt::Error> {
208208
let (associated_ty_data, trait_params, other_params) = self.split_projection(projection_ty);
@@ -384,7 +384,7 @@ impl RustIrDatabase<ChalkIr> for Program {
384384
self.custom_clauses.clone()
385385
}
386386

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

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

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
@@ -16,10 +16,10 @@ impl<I: Interner> Debug for AdtId<I> {
1616
}
1717
}
1818

19-
impl<I: Interner> Debug for AssocTypeId<I> {
19+
impl<I: Interner> Debug for AssocItemId<I> {
2020
fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error> {
2121
I::debug_assoc_type_id(*self, fmt)
22-
.unwrap_or_else(|| write!(fmt, "AssocTypeId({:?})", self.0))
22+
.unwrap_or_else(|| write!(fmt, "AssocItemId({:?})", self.0))
2323
}
2424
}
2525

@@ -136,10 +136,10 @@ impl<I: Interner> Debug for QuantifiedWhereClauses<I> {
136136
}
137137
}
138138

139-
impl<I: Interner> Debug for ProjectionTy<I> {
139+
impl<I: Interner> Debug for ProjectionTerm<I> {
140140
fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error> {
141141
I::debug_projection_ty(self, fmt).unwrap_or_else(|| {
142-
unimplemented!("cannot format ProjectionTy without setting Program in tls")
142+
unimplemented!("cannot format ProjectionTerm without setting Program in tls")
143143
})
144144
}
145145
}
@@ -680,30 +680,30 @@ impl<I: Interner> Debug for TypeOutlives<I> {
680680

681681
/// Helper struct for showing debug output for projection types.
682682
pub struct ProjectionTyDebug<'a, I: Interner> {
683-
projection_ty: &'a ProjectionTy<I>,
683+
projection_term: &'a ProjectionTerm<I>,
684684
interner: I,
685685
}
686686

687687
impl<'a, I: Interner> Debug for ProjectionTyDebug<'a, I> {
688688
fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error> {
689689
let ProjectionTyDebug {
690-
projection_ty,
690+
projection_term,
691691
interner,
692692
} = self;
693693
write!(
694694
fmt,
695695
"({:?}){:?}",
696-
projection_ty.associated_ty_id,
697-
projection_ty.substitution.with_angle(*interner)
696+
projection_term.associated_term_id,
697+
projection_term.substitution.with_angle(*interner)
698698
)
699699
}
700700
}
701701

702-
impl<I: Interner> ProjectionTy<I> {
702+
impl<I: Interner> ProjectionTerm<I> {
703703
/// Show debug output for the projection type.
704704
pub fn debug<'a>(&'a self, interner: I) -> ProjectionTyDebug<'a, I> {
705705
ProjectionTyDebug {
706-
projection_ty: self,
706+
projection_term: self,
707707
interner,
708708
}
709709
}

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)