Skip to content

Commit d2238c3

Browse files
committed
Move Crates section down
Nest existing content under Chalk Structure. I think it reads better this way.
1 parent b62fe76 commit d2238c3

File tree

1 file changed

+40
-33
lines changed

1 file changed

+40
-33
lines changed

src/traits/chalk-overview.md

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ expressive, which should behave better in corner cases, and be much easier to
1717
extend.
1818

1919
## Chalk Structure
20+
2021
Chalk has two main "products". The first of these is the
2122
[`chalk_engine`][doc-chalk-engine] crate, which defines the core [SLG
2223
solver][slg]. This is the part rustc uses.
@@ -52,37 +53,9 @@ You can see more examples of programs and queries in the [unit tests][chalk-test
5253

5354
Next we'll go through each stage required to produce the output above.
5455

55-
### Crates
56-
- [**chalk_engine**][doc-chalk-engine]: Defines the core [SLG solver][slg].
57-
- [**chalk_ir**][doc-chalk-ir]: Defines chalk's internal representation of
58-
types, lifetimes, and goals.
59-
- [**chalk_solve**][doc-chalk-solve]: Combines `chalk_ir` and `chalk_engine`,
60-
effectively.
61-
- [`chalk_engine::context`][engine-context] provides the necessary hooks.
62-
- [**chalk_parse**][doc-chalk-parse]: Defines the raw AST and a parser.
63-
- [**chalk**][doc-chalk]: Brings everything together. Defines the following
64-
modules:
65-
- [`rust_ir`][doc-chalk-rust-ir], containing the "HIR-like" form of the AST
66-
- `rust_ir::lowering`, which converts AST to `rust_ir`
67-
- `rules`, which implements logic rules
68-
converting `rust_ir` to `chalk_ir`
69-
- `coherence`, which implements coherence rules
70-
- Also includes [chalki][doc-chalki], chalk's REPL.
71-
72-
[Browse source on GitHub](https://github.com/rust-lang-nursery/chalk)
73-
74-
[engine-context]: https://rust-lang-nursery.github.io/chalk/doc/chalk_engine/context/index.html
75-
76-
[doc-chalk-engine]: https://rust-lang-nursery.github.io/chalk/doc/chalk_engine/index.html
77-
[doc-chalk-ir]: https://rust-lang-nursery.github.io/chalk/doc/chalk_ir/index.html
78-
[doc-chalk-solve]: https://rust-lang-nursery.github.io/chalk/doc/chalk_solve/index.html
79-
[doc-chalk-parse]: https://rust-lang-nursery.github.io/chalk/doc/chalk_parse/index.html
80-
[doc-chalk]: https://rust-lang-nursery.github.io/chalk/doc/chalk/index.html
81-
[doc-chalk-rust-ir]: https://rust-lang-nursery.github.io/chalk/doc/chalk/rules/index.html
82-
[doc-chalki]: https://rust-lang-nursery.github.io/chalk/doc/chalki/index.html
8356
[chalk-tests]: https://github.com/rust-lang-nursery/chalk/blob/4bce000801de31bf45c02f742a5fce335c9f035f/src/test.rs#L115
8457

85-
## Parsing
58+
### Parsing
8659

8760
Chalk is designed to be incorporated with the Rust compiler, so the syntax and
8861
concepts it deals with heavily borrow from Rust. It is convenient for the sake
@@ -98,7 +71,7 @@ impls, and struct definitions. Parsing is often the first "phase" of
9871
transformation that a program goes through in order to become a format that
9972
chalk can understand.
10073

101-
## Lowering
74+
### Lowering
10275

10376
After parsing, there is a "lowering" phase. This aims to convert traits/impls
10477
into "program clauses". A [`ProgramClause` (source code)][programclause] is
@@ -136,15 +109,15 @@ forall<T> { (Vec<T>: Clone) :- (T: Clone) }
136109
This rule dictates that `Vec<T>: Clone` is only satisfied if `T: Clone` is also
137110
satisfied (i.e. "provable").
138111

139-
### Well-formedness checks
112+
#### Well-formedness checks
140113

141114
As part of lowering from the AST to the internal IR, we also do some "well
142115
formedness" checks. See the [source code][well-formedness-checks] for where
143116
those are done. The call to `record_specialization_priorities` checks
144117
"coherence" which means that it ensures that two impls of the same trait for the
145118
same type cannot exist.
146119

147-
## Intermediate Representation (IR)
120+
### Intermediate Representation (IR)
148121

149122
The second intermediate representation in chalk is called, well, the "ir". :)
150123
The [IR source code][ir-code] contains the complete definition. The
@@ -159,14 +132,48 @@ In addition to `ir::Program` which has "rust-like things", there is also
159132
`program_clauses` which contains the `ProgramClause`s that we generated
160133
previously.
161134

162-
## Rules
135+
### Rules
163136

164137
The `rules` module works by iterating over every trait, impl, etc. and emitting
165138
the rules that come from each one. See [Lowering Rules][lowering-rules] for the
166139
most up-to-date reference on that.
167140

168141
The `ir::ProgramEnvironment` is created [in this module][rules-environment].
169142

143+
### Solver
144+
145+
See [The SLG Solver][slg].
146+
147+
## Crates
148+
149+
Chalk's functionality is broken up into the following crates:
150+
- [**chalk_engine**][doc-chalk-engine]: Defines the core [SLG solver][slg].
151+
- [**chalk_ir**][doc-chalk-ir]: Defines chalk's internal representation of
152+
types, lifetimes, and goals.
153+
- [**chalk_solve**][doc-chalk-solve]: Combines `chalk_ir` and `chalk_engine`,
154+
effectively.
155+
- [`chalk_engine::context`][engine-context] provides the necessary hooks.
156+
- [**chalk_parse**][doc-chalk-parse]: Defines the raw AST and a parser.
157+
- [**chalk**][doc-chalk]: Brings everything together. Defines the following
158+
modules:
159+
- [`rust_ir`][doc-chalk-rust-ir], containing the "HIR-like" form of the AST
160+
- `rust_ir::lowering`, which converts AST to `rust_ir`
161+
- `rules`, which implements logic rules converting `rust_ir` to `chalk_ir`
162+
- `coherence`, which implements coherence rules
163+
- Also includes [chalki][doc-chalki], chalk's REPL.
164+
165+
[Browse source on GitHub](https://github.com/rust-lang-nursery/chalk)
166+
167+
[engine-context]: https://rust-lang-nursery.github.io/chalk/doc/chalk_engine/context/index.html
168+
169+
[doc-chalk-engine]: https://rust-lang-nursery.github.io/chalk/doc/chalk_engine/index.html
170+
[doc-chalk-ir]: https://rust-lang-nursery.github.io/chalk/doc/chalk_ir/index.html
171+
[doc-chalk-solve]: https://rust-lang-nursery.github.io/chalk/doc/chalk_solve/index.html
172+
[doc-chalk-parse]: https://rust-lang-nursery.github.io/chalk/doc/chalk_parse/index.html
173+
[doc-chalk]: https://rust-lang-nursery.github.io/chalk/doc/chalk/index.html
174+
[doc-chalk-rust-ir]: https://rust-lang-nursery.github.io/chalk/doc/chalk/rules/index.html
175+
[doc-chalki]: https://rust-lang-nursery.github.io/chalk/doc/chalki/index.html
176+
170177
## Testing
171178

172179
TODO: Basically, [there is a macro](https://github.com/rust-lang-nursery/chalk/blob/94a1941a021842a5fcb35cd043145c8faae59f08/src/solve/test.rs#L112-L148)

0 commit comments

Comments
 (0)