Skip to content

Commit 97d0e03

Browse files
committed
---
yaml --- r: 195453 b: refs/heads/master c: edc096d h: refs/heads/master i: 195451: c86c2c0 v: v3
1 parent be63c5e commit 97d0e03

File tree

122 files changed

+2082
-2174
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+2082
-2174
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: 5d0beb7d85e8e711334c7fb6f2c5da270e5200cb
2+
refs/heads/master: edc096d820c549319aaa9662412beb2deec39441
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: b3317d68910900f135f9f38e43a7a699bc736b4a
55
refs/heads/try: 961e0358e1a5c0faaef606e31e9965742c1643bf

trunk/mk/crates.mk

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -125,18 +125,13 @@ ONLY_RLIB_rustc_bitflags := 1
125125
# On channels where the only usable crate is std, only build documentation for
126126
# std. This keeps distributions small and doesn't clutter up the API docs with
127127
# confusing internal details from the crates behind the facade.
128-
#
129-
# (Disabled while cmr figures out how to change rustdoc to make reexports work
130-
# slightly nicer. Otherwise, all cross-crate links to Vec will go to
131-
# libcollections, breaking them, and [src] links for anything reexported will
132-
# not work.)
133128

134-
#ifeq ($(CFG_RELEASE_CHANNEL),stable)
135-
#DOC_CRATES := std
136-
#else
137-
#ifeq ($(CFG_RELEASE_CHANNEL),beta)
138-
#DOC_CRATES := std
139-
#else
129+
ifeq ($(CFG_RELEASE_CHANNEL),stable)
130+
DOC_CRATES := std
131+
else
132+
ifeq ($(CFG_RELEASE_CHANNEL),beta)
133+
DOC_CRATES := std
134+
else
140135
DOC_CRATES := $(filter-out rustc, \
141136
$(filter-out rustc_trans, \
142137
$(filter-out rustc_typeck, \
@@ -148,8 +143,8 @@ DOC_CRATES := $(filter-out rustc, \
148143
$(filter-out log, \
149144
$(filter-out getopts, \
150145
$(filter-out syntax, $(CRATES))))))))))))
151-
#endif
152-
#endif
146+
endif
147+
endif
153148
COMPILER_DOC_CRATES := rustc rustc_trans rustc_borrowck rustc_resolve \
154149
rustc_typeck rustc_driver syntax rustc_privacy \
155150
rustc_lint

trunk/src/doc/reference.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,15 +1188,12 @@ 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`
11911192
* Reads of [undef](http://llvm.org/docs/LangRef.html#undefined-values)
11921193
(uninitialized) memory
11931194
* Breaking the [pointer aliasing
11941195
rules](http://llvm.org/docs/LangRef.html#pointer-aliasing-rules)
11951196
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>`
12001197
* Invoking undefined behavior via compiler intrinsics:
12011198
* Indexing outside of the bounds of an object with `std::ptr::offset`
12021199
(`offset` intrinsic), with
@@ -1213,8 +1210,6 @@ the guarantee that these issues are never caused by safe code.
12131210
code. Rust's failure system is not compatible with exception handling in
12141211
other languages. Unwinding must be caught and handled at FFI boundaries.
12151212

1216-
[noalias]: http://llvm.org/docs/LangRef.html#noalias
1217-
12181213
##### Behaviour not considered unsafe
12191214

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

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

Lines changed: 11 additions & 19 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 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:
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:
5656

5757
```rust
5858
struct Circle {
@@ -181,23 +181,17 @@ impl Circle {
181181
}
182182
183183
struct CircleBuilder {
184-
x: f64,
185-
y: f64,
184+
coordinate: f64,
186185
radius: f64,
187186
}
188187
189188
impl CircleBuilder {
190189
fn new() -> CircleBuilder {
191-
CircleBuilder { x: 0.0, y: 0.0, radius: 0.0, }
192-
}
193-
194-
fn x(&mut self, coordinate: f64) -> &mut CircleBuilder {
195-
self.x = coordinate;
196-
self
190+
CircleBuilder { coordinate: 0.0, radius: 0.0, }
197191
}
198192
199-
fn y(&mut self, coordinate: f64) -> &mut CircleBuilder {
200-
self.x = coordinate;
193+
fn coordinate(&mut self, coordinate: f64) -> &mut CircleBuilder {
194+
self.coordinate = coordinate;
201195
self
202196
}
203197
@@ -207,20 +201,18 @@ impl CircleBuilder {
207201
}
208202
209203
fn finalize(&self) -> Circle {
210-
Circle { x: self.x, y: self.y, radius: self.radius }
204+
Circle { x: self.coordinate, y: self.coordinate, radius: self.radius }
211205
}
212206
}
213207
214208
fn main() {
215209
let c = CircleBuilder::new()
216-
.x(1.0)
217-
.y(2.0)
218-
.radius(2.0)
210+
.coordinate(10.0)
211+
.radius(5.0)
219212
.finalize();
220213
214+
221215
println!("area: {}", c.area());
222-
println!("x: {}", c.x);
223-
println!("y: {}", c.y);
224216
}
225217
```
226218

