Skip to content

Commit edc94c0

Browse files
Edit the Mir page to fix infelicities. (#984)
* Edit the Mir page to fix infelicities. - Remove dead reference to Mir. reflow sentence to talk about `Body::local_decls` - Fix broken links to render properly. - Add links for `Terminator`, `RETURN_PLACE`, `ProjectionElem`. * Update src/mir/index.md Co-authored-by: Léo Lanteri Thauvin <[email protected]> * Edit the Mir page to fix infelicities. - Remove dead reference to Mir. reflow sentence to talk about `Body::local_decls` - Fix broken links to render properly. - Add links for `Terminator`, `RETURN_PLACE`, `ProjectionElem`. Co-authored-by: Léo Lanteri Thauvin <[email protected]>
1 parent 02068c0 commit edc94c0

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

Diff for: src/mir/index.md

+17-12
Original file line numberDiff line numberDiff line change
@@ -216,31 +216,31 @@ The MIR data types are defined in the [`compiler/rustc_middle/src/mir/`][mir]
216216
module. Each of the key concepts mentioned in the previous section
217217
maps in a fairly straightforward way to a Rust type.
218218

219-
The main MIR data type is `Mir`. It contains the data for a single
219+
The main MIR data type is [`Body`]. It contains the data for a single
220220
function (along with sub-instances of Mir for "promoted constants",
221221
but [you can read about those below](#promoted)).
222222

223223
- **Basic blocks**: The basic blocks are stored in the field
224-
[`Body::basic_blocks`][basicblocks]; this is a vector
224+
[`Body::basic_blocks`][basicblocks]; this is a vector
225225
of [`BasicBlockData`] structures. Nobody ever references a
226226
basic block directly: instead, we pass around [`BasicBlock`]
227227
values, which are [newtype'd] indices into this vector.
228228
- **Statements** are represented by the type [`Statement`].
229-
- **Terminators** are represented by the `Terminator`.
229+
- **Terminators** are represented by the [`Terminator`].
230230
- **Locals** are represented by a [newtype'd] index type [`Local`].
231-
The data for a local variable is found in the `Mir` (the `local_decls`
232-
vector). There is also a special constant `RETURN_PLACE` identifying
233-
the special "local" representing the return value.
234-
- **Places** are identified by the enum [`Place`]. There are a few
231+
The data for a local variable is found in the
232+
[`Body::local_decls`][localdecls] vector). There is also a special constant
233+
[`RETURN_PLACE`] identifying the special "local" representing the return value.
234+
- **Places** are identified by the enum [`Place`]. There are a few
235235
variants:
236236
- Local variables like `_1`
237237
- Static variables `FOO`
238238
- **Projections**, which are fields or other things that "project
239-
out" from a base place. These are represented by the type
240-
[`Projection`]. So e.g. the place `_1.f` is a projection,
241-
with `f` being the "projection element and `_1` being the base
239+
out" from a base place. These are represented by the type
240+
[`ProjectionElem`]. So e.g. the place `_1.f` is a projection,
241+
with `f` being the "projection element" and `_1` being the base
242242
path. `*_1` is also a projection, with the `*` being represented
243-
by the `ProjectionElem::Deref` element.
243+
by the [`ProjectionElem::Deref`] element.
244244
- **Rvalues** are represented by the enum [`Rvalue`].
245245
- **Operands** are represented by the enum [`Operand`].
246246

@@ -257,13 +257,18 @@ but [you can read about those below](#promoted)).
257257

258258
[mir]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/index.html
259259
[mirmanip]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/index.html
260+
[`Body`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/struct.Body.html
260261
[newtype'd]: ../appendix/glossary.html#newtype
261-
[basicblocks](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/struct.Body.html#structfield.basic_blocks)
262+
[basicblocks]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/struct.Body.html#structfield.basic_blocks
262263
[`BasicBlock`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/struct.BasicBlock.html
263264
[`BasicBlockData`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/struct.BasicBlockData.html
264265
[`Statement`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/struct.Statement.html
265266
[`Terminator`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/terminator/struct.Terminator.html
266267
[`Local`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/struct.Local.html
268+
[localdecls]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/struct.Body.html#structfield.local_decls
269+
[`RETURN_PLACE`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/constant.RETURN_PLACE.html
267270
[`Place`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/struct.Place.html
271+
[`ProjectionElem`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/enum.ProjectionElem.html
272+
[`ProjectionElem::Deref`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/enum.ProjectionElem.html#variant.Deref
268273
[`Rvalue`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/enum.Rvalue.html
269274
[`Operand`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/enum.Operand.html

0 commit comments

Comments
 (0)