Skip to content

Commit 559d1a5

Browse files
committed
Fix mdbook; remove FIXMEs
1 parent 8c55002 commit 559d1a5

File tree

4 files changed

+13
-22
lines changed

4 files changed

+13
-22
lines changed

reference/src/SUMMARY.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44

55
- [Data layout](./layout.md)
66
- [Structs and tuples](./layout/structs-and-tuples.md)
7-
- [Integers and Floating Points](./layout/integers-floatingpoint.md)
7+
- [Scalar types](./layout/scalar.md)
88
- [Enums](./layout/enums.md)
99
- [Unions](./layout/unions.md)
10+
- [Pointers](./layout/pointers.md)
11+
- [Function pointers](./layout/function-pointers.md)
1012
- [Arrays and Slices](./layout/arrays-and-slices.md)
1113
- [Packed SIMD vectors](./layout/packed-simd-vectors.md)
1214
- [Optimizations](./optimizations.md)

reference/src/layout/function-pointers.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ bool for_all(struct Cons const *self, bool (*func)(int, void *), void *thunk);
8181
```
8282
8383
```rust
84+
# use std::{
85+
# ffi::c_void,
86+
# os::raw::c_int,
87+
# };
88+
#
8489
pub struct Cons {
8590
data: c_int,
8691
next: Option<Box<Cons>>,
@@ -117,9 +122,6 @@ pub extern "C" fn for_all(
117122
}
118123
it = node.next.as_ref().map(|x| &**x);
119124
}
125+
true
120126
}
121127
```
122-
123-
### Unresolved Questions
124-
125-
- dunno

reference/src/layout/pointers.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ multi-trait objects `&(dyn T + U)` or references to other dynamically sized type
3636
other than that they are at least word-aligned, and have size at least one word.
3737

3838
The layout of `&dyn T` when `T` is a trait is the same as that of:
39-
```rust
39+
```rust,ignore
4040
#[repr(C)]
4141
struct DynObject {
4242
data: *u8,
@@ -45,7 +45,7 @@ struct DynObject {
4545
```
4646

4747
The layout of `&[T]` is the same as that of:
48-
```rust
48+
```rust,ignore
4949
#[repr(C)]
5050
struct Slice<T> {
5151
ptr: *T,

reference/src/layout/integers-floatingpoint.md renamed to reference/src/layout/scalar.md

+2-15
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
# Layout of Boolean, Floating Point, and Integral Types
1+
# Layout of scalar types
22

33
This chapter represents the consensus from issue [#9]. It documents the memory
4-
layout and considerations for `bool`, floating point types (`f{32, 64}`), and
5-
integral types (`{i,u}{8,16,32,64,128,size}`).
4+
layout and considerations for `bool`, `char`, floating point types (`f{32, 64}`), and integral types (`{i,u}{8,16,32,64,128,size}`).
65

76
These types are all scalar types, representing a single value, and have no
87
layout `#[repr()]` flags.
@@ -48,22 +47,10 @@ The layout of `usize` determines the following:
4847
- the maximum number of elements in an array (`[T; N: usize]`),
4948
- how much a pointer of a certain type can be offseted (limited by `usize::max_value()`).
5049

51-
> **FIXME**: Pointer `add` operates on `usize`, but pointer `offset` operates on
52-
> `isize`, so unless by "offseted" we mean something different from `ptr.offset`
53-
> above, `usize::max_value()` does not determine how much a pointer can be
54-
> "offseted". We should probably be more specific here and call out `ptr.add`
55-
> and `ptr.offset` explicitly.
56-
5750
The maximum size of any single value must fit within `usize` to [ensure that
5851
pointer diff is
5952
representable](https://github.com/rust-rfcs/unsafe-code-guidelines/pull/5#discussion_r212703192).
6053

61-
> **FIXME**: This does not make sense. We state that the layout of `usize`
62-
> determines the maximum size of an object, and then argue that this is to
63-
> ensure that pointer diff is representable, which won't be the case if the size
64-
> of an object is `usize::max_val()`. The link cited actually states that, right
65-
> now, the largest size of a Rust object is limited by `isize::max_value()`.
66-
6754
[pointer types]: ./pointers.md
6855

6956
## Fixed-width integer types

0 commit comments

Comments
 (0)