Skip to content

Commit b949d36

Browse files
committed
---
yaml --- r: 195702 b: refs/heads/auto c: e3f2d45 h: refs/heads/master v: v3
1 parent 50a3224 commit b949d36

File tree

157 files changed

+2730
-2188
lines changed

Some content is hidden

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

157 files changed

+2730
-2188
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1010
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1111
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1212
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
13-
refs/heads/auto: 606f50c46dd9a3852d36456d2015e1ccf832642e
13+
refs/heads/auto: e3f2d45cb38a89172c423aba07ce270b1a04984f
1414
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1515
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1616
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/configure

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,8 @@ VAL_OPTIONS=""
526526
opt valgrind 0 "run tests with valgrind (memcheck by default)"
527527
opt helgrind 0 "run tests with helgrind instead of memcheck"
528528
opt valgrind-rpass 1 "run rpass-valgrind tests with valgrind"
529-
opt docs 1 "build documentation"
529+
opt docs 1 "build standard library documentation"
530+
opt compiler-docs 0 "build compiler documentation"
530531
opt optimize 1 "build optimized rust code"
531532
opt optimize-cxx 1 "build optimized C++ code"
532533
opt optimize-llvm 1 "build optimized LLVM"

branches/auto/mk/crates.mk

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,17 +122,34 @@ ONLY_RLIB_rustc_bitflags := 1
122122
# You should not need to edit below this line
123123
################################################################################
124124

125+
# On channels where the only usable crate is std, only build documentation for
126+
# std. This keeps distributions small and doesn't clutter up the API docs with
127+
# 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.)
133+
134+
#ifeq ($(CFG_RELEASE_CHANNEL),stable)
135+
#DOC_CRATES := std
136+
#else
137+
#ifeq ($(CFG_RELEASE_CHANNEL),beta)
138+
#DOC_CRATES := std
139+
#else
125140
DOC_CRATES := $(filter-out rustc, \
126-
$(filter-out rustc_trans, \
127-
$(filter-out rustc_typeck, \
128-
$(filter-out rustc_borrowck, \
129-
$(filter-out rustc_resolve, \
130-
$(filter-out rustc_driver, \
131-
$(filter-out rustc_privacy, \
132-
$(filter-out rustc_lint, \
133-
$(filter-out log, \
134-
$(filter-out getopts, \
135-
$(filter-out syntax, $(CRATES))))))))))))
141+
$(filter-out rustc_trans, \
142+
$(filter-out rustc_typeck, \
143+
$(filter-out rustc_borrowck, \
144+
$(filter-out rustc_resolve, \
145+
$(filter-out rustc_driver, \
146+
$(filter-out rustc_privacy, \
147+
$(filter-out rustc_lint, \
148+
$(filter-out log, \
149+
$(filter-out getopts, \
150+
$(filter-out syntax, $(CRATES))))))))))))
151+
#endif
152+
#endif
136153
COMPILER_DOC_CRATES := rustc rustc_trans rustc_borrowck rustc_resolve \
137154
rustc_typeck rustc_driver syntax rustc_privacy \
138155
rustc_lint

branches/auto/mk/docs.mk

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,10 @@ doc/$(1)/index.html: $$(LIB_DOC_DEP_$(1)) doc/$(1)/
259259
endef
260260

261261
$(foreach crate,$(DOC_CRATES),$(eval $(call DEF_LIB_DOC,$(crate),DOC_TARGETS)))
262-
$(foreach crate,$(COMPILER_DOC_CRATES),$(eval $(call DEF_LIB_DOC,$(crate),COMPILER_DOC_TARGETS)))
262+
263+
ifdef CFG_COMPILER_DOCS
264+
$(foreach crate,$(COMPILER_DOC_CRATES),$(eval $(call DEF_LIB_DOC,$(crate),COMPILER_DOC_TARGETS)))
265+
endif
263266

264267
ifdef CFG_DISABLE_DOCS
265268
$(info cfg: disabling doc build (CFG_DISABLE_DOCS))

branches/auto/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

branches/auto/src/doc/trpl/method-syntax.md

