Skip to content

Commit 95c5ed2

Browse files
committed
TyKind -> TyVariableKind
1 parent 8f88cdf commit 95c5ed2

File tree

18 files changed

+71
-71
lines changed

18 files changed

+71
-71
lines changed

book/src/clauses/type_equality.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Placeholder associated types are never written directly by the user.
9393
They are used internally by the trait system only, as we will see
9494
shortly.
9595

96-
In rustc, they correspond to the `TyKind::UnnormalizedProjectionTy` enum
96+
In rustc, they correspond to the `TyVariableKind::UnnormalizedProjectionTy` enum
9797
variant, declared in [`compiler/rustc_middle/src/ty/sty.rs`][sty]. In chalk, we use an
9898
`ApplicationTy` with a name living in a special namespace dedicated to
9999
placeholder associated types (see the `TypeName` enum declared in

book/src/types/rust_types.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,13 @@ other type without any effect, and so forth.
165165

166166
## Mapping to rustc types
167167

168-
The rustc [`TyKind`] enum has a lot more variants than chalk. This
168+
The rustc [`TyVariableKind`] enum has a lot more variants than chalk. This
169169
section describes how the rustc types can be mapped to chalk
170170
types. The intention is that, at least when transitioning, rustc would
171-
implement the `Interner` trait and would map from the [`TyKind`]
171+
implement the `Interner` trait and would map from the [`TyVariableKind`]
172172
enum to chalk's `TyData` on the fly, when `data()` is invoked.
173173

174-
[`TyKind`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/enum.TyKind.html
174+
[`TyVariableKind`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/enum.TyVariableKind.html
175175

176176
This section describes how each of rustc's variants can be mapped to
177177
Chalk variants.

chalk-engine/src/normalize_deep.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ where
4646
fn fold_inference_ty(
4747
&mut self,
4848
var: InferenceVar,
49-
kind: TyKind,
49+
kind: TyVariableKind,
5050
_outer_binder: DebruijnIndex,
5151
) -> Fallible<Ty<I>> {
5252
let interner = self.interner;

chalk-integration/src/lowering.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ mod program_lowerer;
44
use chalk_ir::cast::{Cast, Caster};
55
use chalk_ir::{
66
self, BoundVar, ClausePriority, DebruijnIndex, ImplId, QuantifiedWhereClauses, Substitution,
7-
TyKind,
7+
TyVariableKind,
88
};
99
use chalk_parse::ast::*;
1010
use chalk_solve::rust_ir::{self, IntoWhereClauses};
@@ -102,7 +102,7 @@ lower_param_map!(Clause, None);
102102
lower_param_map!(
103103
TraitDefn,
104104
Some(chalk_ir::WithKind::new(
105-
chalk_ir::VariableKind::Ty(TyKind::General),
105+
chalk_ir::VariableKind::Ty(TyVariableKind::General),
106106
Atom::from(SELF),
107107
))
108108
);
@@ -120,11 +120,11 @@ impl Lower for VariableKind {
120120
type Lowered = chalk_ir::WithKind<ChalkIr, Ident>;
121121
fn lower(&self) -> Self::Lowered {
122122
let (kind, n) = match self {
123-
VariableKind::Ty(n) => (chalk_ir::VariableKind::Ty(chalk_ir::TyKind::General), n),
123+
VariableKind::Ty(n) => (chalk_ir::VariableKind::Ty(chalk_ir::TyVariableKind::General), n),
124124
VariableKind::IntegerTy(n) => {
125-
(chalk_ir::VariableKind::Ty(chalk_ir::TyKind::Integer), n)
125+
(chalk_ir::VariableKind::Ty(chalk_ir::TyVariableKind::Integer), n)
126126
}
127-
VariableKind::FloatTy(n) => (chalk_ir::VariableKind::Ty(chalk_ir::TyKind::Float), n),
127+
VariableKind::FloatTy(n) => (chalk_ir::VariableKind::Ty(chalk_ir::TyVariableKind::Float), n),
128128
VariableKind::Lifetime(n) => (chalk_ir::VariableKind::Lifetime, n),
129129
VariableKind::Const(ref n) => (chalk_ir::VariableKind::Const(get_type_of_u32()), n),
130130
};
@@ -672,7 +672,7 @@ impl LowerWithEnv for Ty {
672672
bounds: env.in_binders(
673673
// FIXME: Figure out a proper name for this type parameter
674674
Some(chalk_ir::WithKind::new(
675-
chalk_ir::VariableKind::Ty(TyKind::General),
675+
chalk_ir::VariableKind::Ty(TyVariableKind::General),
676676
Atom::from(FIXME_SELF),
677677
)),
678678
|env| {

chalk-integration/src/lowering/env.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub type FnDefKinds = BTreeMap<chalk_ir::FnDefId<ChalkIr>, TypeKind>;
2323
pub type ClosureKinds = BTreeMap<chalk_ir::ClosureId<ChalkIr>, TypeKind>;
2424
pub type TraitKinds = BTreeMap<chalk_ir::TraitId<ChalkIr>, TypeKind>;
2525
pub type AutoTraits = BTreeMap<chalk_ir::TraitId<ChalkIr>, bool>;
26-
pub type OpaqueTyKinds = BTreeMap<chalk_ir::OpaqueTyId<ChalkIr>, TypeKind>;
26+
pub type OpaqueTyVariableKinds = BTreeMap<chalk_ir::OpaqueTyId<ChalkIr>, TypeKind>;
2727
pub type GeneratorKinds = BTreeMap<chalk_ir::GeneratorId<ChalkIr>, TypeKind>;
2828
pub type AssociatedTyLookups = BTreeMap<(chalk_ir::TraitId<ChalkIr>, Ident), AssociatedTyLookup>;
2929
pub type AssociatedTyValueIds =
@@ -45,7 +45,7 @@ pub struct Env<'k> {
4545
pub trait_ids: &'k TraitIds,
4646
pub trait_kinds: &'k TraitKinds,
4747
pub opaque_ty_ids: &'k OpaqueTyIds,
48-
pub opaque_ty_kinds: &'k OpaqueTyKinds,
48+
pub opaque_ty_kinds: &'k OpaqueTyVariableKinds,
4949
pub associated_ty_lookups: &'k AssociatedTyLookups,
5050
pub auto_traits: &'k AutoTraits,
5151
pub foreign_ty_ids: &'k ForeignIds,

chalk-integration/src/lowering/program_lowerer.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use chalk_ir::cast::Cast;
22
use chalk_ir::{
33
self, AdtId, AssocTypeId, BoundVar, ClosureId, DebruijnIndex, FnDefId, ForeignDefId,
4-
GeneratorId, ImplId, OpaqueTyId, TraitId, TyKind, VariableKinds,
4+
GeneratorId, ImplId, OpaqueTyId, TraitId, TyVariableKind, VariableKinds,
55
};
66
use chalk_parse::ast::*;
77
use chalk_solve::rust_ir::{
@@ -37,7 +37,7 @@ pub(super) struct ProgramLowerer {
3737
generator_kinds: GeneratorKinds,
3838
closure_kinds: ClosureKinds,
3939
trait_kinds: TraitKinds,
40-
opaque_ty_kinds: OpaqueTyKinds,
40+
opaque_ty_kinds: OpaqueTyVariableKinds,
4141
object_safe_traits: HashSet<TraitId<ChalkIr>>,
4242
foreign_ty_ids: ForeignIds,
4343
}
@@ -321,7 +321,7 @@ impl ProgramLowerer {
321321
let bounds: chalk_ir::Binders<Vec<chalk_ir::Binders<_>>> = env
322322
.in_binders(
323323
Some(chalk_ir::WithKind::new(
324-
chalk_ir::VariableKind::Ty(TyKind::General),
324+
chalk_ir::VariableKind::Ty(TyVariableKind::General),
325325
Atom::from(FIXME_SELF),
326326
)),
327327
|env| {
@@ -347,7 +347,7 @@ impl ProgramLowerer {
347347
let where_clauses: chalk_ir::Binders<Vec<chalk_ir::Binders<_>>> = env
348348
.in_binders(
349349
Some(chalk_ir::WithKind::new(
350-
chalk_ir::VariableKind::Ty(TyKind::General),
350+
chalk_ir::VariableKind::Ty(TyVariableKind::General),
351351
Atom::from(FIXME_SELF),
352352
)),
353353
|env| opaque_ty.where_clauses.lower(env),

chalk-integration/src/test_macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ macro_rules! ty {
4545
};
4646

4747
(infer $b:expr) => {
48-
chalk_ir::TyData::InferenceVar(chalk_ir::InferenceVar::from($b), chalk_ir::TyKind::General)
48+
chalk_ir::TyData::InferenceVar(chalk_ir::InferenceVar::from($b), chalk_ir::TyVariableKind::General)
4949
.intern(&chalk_integration::interner::ChalkIr)
5050
};
5151

chalk-ir/src/debug.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,9 @@ impl<I: Interner> Debug for TyData<I> {
225225
match self {
226226
TyData::BoundVar(db) => write!(fmt, "{:?}", db),
227227
TyData::Dyn(clauses) => write!(fmt, "{:?}", clauses),
228-
TyData::InferenceVar(var, TyKind::General) => write!(fmt, "{:?}", var),
229-
TyData::InferenceVar(var, TyKind::Integer) => write!(fmt, "{:?}i", var),
230-
TyData::InferenceVar(var, TyKind::Float) => write!(fmt, "{:?}f", var),
228+
TyData::InferenceVar(var, TyVariableKind::General) => write!(fmt, "{:?}", var),
229+
TyData::InferenceVar(var, TyVariableKind::Integer) => write!(fmt, "{:?}i", var),
230+
TyData::InferenceVar(var, TyVariableKind::Float) => write!(fmt, "{:?}f", var),
231231
TyData::Apply(apply) => write!(fmt, "{:?}", apply),
232232
TyData::Alias(alias) => write!(fmt, "{:?}", alias),
233233
TyData::Placeholder(index) => write!(fmt, "{:?}", index),
@@ -332,9 +332,9 @@ impl<'a, I: Interner> Debug for VariableKindsInnerDebug<'a, I> {
332332
write!(fmt, ", ")?;
333333
}
334334
match binder {
335-
VariableKind::Ty(TyKind::General) => write!(fmt, "type")?,
336-
VariableKind::Ty(TyKind::Integer) => write!(fmt, "integer type")?,
337-
VariableKind::Ty(TyKind::Float) => write!(fmt, "float type")?,
335+
VariableKind::Ty(TyVariableKind::General) => write!(fmt, "type")?,
336+
VariableKind::Ty(TyVariableKind::Integer) => write!(fmt, "integer type")?,
337+
VariableKind::Ty(TyVariableKind::Float) => write!(fmt, "float type")?,
338338
VariableKind::Lifetime => write!(fmt, "lifetime")?,
339339
VariableKind::Const(ty) => write!(fmt, "const: {:?}", ty)?,
340340
}
@@ -857,9 +857,9 @@ impl<I: Interner> Debug for GenericArgData<I> {
857857
impl<I: Interner> Debug for VariableKind<I> {
858858
fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error> {
859859
match self {
860-
VariableKind::Ty(TyKind::General) => write!(fmt, "type"),
861-
VariableKind::Ty(TyKind::Integer) => write!(fmt, "integer type"),
862-
VariableKind::Ty(TyKind::Float) => write!(fmt, "float type"),
860+
VariableKind::Ty(TyVariableKind::General) => write!(fmt, "type"),
861+
VariableKind::Ty(TyVariableKind::Integer) => write!(fmt, "integer type"),
862+
VariableKind::Ty(TyVariableKind::Float) => write!(fmt, "float type"),
863863
VariableKind::Lifetime => write!(fmt, "lifetime"),
864864
VariableKind::Const(ty) => write!(fmt, "const: {:?}", ty),
865865
}
@@ -870,9 +870,9 @@ impl<I: Interner, T: Debug> Debug for WithKind<I, T> {
870870
fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error> {
871871
let value = self.skip_kind();
872872
match &self.kind {
873-
VariableKind::Ty(TyKind::General) => write!(fmt, "{:?} with kind type", value),
874-
VariableKind::Ty(TyKind::Integer) => write!(fmt, "{:?} with kind integer type", value),
875-
VariableKind::Ty(TyKind::Float) => write!(fmt, "{:?} with kind float type", value),
873+
VariableKind::Ty(TyVariableKind::General) => write!(fmt, "{:?} with kind type", value),
874+
VariableKind::Ty(TyVariableKind::Integer) => write!(fmt, "{:?} with kind integer type", value),
875+
VariableKind::Ty(TyVariableKind::Float) => write!(fmt, "{:?} with kind float type", value),
876876
VariableKind::Lifetime => write!(fmt, "{:?} with kind lifetime", value),
877877
VariableKind::Const(ty) => write!(fmt, "{:?} with kind {:?}", value, ty),
878878
}

chalk-ir/src/fold.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ where
270270
fn fold_inference_ty(
271271
&mut self,
272272
var: InferenceVar,
273-
kind: TyKind,
273+
kind: TyVariableKind,
274274
outer_binder: DebruijnIndex,
275275
) -> Fallible<Ty<TI>> {
276276
if self.forbid_inference_vars() {

chalk-ir/src/lib.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -439,16 +439,16 @@ impl<I: Interner> Ty<I> {
439439
}
440440
}
441441

442-
/// Returns true if this is a `BoundVar` or an `InferenceVar` of `TyKind::General`.
442+
/// Returns true if this is a `BoundVar` or an `InferenceVar` of `TyVariableKind::General`.
443443
pub fn is_general_var(&self, interner: &I, binders: &CanonicalVarKinds<I>) -> bool {
444444
match self.data(interner) {
445445
TyData::BoundVar(bv)
446446
if bv.debruijn == DebruijnIndex::INNERMOST
447-
&& binders.at(interner, bv.index).kind == VariableKind::Ty(TyKind::General) =>
447+
&& binders.at(interner, bv.index).kind == VariableKind::Ty(TyVariableKind::General) =>
448448
{
449449
true
450450
}
451-
TyData::InferenceVar(_, TyKind::General) => true,
451+
TyData::InferenceVar(_, TyVariableKind::General) => true,
452452
_ => false,
453453
}
454454
}
@@ -547,7 +547,7 @@ pub enum TyData<I: Interner> {
547547
BoundVar(BoundVar),
548548

549549
/// Inference variable defined in the current inference context.
550-
InferenceVar(InferenceVar, TyKind),
550+
InferenceVar(InferenceVar, TyVariableKind),
551551
}
552552

553553
impl<I: Interner> Copy for TyData<I>
@@ -874,7 +874,7 @@ impl InferenceVar {
874874
}
875875

876876
/// Wraps the inference variable in a type.
877-
pub fn to_ty<I: Interner>(self, interner: &I, kind: TyKind) -> Ty<I> {
877+
pub fn to_ty<I: Interner>(self, interner: &I, kind: TyVariableKind) -> Ty<I> {
878878
TyData::<I>::InferenceVar(self, kind).intern(interner)
879879
}
880880

@@ -1169,11 +1169,11 @@ impl<I: Interner> ApplicationTy<I> {
11691169
/// ```
11701170
/// In this example, `i` is known to be some type of integer. We can infer that
11711171
/// it is `usize` because that is the only integer type that slices have an
1172-
/// `Index` impl for. `i` would have a `TyKind` of `Integer` to guide the
1172+
/// `Index` impl for. `i` would have a `TyVariableKind` of `Integer` to guide the
11731173
/// inference process.
11741174
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
11751175
#[allow(missing_docs)]
1176-
pub enum TyKind {
1176+
pub enum TyVariableKind {
11771177
General,
11781178
Integer,
11791179
Float,
@@ -1183,7 +1183,7 @@ pub enum TyKind {
11831183
#[derive(Clone, PartialEq, Eq, Hash)]
11841184
#[allow(missing_docs)]
11851185
pub enum VariableKind<I: Interner> {
1186-
Ty(TyKind),
1186+
Ty(TyVariableKind),
11871187
Lifetime,
11881188
Const(Ty<I>),
11891189
}
@@ -1925,7 +1925,7 @@ impl<T: HasInterner> Binders<T> {
19251925
// The new variable is at the front and everything afterwards is shifted up by 1
19261926
let new_var = TyData::BoundVar(BoundVar::new(DebruijnIndex::INNERMOST, 0)).intern(interner);
19271927
let value = op(new_var);
1928-
let binders = VariableKinds::from1(interner, VariableKind::Ty(TyKind::General));
1928+
let binders = VariableKinds::from1(interner, VariableKind::Ty(TyVariableKind::General));
19291929
Binders { binders, value }
19301930
}
19311931

0 commit comments

Comments
 (0)