Skip to content

Commit 3c4ef7c

Browse files
committed
minor edits
1 parent 4034a8e commit 3c4ef7c

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

src/serialization.md

+12-13
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Serialization in Rustc
22

3-
Rust's compiler has to [serialize] and deserialize various data during
4-
compilation. Specifically:
3+
rustc has to [serialize] and deserialize various data during compilation.
4+
Specifically:
55

6-
- Certain crate metadata, consisting mainly of query outputs, are serialized
6+
- "Crate metadata", consisting mainly of query outputs, are serialized
77
from a binary format into `rlib` and `rmeta` files that are output when
88
compiling a library crate. These `rlib` and `rmeta` files are then
99
deserialized by the crates which depend on that library.
@@ -36,8 +36,8 @@ types, floating point types, `bool`, `char`, `str`, etc.
3636

3737
For types that are constructed from those types, `Encodable` and `Decodable`
3838
are usually implemented by [derives]. These generate implementations that
39-
forward deserialization to the `field`s of the `struct` or `enum`. For a
40-
`struct` those `impl`s look something like this:
39+
forward deserialization to the fields of the struct or enum. For a
40+
struct those impls look something like this:
4141

4242
```rust,ignore
4343
#![feature(rustc_private)]
@@ -73,14 +73,13 @@ impl<D: Decoder> Decodable<D> for MyStruct {
7373

7474
## Encoding and Decoding arena allocated types
7575

76-
Rust's compiler has a lot of [arena allocated types]. Deserializing these types
77-
isn't possible without access to the `arena` that they need to be allocated on.
78-
The [`TyDecoder`] and [`TyEncoder`] `trait`s are supertraits of [`Decoder`] and
79-
[`Encoder`] that allow access to a [`TyCtxt`].
76+
rustc has a lot of [arena allocated types].
77+
Deserializing these types isn't possible without access to the arena that they need to be allocated on.
78+
The [`TyDecoder`] and [`TyEncoder`] traits are supertraits of [`Decoder`] and [`Encoder`] that allow access to a [`TyCtxt`].
8079

81-
Types which contain `arena` allocated types can then bound the type parameter
82-
of their [`Encodable`] and [`Decodable`] implementations with these `trait`s. For
83-
example
80+
Types which contain `arena` allocated types can then bound the type parameter of their
81+
[`Encodable`] and [`Decodable`] implementations with these traits.
82+
For example
8483

8584
```rust,ignore
8685
impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for MyStruct<'tcx> {
@@ -149,7 +148,7 @@ and `Encodable`.
149148
`Ty` can be deeply recursive, if each `Ty` was encoded naively then crate
150149
metadata would be very large. To handle this, each `TyEncoder` has a cache of
151150
locations in its output where it has serialized types. If a type being encoded
152-
is in cache, then instead of serializing the type as usual, the byte offset
151+
is in the cache, then instead of serializing the type as usual, the byte offset
153152
within the file being written is encoded instead. A similar scheme is used for
154153
`ty::Predicate`.
155154

0 commit comments

Comments
 (0)