Lines changed: 19 additions & 11 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 {
@@ -181,17 +181,23 @@ impl Circle {
181181
}
182182
183183
struct CircleBuilder {
184-
coordinate: f64,
184+
x: f64,
185+
y: f64,
185186
radius: f64,
186187
}
187188
188189
impl CircleBuilder {
189190
fn new() -> CircleBuilder {
190-
CircleBuilder { coordinate: 0.0, radius: 0.0, }
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
191197
}
192198
193-
fn coordinate(&mut self, coordinate: f64) -> &mut CircleBuilder {
194-
self.coordinate = coordinate;
199+
fn y(&mut self, coordinate: f64) -> &mut CircleBuilder {
200+
self.x = coordinate;
195201
self
196202
}
197203
@@ -201,18 +207,20 @@ impl CircleBuilder {
201207
}
202208
203209
fn finalize(&self) -> Circle {
204-
Circle { x: self.coordinate, y: self.coordinate, radius: self.radius }
210+
Circle { x: self.x, y: self.y, radius: self.radius }
205211
}
206212
}
207213
208214
fn main() {
209215
let c = CircleBuilder::new()
210-
.coordinate(10.0)
211-
.radius(5.0)
216+
.x(1.0)
217+
.y(2.0)
218+
.radius(2.0)
212219
.finalize();
213220
214-
215221
println!("area: {}", c.area());
222+
println!("x: {}", c.x);
223+
println!("y: {}", c.y);
216224
}
217225
```
218226

branches/auto/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

branches/auto/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]

branches/auto/src/liballoc/arc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ use heap::deallocate;
110110
/// let child_numbers = shared_numbers.clone();
111111
///
112112
/// thread::spawn(move || {
113-
/// let local_numbers = child_numbers.as_slice();
113+
/// let local_numbers = &child_numbers[..];
114114
///
115115
/// // Work with the local numbers
116116
/// });

branches/auto/src/liballoc/boxed.rs

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -233,24 +233,10 @@ impl<T: ?Sized + Hash> Hash for Box<T> {
233233
}
234234
}
235235

236-
/// Extension methods for an owning `Any` trait object.
237-
#[unstable(feature = "alloc",
238-
reason = "this trait will likely disappear once compiler bugs blocking \
239-
a direct impl on `Box<Any>` have been fixed ")]
240-
// FIXME(#18737): this should be a direct impl on `Box<Any>`. If you're
241-
// removing this please make sure that you can downcase on
242-
// `Box<Any + Send>` as well as `Box<Any>`
243-
pub trait BoxAny {
244-
/// Returns the boxed value if it is of type `T`, or
245-
/// `Err(Self)` if it isn't.
246-
#[stable(feature = "rust1", since = "1.0.0")]
247-
fn downcast<T: Any>(self) -> Result<Box<T>, Box<Any>>;
248-
}
249-
250-
#[stable(feature = "rust1", since = "1.0.0")]
251-
impl BoxAny for Box<Any> {
236+
impl Box<Any> {
252237
#[inline]
253-
fn downcast<T: Any>(self) -> Result<Box<T>, Box<Any>> {
238+
#[stable(feature = "rust1", since = "1.0.0")]
239+
pub fn downcast<T: Any>(self) -> Result<Box<T>, Box<Any>> {
254240
if self.is::<T>() {
255241
unsafe {
256242
// Get the raw representation of the trait object
@@ -267,10 +253,10 @@ impl BoxAny for Box<Any> {
267253
}
268254
}
269255

270-
#[stable(feature = "rust1", since = "1.0.0")]
271-
impl BoxAny for Box<Any+Send> {
256+
impl Box<Any+Send> {
272257
#[inline]
273-
fn downcast<T: Any>(self) -> Result<Box<T>, Box<Any>> {
258+
#[stable(feature = "rust1", since = "1.0.0")]
259+
pub fn downcast<T: Any>(self) -> Result<Box<T>, Box<Any>> {
274260
<Box<Any>>::downcast(self)
275261
}
276262
}

branches/auto/src/liballoc/boxed_test.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use core::clone::Clone;
1717

1818
use std::boxed;
1919
use std::boxed::Box;
20-
use std::boxed::BoxAny;
2120

2221
#[test]
2322
fn test_owned_clone() {

branches/auto/src/liballoc/heap.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ 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;
193192
use libc::{c_char, c_int, c_void, size_t};
194193
use super::MIN_ALIGN;
195194

@@ -301,7 +300,7 @@ mod imp {
301300
libc::realloc(ptr as *mut libc::c_void, size as libc::size_t) as *mut u8
302301
} else {
303302
let new_ptr = allocate(size, align);
304-
ptr::copy(new_ptr, ptr, cmp::min(size, old_size));
303+
ptr::copy(ptr, new_ptr, cmp::min(size, old_size));
305304
deallocate(ptr, old_size, align);
306305
new_ptr
307306
}

branches/auto/src/libcollections/bit.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ 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;
9594
use core::ops::Index;
9695
use core::slice;
9796
use core::{u8, u32, usize};

branches/auto/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 {

0 commit comments

Comments
 (0)