You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/chalk-overview.md
+11-10Lines changed: 11 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,8 +2,8 @@
2
2
3
3
> Chalk is under heavy development, so if any of these links are broken or if
4
4
> any of the information is inconsistent with the code or outdated, please
5
-
> [open an issue][rustc-issues] so we can fix it. If you are able to fix the issue yourself, we would
6
-
> love your contribution!
5
+
> [open an issue][rustc-issues] so we can fix it. If you are able to fix the
6
+
> issue yourself, we would love your contribution!
7
7
8
8
[Chalk][chalk] recasts Rust's trait system explicitly in terms of logic
9
9
programming by "lowering" Rust code into a kind of logic program we can then
@@ -42,7 +42,7 @@ Rust-like syntax.
42
42
The parser takes that syntax and produces an [Abstract Syntax Tree (AST)][ast].
43
43
You can find the [complete definition of the AST][chalk-ast] in the source code.
44
44
45
-
The syntax contains things from Rust that we know and love for example traits,
45
+
The syntax contains things from Rust that we know and love, for example: traits,
46
46
impls, and struct definitions. Parsing is often the first "phase" of
47
47
transformation that a program goes through in order to become a format that
48
48
chalk can understand.
@@ -67,14 +67,14 @@ essentially one of the following:
67
67
*`forall<T> { ... }` is represented in the code using the [`Binders<T>`
68
68
struct][binders-struct].
69
69
70
-
This is the phase where we encode the rules of the trait system into logic. For
71
-
example, if we have:
70
+
Lowering is the phase where we encode the rules of the trait system into logic.
71
+
For example, if we have the following Rust:
72
72
73
73
```rust,ignore
74
74
impl<T: Clone> Clone for Vec<T> {}
75
75
```
76
76
77
-
We generate:
77
+
We generate the following program clause:
78
78
79
79
```rust,ignore
80
80
forall<T> { (Vec<T>: Clone) :- (T: Clone) }
@@ -102,22 +102,23 @@ For example, if you have a type like `Foo<Bar>`, we would represent `Foo` as a
102
102
string in the AST but in `ir::Program`, we use numeric indices (`ItemId`).
103
103
104
104
In addition to `ir::Program` which has "rust-like things", there is also
105
-
`ir::ProgramEnvironment` which is "pure logic". The main field in that is
105
+
`ir::ProgramEnvironment` which is "pure logic". The main field in that struct is
106
106
`program_clauses` which contains the `ProgramClause`s that we generated
107
107
previously.
108
108
109
109
## Rules
110
110
111
111
The `rules` module works by iterating over every trait, impl, etc. and emitting
112
-
the rules that come from each one. The traits section of the rustc-guide (that
113
-
you are currently reading) contains the most up-to-date reference on that.
112
+
the rules that come from each one. See [Lowering Rules][lowering-rules] for the
113
+
most up-to-date reference on that.
114
114
115
115
The `ir::ProgramEnvironment` is created [in this module][rules-environment].
116
116
117
117
## Testing
118
118
119
119
TODO: Basically, [there is a macro](https://github.com/rust-lang-nursery/chalk/blob/94a1941a021842a5fcb35cd043145c8faae59f08/src/solve/test.rs#L112-L148)
120
-
that will take syntax and run it through the full pipeline described above.
120
+
that will take chalk's Rust-like syntax and run it through the full pipeline
0 commit comments