Skip to content

Commit aa7bb2b

Browse files
committed
update chalk with new organization
1 parent 2ef961e commit aa7bb2b

File tree

3 files changed

+34
-33
lines changed

3 files changed

+34
-33
lines changed

src/traits/chalk-overview.md

+26-25
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,17 @@ impls, and struct definitions. Parsing is often the first "phase" of
7070
transformation that a program goes through in order to become a format that
7171
chalk can understand.
7272

73-
### Rust Intermediate Representation ([rust_ir])
73+
### Rust Intermediate Representation ([chalk_rust_ir])
7474

7575
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*.
7879

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"
8081
but indexed and accessible in a different way. For example, if you have a
8182
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`).
8384

8485
The [IR source code][ir-code] contains the complete definition.
8586

@@ -120,14 +121,14 @@ forall<T> { (Vec<T>: Clone) :- (T: Clone) }
120121
This rule dictates that `Vec<T>: Clone` is only satisfied if `T: Clone` is also
121122
satisfied (i.e. "provable").
122123

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
124125
things", chalk_ir defines [`ProgramEnvironment`] which which is "pure logic".
125126
The main field in that struct is `program_clauses`, which contains the
126127
[`ProgramClause`]s generated by the rules module.
127128

128-
#### Rules
129+
### Rules ([chalk_rules])
129130

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
131132
for each item in the Rust IR. It works by iterating over every trait, impl,
132133
etc. and emitting the rules that come from each one.
133134

@@ -136,13 +137,13 @@ etc. and emitting the rules that come from each one.
136137
#### Well-formedness checks
137138

138139
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.
140141

141142
*See also: [Well-formedness checking][wf-checking]*
142143

143144
#### Coherence
144145

145-
The function `record_specialization_priorities` in the `coherence` module
146+
The method `CoherenceSolver::specialization_priorities` in the `coherence` module
146147
([source code][coherence-src]) checks "coherence", which means that it
147148
ensures that two impls of the same trait for the same type cannot exist.
148149

@@ -158,18 +159,19 @@ queries is called the *solver*.
158159

159160
Chalk's functionality is broken up into the following crates:
160161
- [**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
161163
- [**chalk_ir**][chalk_ir]: Defines chalk's internal representation of
162164
types, lifetimes, and goals.
163165
- [**chalk_solve**][chalk_solve]: Combines `chalk_ir` and `chalk_engine`,
164166
effectively.
165167
- [`chalk_engine::context`][engine-context] provides the necessary hooks.
166168
- [**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
167172
- [**chalk**][doc-chalk]: Brings everything together. Defines the following
168173
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`
173175
- Also includes [chalki][chalki], chalk's REPL.
174176

175177
[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
188190
tests support specifying only a prefix of the output.
189191

190192
**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
192194
[well-formedness checks][chalk-test-wf] that occur after that.
193195

194196
### Testing internals
@@ -229,29 +231,28 @@ Likewise, lowering tests use the [`lowering_success!` and
229231
[universal quantification]: https://en.wikipedia.org/wiki/Universal_quantification
230232

231233
[`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
233235
[chalk_engine]: https://rust-lang.github.io/chalk/doc/chalk_engine/index.html
234236
[chalk_ir]: https://rust-lang.github.io/chalk/doc/chalk_ir/index.html
235237
[chalk_parse]: https://rust-lang.github.io/chalk/doc/chalk_parse/index.html
236238
[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
237241
[doc-chalk]: https://rust-lang.github.io/chalk/doc/chalk/index.html
238242
[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
241244

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
244247
[chalk-test-example]: https://github.com/rust-lang/chalk/blob/4bce000801de31bf45c02f742a5fce335c9f035f/src/test.rs#L115
245248
[chalk-test-lowering-example]: https://github.com/rust-lang/chalk/blob/4bce000801de31bf45c02f742a5fce335c9f035f/src/rust_ir/lowering/test.rs#L8-L31
246249
[chalk-test-lowering]: https://github.com/rust-lang/chalk/blob/4bce000801de31bf45c02f742a5fce335c9f035f/src/rust_ir/lowering/test.rs
247250
[chalk-test-wf]: https://github.com/rust-lang/chalk/blob/4bce000801de31bf45c02f742a5fce335c9f035f/src/rules/wf/test.rs#L1
248251
[chalki]: https://rust-lang.github.io/chalk/doc/chalki/index.html
249252
[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
255256
[solve_goal]: https://github.com/rust-lang/chalk/blob/4bce000801de31bf45c02f742a5fce335c9f035f/src/test.rs#L85
256257
[test-lowering-macros]: https://github.com/rust-lang/chalk/blob/4bce000801de31bf45c02f742a5fce335c9f035f/src/test_util.rs#L21-L54
257258
[test-macro]: https://github.com/rust-lang/chalk/blob/4bce000801de31bf45c02f742a5fce335c9f035f/src/test.rs#L33

src/traits/lowering-rules.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ comment like so:
2828
// Rule Foo-Bar-Baz
2929

3030
The reference implementation of these rules is to be found in
31-
[`chalk/src/rules.rs`][chalk_rules]. They are also ported in rustc in the
32-
[`librustc_traits`][librustc_traits] crate.
31+
[`chalk/chalk-rules/src/clauses.rs`][chalk_rules]. They are also ported in
32+
rustc in the [`librustc_traits`][librustc_traits] crate.
3333

34-
[chalk_rules]: https://github.com/rust-lang-nursery/chalk/blob/master/src/rules.rs
34+
[chalk_rules]: https://github.com/rust-lang/chalk/blob/master/chalk-rules/src/clauses.rs
3535
[librustc_traits]: https://github.com/rust-lang/rust/tree/master/src/librustc_traits
3636

3737
## Lowering where clauses

src/traits/wf.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ to prove it using the lowered rules we described in the
1111
[lowering rules](./lowering-rules.md) chapter. If we are able to prove it, we
1212
say that the construct is well-formed. If not, we report an error to the user.
1313

14-
Well-formedness checking happens in the [`src/rules/wf.rs`][wf] module in
15-
chalk. After you have read this chapter, you may find useful to see an
16-
extended set of examples in the [`src/rules/wf/test.rs`][wf_test] submodule.
14+
Well-formedness checking happens in the [`chalk/chalk-rules/src/wf.rs`][wf]
15+
module in chalk. After you have read this chapter, you may find useful to see
16+
an extended set of examples in the [`chalk/src/test/wf.rs`][wf_test] submodule.
1717

1818
The new-style WF checking has not been implemented in rustc yet.
1919

20-
[wf]: https://github.com/rust-lang-nursery/chalk/blob/master/src/rules/wf.rs
21-
[wf_test]: https://github.com/rust-lang-nursery/chalk/blob/master/src/rules/wf/test.rs
20+
[wf]: https://github.com/rust-lang/chalk/blob/master/chalk-rules/src/wf.rs
21+
[wf_test]: https://github.com/rust-lang/chalk/blob/master/src/test/wf.rs
2222

2323
We give here a complete reference of the generated goals for each Rust
2424
declaration.

0 commit comments

Comments
 (0)