@@ -70,16 +70,17 @@ impls, and struct definitions. Parsing is often the first "phase" of
70
70
transformation that a program goes through in order to become a format that
71
71
chalk can understand.
72
72
73
- ### Rust Intermediate Representation ([ rust_ir ] )
73
+ ### Rust Intermediate Representation ([ chalk_rust_ir ] )
74
74
75
75
After getting the AST we convert it to a more convenient intermediate
76
- representation called [ ` rust_ir ` ] [ rust_ir ] . This is sort of analogous to the
77
- [ HIR] in Rust. The process of converting to IR is called * lowering* .
76
+ representation called [ ` chalk_rust_ir ` ] [ chalk_rust_ir ] . This is sort of
77
+ analogous to the [ HIR] in Rust. The process of converting to IR is called
78
+ * lowering* .
78
79
79
- The [ ` rust_ir:: Program` ] [ rust_ir -program] struct contains some "rust things"
80
+ The [ ` chalk::program:: Program` ] [ chalk -program] struct contains some "rust things"
80
81
but indexed and accessible in a different way. For example, if you have a
81
82
type like ` Foo<Bar> ` , we would represent ` Foo ` as a string in the AST but in
82
- ` rust_ir ::Program` , we use numeric indices (` ItemId ` ).
83
+ ` chalk::program ::Program` , we use numeric indices (` ItemId ` ).
83
84
84
85
The [ IR source code] [ ir-code ] contains the complete definition.
85
86
@@ -120,14 +121,14 @@ forall<T> { (Vec<T>: Clone) :- (T: Clone) }
120
121
This rule dictates that ` Vec<T>: Clone ` is only satisfied if ` T: Clone ` is also
121
122
satisfied (i.e. "provable").
122
123
123
- Similar to [ ` rust_ir:: Program` ] [ rust_ir -program] which has "rust-like
124
+ Similar to [ ` chalk::program:: Program` ] [ chalk -program] which has "rust-like
124
125
things", chalk_ir defines [ ` ProgramEnvironment ` ] which which is "pure logic".
125
126
The main field in that struct is ` program_clauses ` , which contains the
126
127
[ ` ProgramClause ` ] s generated by the rules module.
127
128
128
- #### Rules
129
+ ### Rules ( [ chalk_rules ] )
129
130
130
- The ` rules ` module ([ source code] [ rules-src ] ) defines the logic rules we use
131
+ The ` chalk_rules ` crate ([ source code] [ chalk_rules ] ) defines the logic rules we use
131
132
for each item in the Rust IR. It works by iterating over every trait, impl,
132
133
etc. and emitting the rules that come from each one.
133
134
@@ -136,13 +137,13 @@ etc. and emitting the rules that come from each one.
136
137
#### Well-formedness checks
137
138
138
139
As part of lowering to logic, we also do some "well formedness" checks. See
139
- the [ ` rules ::wf` source code] [ rules-wf-src ] for where those are done.
140
+ the [ ` chalk_rules ::wf` source code] [ rules-wf-src ] for where those are done.
140
141
141
142
* See also: [ Well-formedness checking] [ wf-checking ] *
142
143
143
144
#### Coherence
144
145
145
- The function ` record_specialization_priorities ` in the ` coherence ` module
146
+ The method ` CoherenceSolver::specialization_priorities ` in the ` coherence ` module
146
147
([ source code] [ coherence-src ] ) checks "coherence", which means that it
147
148
ensures that two impls of the same trait for the same type cannot exist.
148
149
@@ -158,18 +159,19 @@ queries is called the *solver*.
158
159
159
160
Chalk's functionality is broken up into the following crates:
160
161
- [ ** chalk_engine** ] [ chalk_engine ] : Defines the core [ SLG solver] [ slg ] .
162
+ - [ ** chalk_rust_ir** ] [ chalk_rust_ir ] , containing the "HIR-like" form of the AST
161
163
- [ ** chalk_ir** ] [ chalk_ir ] : Defines chalk's internal representation of
162
164
types, lifetimes, and goals.
163
165
- [ ** chalk_solve** ] [ chalk_solve ] : Combines ` chalk_ir ` and ` chalk_engine ` ,
164
166
effectively.
165
167
- [ ` chalk_engine::context ` ] [ engine-context ] provides the necessary hooks.
166
168
- [ ** chalk_parse** ] [ chalk_parse ] : Defines the raw AST and a parser.
169
+ - [ ** chalk_rules** ] [ chalk_rules ] : which implements logic rules converting
170
+ ` chalk_rust_ir ` to ` chalk_ir `
171
+ - Defines the ` coherence ` module, which implements coherence rules
167
172
- [ ** chalk** ] [ doc-chalk ] : Brings everything together. Defines the following
168
173
modules:
169
- - [ ` rust_ir ` ] [ rust_ir ] , containing the "HIR-like" form of the AST
170
- - ` rust_ir::lowering ` , which converts AST to ` rust_ir `
171
- - ` rules ` , which implements logic rules converting ` rust_ir ` to ` chalk_ir `
172
- - ` coherence ` , which implements coherence rules
174
+ - ` chalk::lowering ` , which converts AST to ` chalk_rust_ir `
173
175
- Also includes [ chalki] [ chalki ] , chalk's REPL.
174
176
175
177
[ Browse source code on GitHub] ( https://github.com/rust-lang/chalk )
@@ -188,7 +190,7 @@ which is expected to lower to logic successfully, and a set of queries
188
190
tests support specifying only a prefix of the output.
189
191
190
192
** Lowering tests** check the stages that occur before we can issue queries
191
- to the solver: the [ lowering to rust_ir ] [ chalk-test-lowering ] , and the
193
+ to the solver: the [ lowering to chalk_rust_ir ] [ chalk-test-lowering ] , and the
192
194
[ well-formedness checks] [ chalk-test-wf ] that occur after that.
193
195
194
196
### Testing internals
@@ -229,29 +231,28 @@ Likewise, lowering tests use the [`lowering_success!` and
229
231
[ universal quantification ] : https://en.wikipedia.org/wiki/Universal_quantification
230
232
231
233
[ `ProgramClause` ] : https://rust-lang.github.io/chalk/doc/chalk_ir/enum.ProgramClause.html
232
- [ `ProgramEnvironment` ] : https ://rust-lang.github.io/chalk/doc/chalk_ir /struct.ProgramEnvironment.html
234
+ [ `ProgramEnvironment` ] : http ://rust-lang.github.io/chalk/doc/chalk/program_environment /struct.ProgramEnvironment.html
233
235
[ chalk_engine ] : https://rust-lang.github.io/chalk/doc/chalk_engine/index.html
234
236
[ chalk_ir ] : https://rust-lang.github.io/chalk/doc/chalk_ir/index.html
235
237
[ chalk_parse ] : https://rust-lang.github.io/chalk/doc/chalk_parse/index.html
236
238
[ chalk_solve ] : https://rust-lang.github.io/chalk/doc/chalk_solve/index.html
239
+ [ chalk_rules ] : https://rust-lang.github.io/chalk/doc/chalk_rules/index.html
240
+ [ chalk_rust_ir ] : https://rust-lang.github.io/chalk/doc/chalk_rust_ir/index.html
237
241
[ doc-chalk ] : https://rust-lang.github.io/chalk/doc/chalk/index.html
238
242
[ engine-context ] : https://rust-lang.github.io/chalk/doc/chalk_engine/context/index.html
239
- [ rust_ir-program ] : https://rust-lang.github.io/chalk/doc/chalk/rust_ir/struct.Program.html
240
- [ rust_ir ] : https://rust-lang.github.io/chalk/doc/chalk/rust_ir/index.html
243
+ [ chalk-program ] : http://rust-lang.github.io/chalk/doc/chalk/program/struct.Program.html
241
244
242
- [ binders-struct ] : https ://github.com/ rust-lang/chalk/blob/94a1941a021842a5fcb35cd043145c8faae59f08/src/ir.rs#L661
243
- [ chalk-ast ] : https ://github.com/ rust-lang/chalk/blob/master/chalk-parse/src/ ast.rs
245
+ [ binders-struct ] : http ://rust-lang.github.io /chalk/doc/chalk_ir/struct.Binders.html
246
+ [ chalk-ast ] : http ://rust-lang.github.io /chalk/doc/chalk_parse/ ast/index.html
244
247
[ chalk-test-example ] : https://github.com/rust-lang/chalk/blob/4bce000801de31bf45c02f742a5fce335c9f035f/src/test.rs#L115
245
248
[ chalk-test-lowering-example ] : https://github.com/rust-lang/chalk/blob/4bce000801de31bf45c02f742a5fce335c9f035f/src/rust_ir/lowering/test.rs#L8-L31
246
249
[ chalk-test-lowering ] : https://github.com/rust-lang/chalk/blob/4bce000801de31bf45c02f742a5fce335c9f035f/src/rust_ir/lowering/test.rs
247
250
[ chalk-test-wf ] : https://github.com/rust-lang/chalk/blob/4bce000801de31bf45c02f742a5fce335c9f035f/src/rules/wf/test.rs#L1
248
251
[ chalki ] : https://rust-lang.github.io/chalk/doc/chalki/index.html
249
252
[ clause ] : https://github.com/rust-lang/chalk/blob/master/GLOSSARY.md#clause
250
- [ coherence-src ] : https://github.com/rust-lang/chalk/blob/master/src/coherence.rs
251
- [ ir-code ] : https://github.com/rust-lang/chalk/blob/master/src/rust_ir.rs
252
- [ rules-environment ] : https://github.com/rust-lang/chalk/blob/94a1941a021842a5fcb35cd043145c8faae59f08/src/rules.rs#L9
253
- [ rules-src ] : https://github.com/rust-lang/chalk/blob/4bce000801de31bf45c02f742a5fce335c9f035f/src/rules.rs
254
- [ rules-wf-src ] : https://github.com/rust-lang/chalk/blob/4bce000801de31bf45c02f742a5fce335c9f035f/src/rules/wf.rs
253
+ [ coherence-src ] : http://rust-lang.github.io/chalk/doc/chalk_rules/coherence/index.html
254
+ [ ir-code ] : http://rust-lang.github.io/chalk/doc/chalk_rust_ir/
255
+ [ rules-wf-src ] : http://rust-lang.github.io/chalk/doc/chalk_rules/wf/index.html
255
256
[ solve_goal ] : https://github.com/rust-lang/chalk/blob/4bce000801de31bf45c02f742a5fce335c9f035f/src/test.rs#L85
256
257
[ test-lowering-macros ] : https://github.com/rust-lang/chalk/blob/4bce000801de31bf45c02f742a5fce335c9f035f/src/test_util.rs#L21-L54
257
258
[ test-macro ] : https://github.com/rust-lang/chalk/blob/4bce000801de31bf45c02f742a5fce335c9f035f/src/test.rs#L33
0 commit comments