trunk/src/doc/trpl/ownership.md

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

473473
## Lifetime Elision
474474

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.
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.
484479

485480
When talking about lifetime elision, we use the term *input lifetime* and
486481
*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 test {
234+
mod tests {
235235
use super::add_two;
236236
237237
#[test]
@@ -241,7 +241,7 @@ mod test {
241241
}
242242
```
243243

244-
There's a few changes here. The first is the introduction of a `mod test` with
244+
There's a few changes here. The first is the introduction of a `mod tests` 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 test {
263+
mod tests {
264264
use super::*;
265265
266266
#[test]

trunk/src/liballoc/heap.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ mod imp {
189189
use core::option::Option;
190190
use core::option::Option::None;
191191
use core::ptr::{null_mut, null};
192+
use core::num::Int;
192193
use libc::{c_char, c_int, c_void, size_t};
193194
use super::MIN_ALIGN;
194195

@@ -300,7 +301,7 @@ mod imp {
300301
libc::realloc(ptr as *mut libc::c_void, size as libc::size_t) as *mut u8
301302
} else {
302303
let new_ptr = allocate(size, align);
303-
ptr::copy(ptr, new_ptr, cmp::min(size, old_size));
304+
ptr::copy(new_ptr, ptr, cmp::min(size, old_size));
304305
deallocate(ptr, old_size, align);
305306
new_ptr
306307
}

trunk/src/libcollections/bit.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ use core::hash;
9191
use core::iter::RandomAccessIterator;
9292
use core::iter::{Chain, Enumerate, Repeat, Skip, Take, repeat, Cloned};
9393
use core::iter::{self, FromIterator, IntoIterator};
94+
use core::num::Int;
9495
use core::ops::Index;
9596
use core::slice;
9697
use core::{u8, u32, usize};

trunk/src/libcollections/borrow.rs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,24 @@ use self::Cow::*;
4040
#[stable(feature = "rust1", since = "1.0.0")]
4141
pub trait Borrow<Borrowed: ?Sized> {
4242
/// Immutably borrow from an owned value.
43+
///
44+
/// # Examples
45+
///
46+
/// ```
47+
/// use std::borrow::Borrow;
48+
///
49+
/// fn check<T: Borrow<str>>(s: T) {
50+
/// assert_eq!("Hello", s.borrow());
51+
/// }
52+
///
53+
/// let s = "Hello".to_string();
54+
///
55+
/// check(s);
56+
///
57+
/// let s = "Hello";
58+
///
59+
/// check(s);
60+
/// ```
4361
#[stable(feature = "rust1", since = "1.0.0")]
4462
fn borrow(&self) -> &Borrowed;
4563
}
@@ -50,6 +68,20 @@ pub trait Borrow<Borrowed: ?Sized> {
5068
#[stable(feature = "rust1", since = "1.0.0")]
5169
pub trait BorrowMut<Borrowed: ?Sized> : Borrow<Borrowed> {
5270
/// Mutably borrow from an owned value.
71+
///
72+
/// # Examples
73+
///
74+
/// ```
75+
/// use std::borrow::BorrowMut;
76+
///
77+
/// fn check<T: BorrowMut<[i32]>>(mut v: T) {
78+
/// assert_eq!(&mut [1, 2, 3], v.borrow_mut());
79+
/// }
80+
///
81+
/// let v = vec![1, 2, 3];
82+
///
83+
/// check(v);
84+
/// ```
5385
#[stable(feature = "rust1", since = "1.0.0")]
5486
fn borrow_mut(&mut self) -> &mut Borrowed;
5587
}
@@ -171,6 +203,18 @@ impl<'a, B: ?Sized> Cow<'a, B> where B: ToOwned {
171203
/// Acquire a mutable reference to the owned form of the data.
172204
///
173205
/// Copies the data if it is not already owned.
206+
///
207+
/// # Examples
208+
///
209+
/// ```
210+
/// use std::borrow::Cow;
211+
///
212+
/// let mut cow: Cow<[_]> = Cow::Owned(vec![1, 2, 3]);
213+
///
214+
/// let hello = cow.to_mut();
215+
///
216+
/// assert_eq!(&[1, 2, 3], hello);
217+
/// ```
174218
#[stable(feature = "rust1", since = "1.0.0")]
175219
pub fn to_mut(&mut self) -> &mut <B as ToOwned>::Owned {
176220
match *self {
@@ -185,6 +229,18 @@ impl<'a, B: ?Sized> Cow<'a, B> where B: ToOwned {
185229
/// Extract the owned data.
186230
///
187231
/// Copies the data if it is not already owned.
232+
///
233+
/// # Examples
234+
///
235+
/// ```
236+
/// use std::borrow::Cow;
237+
///
238+
/// let cow: Cow<[_]> = Cow::Owned(vec![1, 2, 3]);
239+
///
240+
/// let hello = cow.into_owned();
241+
///
242+
/// assert_eq!(vec![1, 2, 3], hello);
243+
/// ```
188244
#[stable(feature = "rust1", since = "1.0.0")]
189245
pub fn into_owned(self) -> <B as ToOwned>::Owned {
190246
match self {

trunk/src/libcollections/btree/node.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,13 +1133,13 @@ impl<K, V> Node<K, V> {
11331133
#[inline]
11341134
unsafe fn insert_kv(&mut self, index: usize, key: K, val: V) -> &mut V {
11351135
ptr::copy(
1136-
self.keys().as_ptr().offset(index as isize),
11371136
self.keys_mut().as_mut_ptr().offset(index as isize + 1),
1137+
self.keys().as_ptr().offset(index as isize),
11381138
self.len() - index
11391139
);
11401140
ptr::copy(
1141-
self.vals().as_ptr().offset(index as isize),
11421141
self.vals_mut().as_mut_ptr().offset(index as isize + 1),
1142+
self.vals().as_ptr().offset(index as isize),
11431143
self.len() - index
11441144
);
11451145

@@ -1155,8 +1155,8 @@ impl<K, V> Node<K, V> {
11551155
#[inline]
11561156
unsafe fn insert_edge(&mut self, index: usize, edge: Node<K, V>) {
11571157
ptr::copy(
1158-
self.edges().as_ptr().offset(index as isize),
11591158
self.edges_mut().as_mut_ptr().offset(index as isize + 1),
1159+
self.edges().as_ptr().offset(index as isize),
11601160
self.len() - index
11611161
);
11621162
ptr::write(self.edges_mut().get_unchecked_mut(index), edge);
@@ -1188,13 +1188,13 @@ impl<K, V> Node<K, V> {
11881188
let val = ptr::read(self.vals().get_unchecked(index));
11891189

11901190
ptr::copy(
1191-
self.keys().as_ptr().offset(index as isize + 1),
11921191
self.keys_mut().as_mut_ptr().offset(index as isize),
1192+
self.keys().as_ptr().offset(index as isize + 1),
11931193
self.len() - index - 1
11941194
);
11951195
ptr::copy(
1196-
self.vals().as_ptr().offset(index as isize + 1),
11971196
self.vals_mut().as_mut_ptr().offset(index as isize),
1197+
self.vals().as_ptr().offset(index as isize + 1),
11981198
self.len() - index - 1
11991199
);
12001200

@@ -1209,8 +1209,8 @@ impl<K, V> Node<K, V> {
12091209
let edge = ptr::read(self.edges().get_unchecked(index));
12101210

12111211
ptr::copy(
1212-
self.edges().as_ptr().offset(index as isize + 1),
12131212
self.edges_mut().as_mut_ptr().offset(index as isize),
1213+
self.edges().as_ptr().offset(index as isize + 1),
12141214
// index can be == len+1, so do the +1 first to avoid underflow.
12151215
(self.len() + 1) - index
12161216
);
@@ -1237,19 +1237,19 @@ impl<K, V> Node<K, V> {
12371237
right._len = self.len() / 2;
12381238
let right_offset = self.len() - right.len();
12391239
ptr::copy_nonoverlapping(
1240-
self.keys().as_ptr().offset(right_offset as isize),
12411240
right.keys_mut().as_mut_ptr(),
1241+
self.keys().as_ptr().offset(right_offset as isize),
12421242
right.len()
12431243
);
12441244
ptr::copy_nonoverlapping(
1245-
self.vals().as_ptr().offset(right_offset as isize),
12461245
right.vals_mut().as_mut_ptr(),
1246+
self.vals().as_ptr().offset(right_offset as isize),
12471247
right.len()
12481248
);
12491249
if !self.is_leaf() {
12501250
ptr::copy_nonoverlapping(
1251-
self.edges().as_ptr().offset(right_offset as isize),
12521251
right.edges_mut().as_mut_ptr(),
1252+
self.edges().as_ptr().offset(right_offset as isize),
12531253
right.len() + 1
12541254
);
12551255
}
@@ -1278,19 +1278,19 @@ impl<K, V> Node<K, V> {
12781278
ptr::write(self.vals_mut().get_unchecked_mut(old_len), val);
12791279

12801280
ptr::copy_nonoverlapping(
1281-
right.keys().as_ptr(),
12821281
self.keys_mut().as_mut_ptr().offset(old_len as isize + 1),
1282+
right.keys().as_ptr(),
12831283
right.len()
12841284
);
12851285
ptr::copy_nonoverlapping(
1286-
right.vals().as_ptr(),
12871286
self.vals_mut().as_mut_ptr().offset(old_len as isize + 1),
1287+
right.vals().as_ptr(),
12881288
right.len()
12891289
);
12901290
if !self.is_leaf() {
12911291
ptr::copy_nonoverlapping(
1292-
right.edges().as_ptr(),
12931292
self.edges_mut().as_mut_ptr().offset(old_len as isize + 1),
1293+
right.edges().as_ptr(),
12941294
right.len() + 1
12951295
);
12961296
}

trunk/src/libcollections/enum_set.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use core::prelude::*;
1717
use core::marker;
1818
use core::fmt;
19+
use core::num::Int;
1920
use core::iter::{FromIterator, IntoIterator};
2021
use core::ops::{Sub, BitOr, BitAnd, BitXor};
2122

0 commit comments

Comments
 (0)