diff options
| author | bors <bors@rust-lang.org> | 2014-11-20 06:11:36 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-11-20 06:11:36 +0000 |
| commit | dd5ce5ae2f254cc42763518909f6e7c486d9502a (patch) | |
| tree | 6c67efe56351c88b3aa8b2f87dafc8ad24454ee4 /src/doc/reference.md | |
| parent | 793624261a221aa4592381fa8067e1f597b90c22 (diff) | |
| parent | e0b0c83138236ba1b2d532f79647ee45f7824741 (diff) | |
| download | rust-dd5ce5ae2f254cc42763518909f6e7c486d9502a.tar.gz rust-dd5ce5ae2f254cc42763518909f6e7c486d9502a.zip | |
auto merge of #19105 : alfie/rust/master, r=thestinger
As discussed in pull #19068, trying to make the wording more clear for unsafe code vs undefined behavior.
Diffstat (limited to 'src/doc/reference.md')
| -rw-r--r-- | src/doc/reference.md | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/doc/reference.md b/src/doc/reference.md index d21d877c458..4f0c9a50422 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -1114,13 +1114,13 @@ Rust: ##### Unsafe functions Unsafe functions are functions that are not safe in all contexts and/or for all -possible inputs. Such a function must be prefixed with the keyword `unsafe`. +possible inputs. Such a function must be prefixed with the keyword `unsafe` and +can only be called from an `unsafe` block or another `unsafe` function. ##### Unsafe blocks -A block of code can also be prefixed with the `unsafe` keyword, to permit -calling `unsafe` functions or dereferencing raw pointers within a safe -function. +A block of code can be prefixed with the `unsafe` keyword, to permit calling +`unsafe` functions or dereferencing raw pointers within a safe function. When a programmer has sufficient conviction that a sequence of potentially unsafe operations is actually safe, they can encapsulate that sequence (taken @@ -1140,12 +1140,11 @@ represented with reference-counted pointers in safe code. By using `unsafe` blocks to represent the reverse links as raw pointers, it can be implemented with only boxes. -##### Behavior considered unsafe +##### Behavior considered undefined -This is a list of behavior which is forbidden in all Rust code. Type checking -provides the guarantee that these issues are never caused by safe code. An -`unsafe` block or function is responsible for never invoking this behaviour or -exposing an API making it possible for it to occur in safe code. +The following is a list of behavior which is forbidden in all Rust code, +including within `unsafe` blocks and `unsafe` functions. Type checking provides +the guarantee that these issues are never caused by safe code. * Data races * Dereferencing a null/dangling raw pointer |
