Skip to content

Commit b64e5a8

Browse files
committed
refactor Parameter and ParameterKind
1 parent 3e9c250 commit b64e5a8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+702
-708
lines changed

book/src/types.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ not been thoroughly discussed by the Rust compiler team as a whole.
5757
Here is a (partial) list of some things that have to be adapted in
5858
Chalk as of today to match this document:
5959

60-
* `Parameter<I>` needs to be renamed to `GenericArgument`
61-
* `Vec<Parameter<I>>` needs to be replaced with `GenericArguments`
6260
* Extract `TypeName` into something opaque to chalk-ir.
6361
* Dyn type equality should probably be driven by entailment.
6462
* Projections need to be renamed to aliases.

chalk-engine/src/context.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ pub trait Context: Clone + Debug {
103103

104104
/// A term that can be quantified over and unified -- in current
105105
/// Chalk, either a type or lifetime.
106-
type Parameter: Debug;
106+
type GenericArg: Debug;
107107

108108
/// A rule like `DomainGoal :- Goal`.
109109
///
@@ -354,13 +354,13 @@ pub trait UnificationOps<C: Context> {
354354
///
355355
/// If the parameters fail to unify, then `Error` is returned
356356
// Used by: simplify
357-
fn unify_parameters_into_ex_clause(
357+
fn unify_generic_args_into_ex_clause(
358358
&mut self,
359359
interner: &C::Interner,
360360
environment: &C::Environment,
361361
variance: C::Variance,
362-
a: &C::Parameter,
363-
b: &C::Parameter,
362+
a: &C::GenericArg,
363+
b: &C::GenericArg,
364364
ex_clause: &mut ExClause<C>,
365365
) -> Fallible<()>;
366366
}

chalk-engine/src/hh.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub enum HhGoal<C: Context> {
1010
Implies(C::ProgramClauses, C::Goal),
1111
All(Vec<C::Goal>),
1212
Not(C::Goal),
13-
Unify(C::Variance, C::Parameter, C::Parameter),
13+
Unify(C::Variance, C::GenericArg, C::GenericArg),
1414
DomainGoal(C::DomainGoal),
1515

1616
/// Indicates something that cannot be proven to be true or false

chalk-engine/src/simplify.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl<C: Context> Forest<C> {
5757
subgoal,
5858
)));
5959
}
60-
HhGoal::Unify(variance, a, b) => infer.unify_parameters_into_ex_clause(
60+
HhGoal::Unify(variance, a, b) => infer.unify_generic_args_into_ex_clause(
6161
context.interner(),
6262
&environment,
6363
variance,

chalk-integration/src/db.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ use chalk_ir::AssocTypeId;
99
use chalk_ir::Canonical;
1010
use chalk_ir::ConstrainedSubst;
1111
use chalk_ir::Environment;
12+
use chalk_ir::GenericArg;
1213
use chalk_ir::Goal;
1314
use chalk_ir::ImplId;
1415
use chalk_ir::InEnvironment;
1516
use chalk_ir::OpaqueTyId;
16-
use chalk_ir::Parameter;
1717
use chalk_ir::ProgramClause;
1818
use chalk_ir::StructId;
1919
use chalk_ir::TraitId;
@@ -117,11 +117,11 @@ impl RustIrDatabase<ChalkIr> for ChalkDatabase {
117117
fn impls_for_trait(
118118
&self,
119119
trait_id: TraitId<ChalkIr>,
120-
parameters: &[Parameter<ChalkIr>],
120+
generic_args: &[GenericArg<ChalkIr>],
121121
) -> Vec<ImplId<ChalkIr>> {
122122
self.program_ir()
123123
.unwrap()
124-
.impls_for_trait(trait_id, parameters)
124+
.impls_for_trait(trait_id, generic_args)
125125
}
126126

127127
fn local_impls_to_coherence_check(&self, trait_id: TraitId<ChalkIr>) -> Vec<ImplId<ChalkIr>> {

chalk-integration/src/interner.rs

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
use crate::tls;
22
use chalk_ir::interner::{HasInterner, Interner};
33
use chalk_ir::{
4-
AliasTy, ApplicationTy, AssocTypeId, CanonicalVarKinds, Goals, Lifetime, OpaqueTy, OpaqueTyId,
5-
ParameterKinds, ProgramClauseImplication, ProgramClauses, ProjectionTy, QuantifiedWhereClauses,
6-
SeparatorTraitRef, Substitution, TraitId, Ty,
4+
AliasTy, ApplicationTy, AssocTypeId, CanonicalVarKind, CanonicalVarKinds, Goals, Lifetime,
5+
OpaqueTy, OpaqueTyId, ProgramClauseImplication, ProgramClauses, ProjectionTy,
6+
QuantifiedWhereClauses, SeparatorTraitRef, Substitution, TraitId, Ty, VariableKind,
7+
VariableKinds,
78
};
89
use chalk_ir::{
9-
Goal, GoalData, LifetimeData, Parameter, ParameterData, ParameterKind, ProgramClause,
10-
ProgramClauseData, QuantifiedWhereClause, StructId, TyData, UniverseIndex,
10+
GenericArg, GenericArgData, Goal, GoalData, LifetimeData, ProgramClause, ProgramClauseData,
11+
QuantifiedWhereClause, StructId, TyData,
1112
};
1213
use std::fmt;
1314
use std::fmt::Debug;
@@ -35,15 +36,15 @@ pub struct ChalkIr;
3536
impl Interner for ChalkIr {
3637
type InternedType = Arc<TyData<ChalkIr>>;
3738
type InternedLifetime = LifetimeData<ChalkIr>;
38-
type InternedParameter = ParameterData<ChalkIr>;
39+
type InternedGenericArg = GenericArgData<ChalkIr>;
3940
type InternedGoal = Arc<GoalData<ChalkIr>>;
4041
type InternedGoals = Vec<Goal<ChalkIr>>;
41-
type InternedSubstitution = Vec<Parameter<ChalkIr>>;
42+
type InternedSubstitution = Vec<GenericArg<ChalkIr>>;
4243
type InternedProgramClause = ProgramClauseData<ChalkIr>;
4344
type InternedProgramClauses = Vec<ProgramClause<ChalkIr>>;
4445
type InternedQuantifiedWhereClauses = Vec<QuantifiedWhereClause<ChalkIr>>;
45-
type InternedParameterKinds = Vec<ParameterKind<()>>;
46-
type InternedCanonicalVarKinds = Vec<ParameterKind<UniverseIndex>>;
46+
type InternedVariableKinds = Vec<VariableKind<ChalkIr>>;
47+
type InternedCanonicalVarKinds = Vec<CanonicalVarKind<ChalkIr>>;
4748
type DefId = RawId;
4849
type Identifier = Identifier;
4950

@@ -105,26 +106,26 @@ impl Interner for ChalkIr {
105106
.or_else(|| Some(write!(fmt, "{:?}", lifetime.interned())))
106107
}
107108

108-
fn debug_parameter(
109-
parameter: &Parameter<ChalkIr>,
109+
fn debug_generic_arg(
110+
generic_arg: &GenericArg<ChalkIr>,
110111
fmt: &mut fmt::Formatter<'_>,
111112
) -> Option<fmt::Result> {
112-
tls::with_current_program(|prog| Some(prog?.debug_parameter(parameter, fmt)))
113+
tls::with_current_program(|prog| Some(prog?.debug_generic_arg(generic_arg, fmt)))
113114
}
114115

115-
fn debug_parameter_kinds(
116-
parameter_kinds: &ParameterKinds<Self>,
116+
fn debug_variable_kinds(
117+
variable_kinds: &VariableKinds<Self>,
117118
fmt: &mut fmt::Formatter<'_>,
118119
) -> Option<fmt::Result> {
119-
tls::with_current_program(|prog| Some(prog?.debug_parameter_kinds(parameter_kinds, fmt)))
120+
tls::with_current_program(|prog| Some(prog?.debug_variable_kinds(variable_kinds, fmt)))
120121
}
121122

122-
fn debug_parameter_kinds_with_angles(
123-
parameter_kinds: &ParameterKinds<Self>,
123+
fn debug_variable_kinds_with_angles(
124+
variable_kinds: &VariableKinds<Self>,
124125
fmt: &mut fmt::Formatter<'_>,
125126
) -> Option<fmt::Result> {
126127
tls::with_current_program(|prog| {
127-
Some(prog?.debug_parameter_kinds_with_angles(parameter_kinds, fmt))
128+
Some(prog?.debug_variable_kinds_with_angles(variable_kinds, fmt))
128129
})
129130
}
130131

@@ -212,15 +213,15 @@ impl Interner for ChalkIr {
212213
lifetime
213214
}
214215

215-
fn intern_parameter(&self, parameter: ParameterData<ChalkIr>) -> ParameterData<ChalkIr> {
216-
parameter
216+
fn intern_generic_arg(&self, generic_arg: GenericArgData<ChalkIr>) -> GenericArgData<ChalkIr> {
217+
generic_arg
217218
}
218219

219-
fn parameter_data<'a>(
220+
fn generic_arg_data<'a>(
220221
&self,
221-
parameter: &'a ParameterData<ChalkIr>,
222-
) -> &'a ParameterData<ChalkIr> {
223-
parameter
222+
generic_arg: &'a GenericArgData<ChalkIr>,
223+
) -> &'a GenericArgData<ChalkIr> {
224+
generic_arg
224225
}
225226

226227
fn intern_goal(&self, goal: GoalData<ChalkIr>) -> Arc<GoalData<ChalkIr>> {
@@ -244,15 +245,15 @@ impl Interner for ChalkIr {
244245

245246
fn intern_substitution<E>(
246247
&self,
247-
data: impl IntoIterator<Item = Result<Parameter<ChalkIr>, E>>,
248-
) -> Result<Vec<Parameter<ChalkIr>>, E> {
248+
data: impl IntoIterator<Item = Result<GenericArg<ChalkIr>, E>>,
249+
) -> Result<Vec<GenericArg<ChalkIr>>, E> {
249250
data.into_iter().collect()
250251
}
251252

252253
fn substitution_data<'a>(
253254
&self,
254-
substitution: &'a Vec<Parameter<ChalkIr>>,
255-
) -> &'a [Parameter<ChalkIr>] {
255+
substitution: &'a Vec<GenericArg<ChalkIr>>,
256+
) -> &'a [GenericArg<ChalkIr>] {
256257
substitution
257258
}
258259

@@ -294,31 +295,31 @@ impl Interner for ChalkIr {
294295
) -> &'a [QuantifiedWhereClause<Self>] {
295296
clauses
296297
}
297-
fn intern_parameter_kinds<E>(
298+
fn intern_generic_arg_kinds<E>(
298299
&self,
299-
data: impl IntoIterator<Item = Result<ParameterKind<()>, E>>,
300-
) -> Result<Self::InternedParameterKinds, E> {
300+
data: impl IntoIterator<Item = Result<VariableKind<ChalkIr>, E>>,
301+
) -> Result<Self::InternedVariableKinds, E> {
301302
data.into_iter().collect()
302303
}
303304

304-
fn parameter_kinds_data<'a>(
305+
fn variable_kinds_data<'a>(
305306
&self,
306-
parameter_kinds: &'a Self::InternedParameterKinds,
307-
) -> &'a [ParameterKind<()>] {
308-
parameter_kinds
307+
variable_kinds: &'a Self::InternedVariableKinds,
308+
) -> &'a [VariableKind<ChalkIr>] {
309+
variable_kinds
309310
}
310311

311312
fn intern_canonical_var_kinds<E>(
312313
&self,
313-
data: impl IntoIterator<Item = Result<ParameterKind<UniverseIndex>, E>>,
314+
data: impl IntoIterator<Item = Result<CanonicalVarKind<ChalkIr>, E>>,
314315
) -> Result<Self::InternedCanonicalVarKinds, E> {
315316
data.into_iter().collect()
316317
}
317318

318319
fn canonical_var_kinds_data<'a>(
319320
&self,
320321
canonical_var_kinds: &'a Self::InternedCanonicalVarKinds,
321-
) -> &'a [ParameterKind<UniverseIndex>] {
322+
) -> &'a [CanonicalVarKind<ChalkIr>] {
322323
canonical_var_kinds
323324
}
324325
}

0 commit comments

Comments
 (0)