Skip to content

Commit e4b9f46

Browse files
committed
TyData -> TyKind
1 parent 95c5ed2 commit e4b9f46

35 files changed

+312
-312
lines changed

book/src/types/role_of_interner.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,24 @@ used to intern all the types, as rustc does, or it could be used to
2222
The purpose of the [`Interner`] trait is to give control over how
2323
types and other bits of chalk-ir are represented in memory. This is
2424
done via an "indirection" strategy. We'll explain that strategy here
25-
in terms of [`Ty`] and [`TyData`], the two types used to represent
25+
in terms of [`Ty`] and [`TyKind`], the two types used to represent
2626
Rust types, but the same pattern is repeated for many other things.
2727

2828
[`Interner`]: http://rust-lang.github.io/chalk/chalk_ir/interner/trait.Interner.html
2929
[`Ty`]: http://rust-lang.github.io/chalk/chalk_ir/struct.Ty.html
30-
[`TyData`]: http://rust-lang.github.io/chalk/chalk_ir/enum.TyData.html
30+
[`TyKind`]: http://rust-lang.github.io/chalk/chalk_ir/enum.TyKind.html
3131

32-
Types are represented by a [`Ty<I>`] type and the [`TyData<I>`] enum.
32+
Types are represented by a [`Ty<I>`] type and the [`TyKind<I>`] enum.
3333
There is no *direct* connection between them. The link is rather made
3434
by the [`Interner`] trait, via the [`InternedTy`] associated type:
3535

3636
[`Ty<I>`]: http://rust-lang.github.io/chalk/chalk_ir/struct.Ty.html
37-
[`TyData<I>`]: http://rust-lang.github.io/chalk/chalk_ir/enum.TyData.html
37+
[`TyKind<I>`]: http://rust-lang.github.io/chalk/chalk_ir/enum.TyKind.html
3838
[`InternedTy`]: http://rust-lang.github.io/chalk/chalk_ir/interner/trait.Interner.html#associatedtype.InternedType
3939

4040
```rust,ignore
4141
struct Ty<I: Interner>(I::InternedTy);
42-
enum TyData<I: Interner> { .. }
42+
enum TyKind<I: Interner> { .. }
4343
```
4444

