Skip to content

Commit f950edb

Browse files
committed
Elaborate some in the documentation and respond to some review comments
1 parent 06edf08 commit f950edb

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

library/std/src/io/error.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ enum ErrorData<C> {
8888
// requires an alignment >= 4 (note that `#[repr(align)]` will not reduce the
8989
// alignment required by the struct, only increase it).
9090
#[repr(align(4))]
91-
#[doc(hidden)]
9291
pub(crate) struct SimpleMessage {
9392
kind: ErrorKind,
9493
message: &'static str,

library/std/src/io/error/repr_bitpacked.rs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,29 @@
22
//! 64-bit pointers.
33
//!
44
//! (Note that `bitpacked` vs `unpacked` here has no relationship to
5-
//! `#[repr(packed)]`, it just refers to attempting to use any available
6-
//! bits in a more clever manner than `rustc`'s default layout algorithm would).
5+
//! `#[repr(packed)]`, it just refers to attempting to use any available bits in
6+
//! a more clever manner than `rustc`'s default layout algorithm would).
77
//!
8-
//! Conceptually, it stores the same information as the "unpacked" equivalent we
9-
//! use on other targets: `repr_unpacked::Repr` (see repr_unpacked.rs), however
10-
//! it packs it into a 64bit non-zero value.
8+
//! Conceptually, it stores the same data as the "unpacked" equivalent we use on
9+
//! other targets. Specifically, you can imagine it as an optimized following
10+
//! data (which is equivalent to what's stored by `repr_unpacked::Repr`, e.g.
11+
//! `super::ErrorData<Box<Custom>>`):
12+
//!
13+
//! ```ignore (exposition-only)
14+
//! enum ErrorData {
15+
//! Os(i32),
16+
//! Simple(ErrorKind),
17+
//! SimpleMessage(&'static SimpleMessage),
18+
//! Custom(Box<Custom>),
19+
//! }
20+
//! ```
21+
//!
22+
//! However, it packs this data into a 64bit non-zero value.
1123
//!
1224
//! This optimization not only allows `io::Error` to occupy a single pointer,
1325
//! but improves `io::Result` as well, especially for situations like
14-
//! `Result<()>` (which is now 64 bits) or `Result<u64>` (which i), which are
15-
//! quite common.
26+
//! `io::Result<()>` (which is now 64 bits) or `io::Result<u64>` (which is now
27+
//! 128 bits), which are quite common.
1628
//!
1729
//! # Layout
1830
//! Tagged values are 64 bits, with the 2 least significant bits used for the

0 commit comments

Comments
 (0)