@@ -33,9 +33,21 @@ in the sections marked `unsafe`.
3333
3434# What does ‘safe’ mean?
3535
36- Safe, in the context of Rust, means “doesn’t do anything unsafe.” Easy!
36+ Safe, in the context of Rust, means ‘doesn’t do anything unsafe’. It’s also
37+ important to know that there are certain behaviors that are probably not
38+ desirable in your code, but are expressly _ not_ unsafe:
3739
38- Okay, let’s try again: what is not safe to do? Here’s a list:
40+ * Deadlocks
41+ * Leaks of memory or other resources
42+ * Exiting without calling destructors
43+ * Integer overflow
44+
45+ Rust cannot prevent all kinds of software problems. Buggy code can and will be
46+ written in Rust. These things aren’t great, but they don’t qualify as ` unsafe `
47+ specifically.
48+
49+ In addition, the following are all undefined behaviors in Rust, and must be
50+ avoided, even when writing ` unsafe ` code:
3951
4052* Data races
4153* Dereferencing a null/dangling raw pointer
@@ -64,18 +76,6 @@ Okay, let’s try again: what is not safe to do? Here’s a list:
6476[ undef ] : http://llvm.org/docs/LangRef.html#undefined-values
6577[ aliasing ] : http://llvm.org/docs/LangRef.html#pointer-aliasing-rules
6678
67- Whew! That’s a bunch of stuff. It’s also important to notice all kinds of
68- behaviors that are certainly bad, but are expressly _ not_ unsafe:
69-
70- * Deadlocks
71- * Leaks of memory or other resources
72- * Exiting without calling destructors
73- * Integer overflow
74-
75- Rust cannot prevent all kinds of software problems. Buggy code can and will be
76- written in Rust. These things aren’t great, but they don’t qualify as ` unsafe `
77- specifically.
78-
7979# Unsafe Superpowers
8080
8181In both unsafe functions and unsafe blocks, Rust will let you do three things
0 commit comments