Skip to content

Commit aa218a8

Browse files
committed
---
yaml --- r: 195443 b: refs/heads/master c: 464c18c h: refs/heads/master i: 195441: b97dac1 195439: 0a3c4e4 v: v3
1 parent 1d5043b commit aa218a8

File tree

17 files changed

+320
-98
lines changed

17 files changed

+320
-98
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 4c1f5bd6dc03116c20938d11800c0da8f1a84615
2+
refs/heads/master: 464c18ce9cc6a29c2dcf83d3e78576dbc5390f3c
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: b3317d68910900f135f9f38e43a7a699bc736b4a
55
refs/heads/try: 961e0358e1a5c0faaef606e31e9965742c1643bf

trunk/src/doc/reference.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1188,12 +1188,15 @@ the guarantee that these issues are never caused by safe code.
11881188

11891189
* Data races
11901190
* Dereferencing a null/dangling raw pointer
1191-
* Mutating an immutable value/reference without `UnsafeCell`
11921191
* Reads of [undef](http://llvm.org/docs/LangRef.html#undefined-values)
11931192
(uninitialized) memory
11941193
* Breaking the [pointer aliasing
11951194
rules](http://llvm.org/docs/LangRef.html#pointer-aliasing-rules)
11961195
with raw pointers (a subset of the rules used by C)
1196+
* `&mut` and `&` follow LLVM’s scoped [noalias] model, except if the `&T`
1197+
contains an `UnsafeCell<U>`. Unsafe code must not violate these aliasing
1198+
guarantees.
1199+
* Mutating an immutable value/reference without `UnsafeCell<U>`
11971200
* Invoking undefined behavior via compiler intrinsics:
11981201
* Indexing outside of the bounds of an object with `std::ptr::offset`
11991202
(`offset` intrinsic), with
@@ -1210,6 +1213,8 @@ the guarantee that these issues are never caused by safe code.
12101213
code. Rust's failure system is not compatible with exception handling in
12111214
other languages. Unwinding must be caught and handled at FFI boundaries.
12121215

1216+
[noalias]: http://llvm.org/docs/LangRef.html#noalias
1217+
12131218
##### Behaviour not considered unsafe
12141219

12151220
This is a list of behaviour not considered *unsafe* in Rust terms, but that may

trunk/src/doc/trpl/method-syntax.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ parameter, of which there are three variants: `self`, `&self`, and `&mut self`.
5050
You can think of this first parameter as being the `x` in `x.foo()`. The three
5151
variants correspond to the three kinds of thing `x` could be: `self` if it's
5252
just a value on the stack, `&self` if it's a reference, and `&mut self` if it's
53-
a mutable reference. We should default to using `&self`, as it's the most
54-
common, as Rustaceans prefer borrowing over taking ownership, and references
55-
over mutable references. Here's an example of all three variants:
53+
a mutable reference. We should default to using `&self`, as you should prefer
54+
borrowing over taking ownership, as well as taking immutable references
55+
over mutable ones. Here's an example of all three variants:
5656

5757
```rust
5858
struct Circle {

trunk/src/doc/trpl/ownership.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -472,10 +472,15 @@ thread-safe counterpart of `Rc<T>`.
472472

473473
## Lifetime Elision
474474

475-
Earlier, we mentioned *lifetime elision*, a feature of Rust which allows you to
476-
not write lifetime annotations in certain circumstances. All references have a
477-
lifetime, and so if you elide a lifetime (like `&T` instead of `&'a T`), Rust
478-
will do three things to determine what those lifetimes should be.
475+
Rust supports powerful local type inference in function bodies, but it’s
476+
forbidden in item signatures to allow reasoning about the types just based in
477+
the item signature alone. However, for ergonomic reasons a very restricted
478+
secondary inference algorithm called “lifetime elision” applies in function
479+
signatures. It infers only based on the signature components themselves and not
480+
based on the body of the function, only infers lifetime paramters, and does
481+
this with only three easily memorizable and unambiguous rules. This makes
482+
lifetime elision a shorthand for writing an item signature, while not hiding
483+
away the actual types involved as full local inference would if applied to it.
479484

480485
When talking about lifetime elision, we use the term *input lifetime* and
481486
*output lifetime*. An *input lifetime* is a lifetime associated with a parameter

trunk/src/doc/trpl/testing.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ pub fn add_two(a: i32) -> i32 {
231231
}
232232
233233
#[cfg(test)]
234-
mod tests {
234+
mod test {
235235
use super::add_two;
236236
237237
#[test]
@@ -241,7 +241,7 @@ mod tests {
241241
}
242242
```
243243

244-
There's a few changes here. The first is the introduction of a `mod tests` with
244+
There's a few changes here. The first is the introduction of a `mod test` with
245245
a `cfg` attribute. The module allows us to group all of our tests together, and
246246
to also define helper functions if needed, that don't become a part of the rest
247247
of our crate. The `cfg` attribute only compiles our test code if we're
@@ -260,7 +260,7 @@ pub fn add_two(a: i32) -> i32 {
260260
}
261261
262262
#[cfg(test)]
263-
mod tests {
263+
mod test {
264264
use super::*;
265265
266266
#[test]

trunk/src/libcore/error.rs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,33 +48,30 @@
4848
//! For example,
4949
//!
5050
//! ```
51-
//! # #![feature(os, old_io, old_path)]
51+
//! #![feature(core)]
5252
//! use std::error::FromError;
53-
//! use std::old_io::{File, IoError};
54-
//! use std::os::{MemoryMap, MapError};
55-
//! use std::old_path::Path;
53+
//! use std::{io, str};
54+
//! use std::fs::File;
5655
//!
5756
//! enum MyError {
58-
//! Io(IoError),
59-
//! Map(MapError)
57+
//! Io(io::Error),
58+
//! Utf8(str::Utf8Error),
6059
//! }
6160
//!
62-
//! impl FromError<IoError> for MyError {
63-
//! fn from_error(err: IoError) -> MyError {
64-
//! MyError::Io(err)
65-
//! }
61+
//! impl FromError<io::Error> for MyError {
62+
//! fn from_error(err: io::Error) -> MyError { MyError::Io(err) }
6663
//! }
6764
//!
68-
//! impl FromError<MapError> for MyError {
69-
//! fn from_error(err: MapError) -> MyError {
70-
//! MyError::Map(err)
71-
//! }
65+
//! impl FromError<str::Utf8Error> for MyError {
66+
//! fn from_error(err: str::Utf8Error) -> MyError { MyError::Utf8(err) }
7267
//! }
7368
//!
7469
//! #[allow(unused_variables)]
7570
//! fn open_and_map() -> Result<(), MyError> {
76-
//! let f = try!(File::open(&Path::new("foo.txt")));
77-
//! let m = try!(MemoryMap::new(0, &[]));
71+
//! let b = b"foo.txt";
72+
//! let s = try!(str::from_utf8(b));
73+
//! let f = try!(File::open(s));
74+
//!
7875
//! // do something interesting here...
7976
//! Ok(())
8077
//! }

trunk/src/libcore/option.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ impl<T> Option<T> {
333333
}
334334
}
335335

336-
/// Moves the value `v` out of the `Option<T>` if the content of the `Option<T>` is a `Some(v)`.
336+
/// Moves the value `v` out of the `Option<T>` if it is `Some(v)`.
337337
///
338338
/// # Panics
339339
///

trunk/src/librustc/middle/expr_use_visitor.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,11 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
885885
}
886886
}
887887

888+
// When this returns true, it means that the expression *is* a
889+
// method-call (i.e. via the operator-overload). This true result
890+
// also implies that walk_overloaded_operator already took care of
891+
// recursively processing the input arguments, and thus the caller
892+
// should not do so.
888893
fn walk_overloaded_operator(&mut self,
889894
expr: &ast::Expr,
890895
receiver: &ast::Expr,

0 commit comments

Comments
 (0)