Skip to content

Commit b41ef53

Browse files
RalfJungGankra
authored andcommitted
explain when metadata is invalid
1 parent c113664 commit b41ef53

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/what-unsafe-does.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Unlike C, Undefined Behavior is pretty limited in scope in Rust. All the core
1717
language cares about is preventing the following things:
1818

1919
* Dereferencing (using the `*` operator on) null, dangling, or unaligned
20-
pointers
20+
pointers, or fat pointers with invalid metadata (see below)
2121
* Reading [uninitialized memory][]
2222
* Breaking the [pointer aliasing rules][]
2323
* Producing invalid primitive values (either alone or as a field of a compound
@@ -30,6 +30,10 @@ language cares about is preventing the following things:
3030
* dangling/null/unaligned references, references that do themselves point to
3131
invalid values, or fat references (to a dynamically sized type) with
3232
invalid metadata
33+
* slice metadata is invalid if the slice has a total size larger than
34+
`isize::MAX` bytes in memory
35+
* `dyn Trait` metadata is invalid if it is not a pointer to a vtable for
36+
`Trait` that matches the actual dynamic trait the reference points to
3337
* a non-utf8 `str`
3438
* an uninitialized integer (`i*`/`u*`) or floating point value (`f*`)
3539
* an invalid library type with custom invalid values, such as a `NonNull` or

0 commit comments

Comments
 (0)