From 6c0314a38ad761c05e1382306bf01d766130a8b0 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Sat, 28 Mar 2015 15:42:56 -0400 Subject: [PATCH] Make note of noalias in unsafe reference section Fixes #19733 --- src/doc/reference.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/doc/reference.md b/src/doc/reference.md index 32088b2ab67bf..81dcfa85f0860 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -1231,12 +1231,15 @@ the guarantee that these issues are never caused by safe code. * Data races * Dereferencing a null/dangling raw pointer -* Mutating an immutable value/reference without `UnsafeCell` * Reads of [undef](http://llvm.org/docs/LangRef.html#undefined-values) (uninitialized) memory * Breaking the [pointer aliasing rules](http://llvm.org/docs/LangRef.html#pointer-aliasing-rules) with raw pointers (a subset of the rules used by C) +* `&mut` and `&` follow LLVM’s scoped [noalias] model, except if the `&T` + contains an `UnsafeCell`. Unsafe code must not violate these aliasing + guarantees. +* Mutating an immutable value/reference without `UnsafeCell` * Invoking undefined behavior via compiler intrinsics: * Indexing outside of the bounds of an object with `std::ptr::offset` (`offset` intrinsic), with @@ -1253,6 +1256,8 @@ the guarantee that these issues are never caused by safe code. code. Rust's failure system is not compatible with exception handling in other languages. Unwinding must be caught and handled at FFI boundaries. +[noalias]: http://llvm.org/docs/LangRef.html#noalias + ##### Behaviour not considered unsafe This is a list of behaviour not considered *unsafe* in Rust terms, but that may