File tree 2 files changed +13
-2
lines changed
2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,16 @@ if it exhibits any of the behaviors in the following list. It is the
5
5
programmer's responsibility when writing ` unsafe ` code that it is not possible
6
6
to let ` safe ` code exhibit these behaviors.
7
7
8
+ <div class =" warning " >
9
+
10
+ *** Warning:*** The following list is not exhaustive. There is no formal model of
11
+ Rust's semantics for what is and is not allowed in unsafe code, so there may be
12
+ more behavior considered unsafe. The following list is just what we know for
13
+ sure is undefined behavior. Please read the [ Rustonomicon] before writing unsafe
14
+ code.
15
+
16
+ </div >
17
+
8
18
* Data races.
9
19
* Dereferencing a null or dangling raw pointer.
10
20
* Unaligned pointer reading and writing outside of [ ` read_unaligned ` ]
@@ -37,3 +47,4 @@ to let `safe` code exhibit these behaviors.
37
47
[ `UnsafeCell<U>` ] : https://doc.rust-lang.org/std/cell/struct.UnsafeCell.html
38
48
[ `read_unaligned` ] : https://doc.rust-lang.org/std/ptr/fn.read_unaligned.html
39
49
[ `write_unaligned` ] : https://doc.rust-lang.org/std/ptr/fn.write_unaligned.html
50
+ [ Rustonomicon ] : ../nomicon
Original file line number Diff line number Diff line change 1
1
# Unsafety
2
2
3
- Unsafe operations are those that potentially violate the memory-safety
3
+ Unsafe operations are those that can potentially violate the memory-safety
4
4
guarantees of Rust's static semantics.
5
5
6
6
The following language level features cannot be used in the safe subset of
11
11
- Reading a field of a [ ` union ` ] ( items/unions.html ) , or writing to a field of a
12
12
union that isn't [ ` Copy ` ] ( special-types-and-traits.html#copy ) .
13
13
- Calling an unsafe function (including an intrinsic or foreign function).
14
- - Implementing an unsafe trait.
14
+ - Implementing an unsafe trait.
You can’t perform that action at this time.
0 commit comments