4545
The way this works is that the [`Interner`] trait has an associated
@@ -52,17 +52,17 @@ type [`InternedTy`] and two related methods, [`intern_ty`] and [`ty_data`]:
5252
trait Interner {
5353
type InternedTy;
5454
55-
fn intern_ty(&self, data: &TyData<Self>) -> Self::InternedTy;
56-
fn ty_data(data: &Self::InternedTy) -> &TyData<Self>;
55+
fn intern_ty(&self, data: &TyKind<Self>) -> Self::InternedTy;
56+
fn ty_data(data: &Self::InternedTy) -> &TyKind<Self>;
5757
}
5858
```
5959

6060
However, as a user you are not meant to use these directly. Rather,
61-
they are encapsulated in methods on the [`Ty`] and [`TyData`] types:
61+
they are encapsulated in methods on the [`Ty`] and [`TyKind`] types:
6262

6363
```rust,ignore
6464
impl<I: Interner> Ty<I> {
65-
fn data(&self) -> &TyData<I> {
65+
fn data(&self) -> &TyKind<I> {
6666
I::lookup_ty(self)
6767
}
6868
}
@@ -71,7 +71,7 @@ impl<I: Interner> Ty<I> {
7171
and
7272

7373
```rust,ignore
74-
impl<I: Interner> TyData<I> {
74+
impl<I: Interner> TyKind<I> {
7575
fn intern(&self, i: &I) -> Ty<I> {
7676
Ty(i.intern_ty(self))
7777
}

book/src/types/rust_types.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# Rust types
22

3-
Rust types are represented by the [`Ty`] and [`TyData`] types.
3+
Rust types are represented by the [`Ty`] and [`TyKind`] types.
44
You use [`Ty`] to represent "some Rust type". But to actually inspect
55
what sort of type you have, you invoke the [`data`] method, which
6-
returns a [`TyData`]. As described earlier, the actual in-memory
6+
returns a [`TyKind`]. As described earlier, the actual in-memory
77
representation of types is controlled by the [`Interner`] trait.
88

99
[`Interner`]: http://rust-lang.github.io/chalk/chalk_ir/interner/trait.Interner.html
1010
[`Ty`]: http://rust-lang.github.io/chalk/chalk_ir/struct.Ty.html
11-
[`TyData`]: http://rust-lang.github.io/chalk/chalk_ir/enum.TyData.html
11+
[`TyKind`]: http://rust-lang.github.io/chalk/chalk_ir/enum.TyKind.html
1212
[`data`]: http://rust-lang.github.io/chalk/chalk_ir/struct.Ty.html#method.data
1313

14-
## The `TyData` variants and how they map to Rust syntax
14+
## The `TyKind` variants and how they map to Rust syntax
1515

1616
This section covers the variants we use to categorize types. We have
1717
endeavored to create a breakdown that simplifies the Rust "surface
@@ -31,7 +31,7 @@ differences in how they are handled.
3131

3232
## Justification for each variant
3333

34-
Each variant of `TyData` generally wraps a single struct, which
34+
Each variant of `TyKind` generally wraps a single struct, which
3535
represents a type known to be of that particular variant. This section
3636
goes through the variants in a bit more detail, and in particular
3737
describes why each variant exists.
@@ -169,7 +169,7 @@ 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
171171
implement the `Interner` trait and would map from the [`TyVariableKind`]
172-
enum to chalk's `TyData` on the fly, when `data()` is invoked.
172+
enum to chalk's `TyKind` on the fly, when `data()` is invoked.
173173

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

chalk-engine/src/slg.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ impl<I: Interner> MayInvalidate<'_, I> {
372372
fn aggregate_tys(&mut self, new: &Ty<I>, current: &Ty<I>) -> bool {
373373
let interner = self.interner;
374374
match (new.data(interner), current.data(interner)) {
375-
(_, TyData::BoundVar(_)) => {
375+
(_, TyKind::BoundVar(_)) => {
376376
// If the aggregate solution already has an inference
377377
// variable here, then no matter what type we produce,
378378
// the aggregate cannot get 'more generalized' than it
@@ -384,7 +384,7 @@ impl<I: Interner> MayInvalidate<'_, I> {
384384
false
385385
}
386386

387-
(TyData::BoundVar(_), _) => {
387+
(TyKind::BoundVar(_), _) => {
388388
// If we see a type variable in the potential future
389389
// solution, we have to be conservative. We don't know
390390
// what type variable will wind up being! Remember
@@ -398,37 +398,37 @@ impl<I: Interner> MayInvalidate<'_, I> {
398398
true
399399
}
400400

401-
(TyData::InferenceVar(_, _), _) | (_, TyData::InferenceVar(_, _)) => {
401+
(TyKind::InferenceVar(_, _), _) | (_, TyKind::InferenceVar(_, _)) => {
402402
panic!(
403403
"unexpected free inference variable in may-invalidate: {:?} vs {:?}",
404404
new, current,
405405
);
406406
}
407407

408-
(TyData::Apply(apply1), TyData::Apply(apply2)) => {
408+
(TyKind::Apply(apply1), TyKind::Apply(apply2)) => {
409409
self.aggregate_application_tys(apply1, apply2)
410410
}
411411

412-
(TyData::Placeholder(p1), TyData::Placeholder(p2)) => {
412+
(TyKind::Placeholder(p1), TyKind::Placeholder(p2)) => {
413413
self.aggregate_placeholders(p1, p2)
414414
}
415415

416416
(
417-
TyData::Alias(AliasTy::Projection(proj1)),
418-
TyData::Alias(AliasTy::Projection(proj2)),
417+
TyKind::Alias(AliasTy::Projection(proj1)),
418+
TyKind::Alias(AliasTy::Projection(proj2)),
419419
) => self.aggregate_projection_tys(proj1, proj2),
420420

421421
(
422-
TyData::Alias(AliasTy::Opaque(opaque_ty1)),
423-
TyData::Alias(AliasTy::Opaque(opaque_ty2)),
422+
TyKind::Alias(AliasTy::Opaque(opaque_ty1)),
423+
TyKind::Alias(AliasTy::Opaque(opaque_ty2)),
424424
) => self.aggregate_opaque_ty_tys(opaque_ty1, opaque_ty2),
425425

426426
// For everything else, be conservative here and just say we may invalidate.
427-
(TyData::Function(_), _)
428-
| (TyData::Dyn(_), _)
429-
| (TyData::Apply(_), _)
430-
| (TyData::Placeholder(_), _)
431-
| (TyData::Alias(_), _) => true,
427+
(TyKind::Function(_), _)
428+
| (TyKind::Dyn(_), _)
429+
| (TyKind::Apply(_), _)
430+
| (TyKind::Placeholder(_), _)
431+
| (TyKind::Alias(_), _) => true,
432432
}
433433
}
434434

chalk-engine/src/slg/aggregate.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -237,42 +237,42 @@ impl<I: Interner> AntiUnifier<'_, '_, I> {
237237
// overgeneralize. So for example if we have two
238238
// solutions that are both `(X, X)`, we just produce `(Y,
239239
// Z)` in all cases.
240-
(TyData::InferenceVar(_, _), TyData::InferenceVar(_, _)) => self.new_ty_variable(),
240+
(TyKind::InferenceVar(_, _), TyKind::InferenceVar(_, _)) => self.new_ty_variable(),
241241

242242
// Ugh. Aggregating two types like `for<'a> fn(&'a u32,
243243
// &'a u32)` and `for<'a, 'b> fn(&'a u32, &'b u32)` seems
244244
// kinda hard. Don't try to be smart for now, just plop a
245245
// variable in there and be done with it.
246-
(TyData::BoundVar(_), TyData::BoundVar(_))
247-
| (TyData::Function(_), TyData::Function(_))
248-
| (TyData::Dyn(_), TyData::Dyn(_)) => self.new_ty_variable(),
246+
(TyKind::BoundVar(_), TyKind::BoundVar(_))
247+
| (TyKind::Function(_), TyKind::Function(_))
248+
| (TyKind::Dyn(_), TyKind::Dyn(_)) => self.new_ty_variable(),
249249

250-
(TyData::Apply(apply1), TyData::Apply(apply2)) => {
250+
(TyKind::Apply(apply1), TyKind::Apply(apply2)) => {
251251
self.aggregate_application_tys(apply1, apply2)
252252
}
253253

254254
(
255-
TyData::Alias(AliasTy::Projection(proj1)),
256-
TyData::Alias(AliasTy::Projection(proj2)),
255+
TyKind::Alias(AliasTy::Projection(proj1)),
256+
TyKind::Alias(AliasTy::Projection(proj2)),
257257
) => self.aggregate_projection_tys(proj1, proj2),
258258

259259
(
260-
TyData::Alias(AliasTy::Opaque(opaque_ty1)),
261-
TyData::Alias(AliasTy::Opaque(opaque_ty2)),
260+
TyKind::Alias(AliasTy::Opaque(opaque_ty1)),
261+
TyKind::Alias(AliasTy::Opaque(opaque_ty2)),
262262
) => self.aggregate_opaque_ty_tys(opaque_ty1, opaque_ty2),
263263

264-
(TyData::Placeholder(placeholder1), TyData::Placeholder(placeholder2)) => {
264+
(TyKind::Placeholder(placeholder1), TyKind::Placeholder(placeholder2)) => {
265265
self.aggregate_placeholder_tys(placeholder1, placeholder2)
266266
}
267267

268268
// Mismatched base kinds.
269-
(TyData::InferenceVar(_, _), _)
270-
| (TyData::BoundVar(_), _)
271-
| (TyData::Dyn(_), _)
272-
| (TyData::Function(_), _)
273-
| (TyData::Apply(_), _)
274-
| (TyData::Alias(_), _)
275-
| (TyData::Placeholder(_), _) => self.new_ty_variable(),
269+
(TyKind::InferenceVar(_, _), _)
270+
| (TyKind::BoundVar(_), _)
271+
| (TyKind::Dyn(_), _)
272+
| (TyKind::Function(_), _)
273+
| (TyKind::Apply(_), _)
274+
| (TyKind::Alias(_), _)
275+
| (TyKind::Placeholder(_), _) => self.new_ty_variable(),
276276
}
277277
}
278278

@@ -293,7 +293,7 @@ impl<I: Interner> AntiUnifier<'_, '_, I> {
293293

294294
self.aggregate_name_and_substs(name1, substitution1, name2, substitution2)
295295
.map(|(&name, substitution)| {
296-
TyData::Apply(ApplicationTy { name, substitution }).intern(interner)
296+
TyKind::Apply(ApplicationTy { name, substitution }).intern(interner)
297297
})
298298
.unwrap_or_else(|| self.new_ty_variable())
299299
}
@@ -307,7 +307,7 @@ impl<I: Interner> AntiUnifier<'_, '_, I> {
307307
if index1 != index2 {
308308
self.new_ty_variable()
309309
} else {
310-
TyData::Placeholder(*index1).intern(interner)
310+
TyKind::Placeholder(*index1).intern(interner)
311311
}
312312
}
313313

@@ -328,7 +328,7 @@ impl<I: Interner> AntiUnifier<'_, '_, I> {
328328

329329
self.aggregate_name_and_substs(name1, substitution1, name2, substitution2)
330330
.map(|(&associated_ty_id, substitution)| {
331-
TyData::Alias(AliasTy::Projection(ProjectionTy {
331+
TyKind::Alias(AliasTy::Projection(ProjectionTy {
332332
associated_ty_id,
333333
substitution,
334334
}))
@@ -353,7 +353,7 @@ impl<I: Interner> AntiUnifier<'_, '_, I> {
353353

354354
self.aggregate_name_and_substs(name1, substitution1, name2, substitution2)
355355
.map(|(&opaque_ty_id, substitution)| {
356-
TyData::Alias(AliasTy::Opaque(OpaqueTy {
356+
TyKind::Alias(AliasTy::Opaque(OpaqueTy {
357357
opaque_ty_id,
358358
substitution,
359359
}))

chalk-engine/src/slg/resolvent.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ impl<'i, I: Interner> Zipper<'i, I> for AnswerSubstitutor<'i, I> {
373373
// "inputs" to the subgoal table. We need to extract the
374374
// resulting answer that the subgoal found and unify it with
375375
// the value from our "pending subgoal".
376-
if let TyData::BoundVar(answer_depth) = answer.data(interner) {
376+
if let TyKind::BoundVar(answer_depth) = answer.data(interner) {
377377
if self.unify_free_answer_var(
378378
interner,
379379
*answer_depth,
@@ -386,38 +386,38 @@ impl<'i, I: Interner> Zipper<'i, I> for AnswerSubstitutor<'i, I> {
386386
// Otherwise, the answer and the selected subgoal ought to be a perfect match for
387387
// one another.
388388
match (answer.data(interner), pending.data(interner)) {
389-
(TyData::BoundVar(answer_depth), TyData::BoundVar(pending_depth)) => {
389+
(TyKind::BoundVar(answer_depth), TyKind::BoundVar(pending_depth)) => {
390390
self.assert_matching_vars(*answer_depth, *pending_depth)
391391
}
392392

393-
(TyData::Apply(answer), TyData::Apply(pending)) => Zip::zip_with(self, answer, pending),
393+
(TyKind::Apply(answer), TyKind::Apply(pending)) => Zip::zip_with(self, answer, pending),
394394

395-
(TyData::Dyn(answer), TyData::Dyn(pending)) => Zip::zip_with(self, answer, pending),
395+
(TyKind::Dyn(answer), TyKind::Dyn(pending)) => Zip::zip_with(self, answer, pending),
396396

397-
(TyData::Alias(answer), TyData::Alias(pending)) => Zip::zip_with(self, answer, pending),
397+
(TyKind::Alias(answer), TyKind::Alias(pending)) => Zip::zip_with(self, answer, pending),
398398

399-
(TyData::Placeholder(answer), TyData::Placeholder(pending)) => {
399+
(TyKind::Placeholder(answer), TyKind::Placeholder(pending)) => {
400400
Zip::zip_with(self, answer, pending)
401401
}
402402

403-
(TyData::Function(answer), TyData::Function(pending)) => {
403+
(TyKind::Function(answer), TyKind::Function(pending)) => {
404404
self.outer_binder.shift_in();
405405
Zip::zip_with(self, &answer.substitution, &pending.substitution)?;
406406
self.outer_binder.shift_out();
407407
Ok(())
408408
}
409409

410-
(TyData::InferenceVar(_, _), _) | (_, TyData::InferenceVar(_, _)) => panic!(
410+
(TyKind::InferenceVar(_, _), _) | (_, TyKind::InferenceVar(_, _)) => panic!(
411411
"unexpected inference var in answer `{:?}` or pending goal `{:?}`",
412412
answer, pending,
413413
),
414414

415-
(TyData::BoundVar(_), _)
416-
| (TyData::Apply(_), _)
417-
| (TyData::Dyn(_), _)
418-
| (TyData::Alias(_), _)
419-
| (TyData::Placeholder(_), _)
420-
| (TyData::Function(_), _) => panic!(
415+
(TyKind::BoundVar(_), _)
416+
| (TyKind::Apply(_), _)
417+
| (TyKind::Dyn(_), _)
418+
| (TyKind::Alias(_), _)
419+
| (TyKind::Placeholder(_), _)
420+
| (TyKind::Function(_), _) => panic!(
421421
"structural mismatch between answer `{:?}` and pending goal `{:?}`",
422422
answer, pending,
423423
),

chalk-integration/src/interner.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use chalk_ir::{
88
};
99
use chalk_ir::{
1010
GenericArg, GenericArgData, Goal, GoalData, LifetimeData, ProgramClause, ProgramClauseData,
11-
QuantifiedWhereClause, TyData,
11+
QuantifiedWhereClause, TyKind,
1212
};
1313
use std::fmt;
1414
use std::fmt::Debug;
@@ -40,7 +40,7 @@ pub enum ChalkFnAbi {
4040
pub struct ChalkIr;
4141

4242
impl Interner for ChalkIr {
43-
type InternedType = Arc<TyData<ChalkIr>>;
43+
type InternedType = Arc<TyKind<ChalkIr>>;
4444
type InternedLifetime = LifetimeData<ChalkIr>;
4545
type InternedConst = Arc<ConstData<ChalkIr>>;
4646
type InternedConcreteConst = u32;
@@ -212,11 +212,11 @@ impl Interner for ChalkIr {
212212
tls::with_current_program(|prog| Some(prog?.debug_quantified_where_clauses(clauses, fmt)))
213213
}
214214

215-
fn intern_ty(&self, ty: TyData<ChalkIr>) -> Arc<TyData<ChalkIr>> {
215+
fn intern_ty(&self, ty: TyKind<ChalkIr>) -> Arc<TyKind<ChalkIr>> {
216216
Arc::new(ty)
217217
}
218218

219-
fn ty_data<'a>(&self, ty: &'a Arc<TyData<ChalkIr>>) -> &'a TyData<Self> {
219+
fn ty_data<'a>(&self, ty: &'a Arc<TyKind<ChalkIr>>) -> &'a TyKind<Self> {
220220
ty
221221
}
222222

@@ -236,7 +236,7 @@ impl Interner for ChalkIr {
236236
constant
237237
}
238238

239-
fn const_eq(&self, _ty: &Arc<TyData<ChalkIr>>, c1: &u32, c2: &u32) -> bool {
239+
fn const_eq(&self, _ty: &Arc<TyKind<ChalkIr>>, c1: &u32, c2: &u32) -> bool {
240240
c1 == c2
241241
}
242242

0 commit comments

Comments
 (0)