Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f136e9e

Browse files
authoredOct 22, 2016
Auto merge of #37337 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 10 pull requests - Successful merges: #37043, #37209, #37211, #37219, #37244, #37253, #37286, #37297, #37309, #37314 - Failed merges:
2 parents a6fa572 + 1c2d223 commit f136e9e

File tree

14 files changed

+263
-133
lines changed

14 files changed

+263
-133
lines changed
 

‎src/bootstrap/bin/rustc.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ fn main() {
3636
let args = env::args_os().skip(1).collect::<Vec<_>>();
3737
// Detect whether or not we're a build script depending on whether --target
3838
// is passed (a bit janky...)
39-
let target = args.windows(2).find(|w| &*w[0] == "--target")
40-
.and_then(|w| w[1].to_str());
39+
let target = args.windows(2)
40+
.find(|w| &*w[0] == "--target")
41+
.and_then(|w| w[1].to_str());
4142
let version = args.iter().find(|w| &**w == "-vV");
4243

4344
// Build scripts always use the snapshot compiler which is guaranteed to be
@@ -64,9 +65,10 @@ fn main() {
6465

6566
let mut cmd = Command::new(rustc);
6667
cmd.args(&args)
67-
.arg("--cfg").arg(format!("stage{}", stage))
68-
.env(bootstrap::util::dylib_path_var(),
69-
env::join_paths(&dylib_path).unwrap());
68+
.arg("--cfg")
69+
.arg(format!("stage{}", stage))
70+
.env(bootstrap::util::dylib_path_var(),
71+
env::join_paths(&dylib_path).unwrap());
7072

7173
if let Some(target) = target {
7274
// The stage0 compiler has a special sysroot distinct from what we
@@ -101,9 +103,8 @@ fn main() {
101103
// This... is a bit of a hack how we detect this. Ideally this
102104
// information should be encoded in the crate I guess? Would likely
103105
// require an RFC amendment to RFC 1513, however.
104-
let is_panic_abort = args.windows(2).any(|a| {
105-
&*a[0] == "--crate-name" && &*a[1] == "panic_abort"
106-
});
106+
let is_panic_abort = args.windows(2)
107+
.any(|a| &*a[0] == "--crate-name" && &*a[1] == "panic_abort");
107108
if is_panic_abort {
108109
cmd.arg("-C").arg("panic=abort");
109110
}
@@ -116,7 +117,7 @@ fn main() {
116117
cmd.arg("-Cdebuginfo=1");
117118
}
118119
let debug_assertions = match env::var("RUSTC_DEBUG_ASSERTIONS") {
119-
Ok(s) => if s == "true" {"y"} else {"n"},
120+
Ok(s) => if s == "true" { "y" } else { "n" },
120121
Err(..) => "n",
121122
};
122123
cmd.arg("-C").arg(format!("debug-assertions={}", debug_assertions));

‎src/bootstrap/bin/rustdoc.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ fn main() {
2929

3030
let mut cmd = Command::new(rustdoc);
3131
cmd.args(&args)
32-
.arg("--cfg").arg(format!("stage{}", stage))
33-
.arg("--cfg").arg("dox")
34-
.env(bootstrap::util::dylib_path_var(),
35-
env::join_paths(&dylib_path).unwrap());
32+
.arg("--cfg")
33+
.arg(format!("stage{}", stage))
34+
.arg("--cfg")
35+
.arg("dox")
36+
.env(bootstrap::util::dylib_path_var(),
37+
env::join_paths(&dylib_path).unwrap());
3638
std::process::exit(match cmd.status() {
3739
Ok(s) => s.code().unwrap_or(1),
3840
Err(e) => panic!("\n\nfailed to run {:?}: {}\n\n", cmd, e),

‎src/build_helper/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ pub fn run_silent(cmd: &mut Command) {
2525
};
2626
if !status.success() {
2727
fail(&format!("command did not execute successfully: {:?}\n\
28-
expected success, got: {}", cmd, status));
28+
expected success, got: {}",
29+
cmd,
30+
status));
2931
}
3032
}
3133

@@ -65,7 +67,9 @@ pub fn output(cmd: &mut Command) -> String {
6567
};
6668
if !output.status.success() {
6769
panic!("command did not execute successfully: {:?}\n\
68-
expected success, got: {}", cmd, output.status);
70+
expected success, got: {}",
71+
cmd,
72+
output.status);
6973
}
7074
String::from_utf8(output.stdout).unwrap()
7175
}

‎src/doc/book/guessing-game.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ displaying the message.
276276
[expect]: ../std/result/enum.Result.html#method.expect
277277
[panic]: error-handling.html
278278

279-
If we leave off calling this method, our program will compile, but
279+
If we do not call `expect()`, our program will compile, but
280280
we’ll get a warning:
281281

282282
```bash

‎src/liballoc/raw_vec.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,7 @@ impl<T> RawVec<T> {
5757
pub fn new() -> Self {
5858
unsafe {
5959
// !0 is usize::MAX. This branch should be stripped at compile time.
60-
let cap = if mem::size_of::<T>() == 0 {
61-
!0
62-
} else {
63-
0
64-
};
60+
let cap = if mem::size_of::<T>() == 0 { !0 } else { 0 };
6561

6662
// heap::EMPTY doubles as "unallocated" and "zero-sized allocation"
6763
RawVec {
@@ -209,11 +205,7 @@ impl<T> RawVec<T> {
209205

210206
let (new_cap, ptr) = if self.cap == 0 {
211207
// skip to 4 because tiny Vec's are dumb; but not if that would cause overflow
212-
let new_cap = if elem_size > (!0) / 8 {
213-
1
214-
} else {
215-
4
216-
};
208+
let new_cap = if elem_size > (!0) / 8 { 1 } else { 4 };
217209
let ptr = heap::allocate(new_cap * elem_size, align);
218210
(new_cap, ptr)
219211
} else {
@@ -347,7 +339,7 @@ impl<T> RawVec<T> {
347339
let elem_size = mem::size_of::<T>();
348340
// Nothing we can really do about these checks :(
349341
let required_cap = used_cap.checked_add(needed_extra_cap)
350-
.expect("capacity overflow");
342+
.expect("capacity overflow");
351343
// Cannot overflow, because `cap <= isize::MAX`, and type of `cap` is `usize`.
352344
let double_cap = self.cap * 2;
353345
// `double_cap` guarantees exponential growth.

‎src/liballoc_jemalloc/build.rs

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,8 @@ fn main() {
3535
// that the feature set used by std is the same across all
3636
// targets, which means we have to build the alloc_jemalloc crate
3737
// for targets like emscripten, even if we don't use it.
38-
if target.contains("rumprun") ||
39-
target.contains("bitrig") ||
40-
target.contains("openbsd") ||
41-
target.contains("msvc") ||
42-
target.contains("emscripten")
43-
{
38+
if target.contains("rumprun") || target.contains("bitrig") || target.contains("openbsd") ||
39+
target.contains("msvc") || target.contains("emscripten") {
4440
println!("cargo:rustc-cfg=dummy_jemalloc");
4541
return;
4642
}
@@ -64,16 +60,16 @@ fn main() {
6460
// only msvc returns None for ar so unwrap is okay
6561
let ar = build_helper::cc2ar(compiler.path(), &target).unwrap();
6662
let cflags = compiler.args()
67-
.iter()
68-
.map(|s| s.to_str().unwrap())
69-
.collect::<Vec<_>>()
70-
.join(" ");
63+
.iter()
64+
.map(|s| s.to_str().unwrap())
65+
.collect::<Vec<_>>()
66+
.join(" ");
7167

7268
let mut stack = src_dir.join("../jemalloc")
73-
.read_dir()
74-
.unwrap()
75-
.map(|e| e.unwrap())
76-
.collect::<Vec<_>>();
69+
.read_dir()
70+
.unwrap()
71+
.map(|e| e.unwrap())
72+
.collect::<Vec<_>>();
7773
while let Some(entry) = stack.pop() {
7874
let path = entry.path();
7975
if entry.file_type().unwrap().is_dir() {
@@ -155,10 +151,10 @@ fn main() {
155151

156152
run(&mut cmd);
157153
run(Command::new("make")
158-
.current_dir(&build_dir)
159-
.arg("build_lib_static")
160-
.arg("-j")
161-
.arg(env::var("NUM_JOBS").expect("NUM_JOBS was not set")));
154+
.current_dir(&build_dir)
155+
.arg("build_lib_static")
156+
.arg("-j")
157+
.arg(env::var("NUM_JOBS").expect("NUM_JOBS was not set")));
162158

163159
if target.contains("windows") {
164160
println!("cargo:rustc-link-lib=static=jemalloc");

‎src/liballoc_system/lib.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,7 @@ mod imp {
221221
HEAP_REALLOC_IN_PLACE_ONLY,
222222
ptr as LPVOID,
223223
size as SIZE_T) as *mut u8;
224-
if new.is_null() {
225-
old_size
226-
} else {
227-
size
228-
}
224+
if new.is_null() { old_size } else { size }
229225
} else {
230226
old_size
231227
}

‎src/libarena/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,8 @@ mod tests {
335335

336336
let arena = Wrap(TypedArena::new());
337337

338-
let result = arena.alloc_outer(|| {
339-
Outer { inner: arena.alloc_inner(|| Inner { value: 10 }) }
340-
});
338+
let result =
339+
arena.alloc_outer(|| Outer { inner: arena.alloc_inner(|| Inner { value: 10 }) });
341340

342341
assert_eq!(result.inner.value, 10);
343342
}

‎src/libcollections/vec.rs

Lines changed: 85 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
//!
1717
//! # Examples
1818
//!
19-
//! You can explicitly create a `Vec<T>` with `new()`:
19+
//! You can explicitly create a [`Vec<T>`] with [`new()`]:
2020
//!
2121
//! ```
2222
//! let v: Vec<i32> = Vec::new();
2323
//! ```
2424
//!
25-
//! ...or by using the `vec!` macro:
25+
//! ...or by using the [`vec!`] macro:
2626
//!
2727
//! ```
2828
//! let v: Vec<i32> = vec![];
@@ -32,7 +32,7 @@
3232
//! let v = vec![0; 10]; // ten zeroes
3333
//! ```
3434
//!
35-
//! You can `push` values onto the end of a vector (which will grow the vector
35+
//! You can [`push`] values onto the end of a vector (which will grow the vector
3636
//! as needed):
3737
//!
3838
//! ```
@@ -49,13 +49,20 @@
4949
//! let two = v.pop();
5050
//! ```
5151
//!
52-
//! Vectors also support indexing (through the `Index` and `IndexMut` traits):
52+
//! Vectors also support indexing (through the [`Index`] and [`IndexMut`] traits):
5353
//!
5454
//! ```
5555
//! let mut v = vec![1, 2, 3];
5656
//! let three = v[2];
5757
//! v[1] = v[1] + 5;
5858
//! ```
59+
//!
60+
//! [`Vec<T>`]: ../../std/vec/struct.Vec.html
61+
//! [`new()`]: ../../std/vec/struct.Vec.html#method.new
62+
//! [`push`]: ../../std/vec/struct.Vec.html#method.push
63+
//! [`Index`]: ../../std/ops/trait.Index.html
64+
//! [`IndexMut`]: ../../std/ops/trait.IndexMut.html
65+
//! [`vec!`]: ../../std/macro.vec.html
5966
6067
#![stable(feature = "rust1", since = "1.0.0")]
6168

@@ -79,7 +86,7 @@ use core::slice;
7986
use super::SpecExtend;
8087
use super::range::RangeArgument;
8188

82-
/// A contiguous growable array type, written `Vec<T>` but pronounced 'vector.'
89+
/// A contiguous growable array type, written `Vec<T>` but pronounced 'vector'.
8390
///
8491
/// # Examples
8592
///
@@ -105,7 +112,7 @@ use super::range::RangeArgument;
105112
/// assert_eq!(vec, [7, 1, 2, 3]);
106113
/// ```
107114
///
108-
/// The `vec!` macro is provided to make initialization more convenient:
115+
/// The [`vec!`] macro is provided to make initialization more convenient:
109116
///
110117
/// ```
111118
/// let mut vec = vec![1, 2, 3];
@@ -137,15 +144,15 @@ use super::range::RangeArgument;
137144
///
138145
/// # Indexing
139146
///
140-
/// The Vec type allows to access values by index, because it implements the
141-
/// `Index` trait. An example will be more explicit:
147+
/// The `Vec` type allows to access values by index, because it implements the
148+
/// [`Index`] trait. An example will be more explicit:
142149
///
143150
/// ```
144151
/// let v = vec!(0, 2, 4, 6);
145152
/// println!("{}", v[1]); // it will display '2'
146153
/// ```
147154
///
148-
/// However be careful: if you try to access an index which isn't in the Vec,
155+
/// However be careful: if you try to access an index which isn't in the `Vec`,
149156
/// your software will panic! You cannot do this:
150157
///
151158
/// ```ignore
@@ -158,7 +165,7 @@ use super::range::RangeArgument;
158165
///
159166
/// # Slicing
160167
///
161-
/// A Vec can be mutable. Slices, on the other hand, are read-only objects.
168+
/// A `Vec` can be mutable. Slices, on the other hand, are read-only objects.
162169
/// To get a slice, use "&". Example:
163170
///
164171
/// ```
@@ -175,8 +182,8 @@ use super::range::RangeArgument;
175182
/// ```
176183
///
177184
/// In Rust, it's more common to pass slices as arguments rather than vectors
178-
/// when you just want to provide a read access. The same goes for String and
179-
/// &str.
185+
/// when you just want to provide a read access. The same goes for [`String`] and
186+
/// [`&str`].
180187
///
181188
/// # Capacity and reallocation
182189
///
@@ -191,7 +198,7 @@ use super::range::RangeArgument;
191198
/// with space for 10 more elements. Pushing 10 or fewer elements onto the
192199
/// vector will not change its capacity or cause reallocation to occur. However,
193200
/// if the vector's length is increased to 11, it will have to reallocate, which
194-
/// can be slow. For this reason, it is recommended to use `Vec::with_capacity`
201+
/// can be slow. For this reason, it is recommended to use [`Vec::with_capacity`]
195202
/// whenever possible to specify how big the vector is expected to get.
196203
///
197204
/// # Guarantees
@@ -209,65 +216,83 @@ use super::range::RangeArgument;
209216
/// The pointer will never be null, so this type is null-pointer-optimized.
210217
///
211218
/// However, the pointer may not actually point to allocated memory. In particular,
212-
/// if you construct a Vec with capacity 0 via `Vec::new()`, `vec![]`,
213-
/// `Vec::with_capacity(0)`, or by calling `shrink_to_fit()` on an empty Vec, it
214-
/// will not allocate memory. Similarly, if you store zero-sized types inside
215-
/// a Vec, it will not allocate space for them. *Note that in this case the
216-
/// Vec may not report a `capacity()` of 0*. Vec will allocate if and only
217-
/// if `mem::size_of::<T>() * capacity() > 0`. In general, Vec's allocation
219+
/// if you construct a Vec with capacity 0 via [`Vec::new()`], [`vec![]`][`vec!`],
220+
/// [`Vec::with_capacity(0)`][`Vec::with_capacity`], or by calling [`shrink_to_fit()`]
221+
/// on an empty Vec, it will not allocate memory. Similarly, if you store zero-sized
222+
/// types inside a `Vec`, it will not allocate space for them. *Note that in this case
223+
/// the `Vec` may not report a [`capacity()`] of 0*. Vec will allocate if and only
224+
/// if [`mem::size_of::<T>()`]` * capacity() > 0`. In general, `Vec`'s allocation
218225
/// details are subtle enough that it is strongly recommended that you only
219226
/// free memory allocated by a Vec by creating a new Vec and dropping it.
220227
///
221-
/// If a Vec *has* allocated memory, then the memory it points to is on the heap
228+
/// If a `Vec` *has* allocated memory, then the memory it points to is on the heap
222229
/// (as defined by the allocator Rust is configured to use by default), and its
223-
/// pointer points to `len()` initialized elements in order (what you would see
224-
/// if you coerced it to a slice), followed by `capacity() - len()` logically
225-
/// uninitialized elements.
230+
/// pointer points to [`len()`] initialized elements in order (what you would see
231+
/// if you coerced it to a slice), followed by `[capacity()][`capacity()`] -
232+
/// [len()][`len()`]` logically uninitialized elements.
226233
///
227-
/// Vec will never perform a "small optimization" where elements are actually
234+
/// `Vec` will never perform a "small optimization" where elements are actually
228235
/// stored on the stack for two reasons:
229236
///
230237
/// * It would make it more difficult for unsafe code to correctly manipulate
231-
/// a Vec. The contents of a Vec wouldn't have a stable address if it were
232-
/// only moved, and it would be more difficult to determine if a Vec had
238+
/// a `Vec`. The contents of a `Vec` wouldn't have a stable address if it were
239+
/// only moved, and it would be more difficult to determine if a `Vec` had
233240
/// actually allocated memory.
234241
///
235242
/// * It would penalize the general case, incurring an additional branch
236243
/// on every access.
237244
///
238-
/// Vec will never automatically shrink itself, even if completely empty. This
239-
/// ensures no unnecessary allocations or deallocations occur. Emptying a Vec
240-
/// and then filling it back up to the same `len()` should incur no calls to
241-
/// the allocator. If you wish to free up unused memory, use `shrink_to_fit`.
245+
/// `Vec` will never automatically shrink itself, even if completely empty. This
246+
/// ensures no unnecessary allocations or deallocations occur. Emptying a `Vec`
247+
/// and then filling it back up to the same [`len()`] should incur no calls to
248+
/// the allocator. If you wish to free up unused memory, use
249+
/// [`shrink_to_fit`][`shrink_to_fit()`].
242250
///
243-
/// `push` and `insert` will never (re)allocate if the reported capacity is
244-
/// sufficient. `push` and `insert` *will* (re)allocate if `len() == capacity()`.
245-
/// That is, the reported capacity is completely accurate, and can be relied on.
246-
/// It can even be used to manually free the memory allocated by a Vec if
247-
/// desired. Bulk insertion methods *may* reallocate, even when not necessary.
251+
/// [`push`] and [`insert`] will never (re)allocate if the reported capacity is
252+
/// sufficient. [`push`] and [`insert`] *will* (re)allocate if `[len()][`len()`]
253+
/// == [capacity()][`capacity()`]`. That is, the reported capacity is completely
254+
/// accurate, and can be relied on. It can even be used to manually free the memory
255+
/// allocated by a `Vec` if desired. Bulk insertion methods *may* reallocate, even
256+
/// when not necessary.
248257
///
249-
/// Vec does not guarantee any particular growth strategy when reallocating
250-
/// when full, nor when `reserve` is called. The current strategy is basic
258+
/// `Vec` does not guarantee any particular growth strategy when reallocating
259+
/// when full, nor when [`reserve`] is called. The current strategy is basic
251260
/// and it may prove desirable to use a non-constant growth factor. Whatever
252-
/// strategy is used will of course guarantee `O(1)` amortized `push`.
261+
/// strategy is used will of course guarantee `O(1)` amortized [`push`].
253262
///
254-
/// `vec![x; n]`, `vec![a, b, c, d]`, and `Vec::with_capacity(n)`, will all
255-
/// produce a Vec with exactly the requested capacity. If `len() == capacity()`,
256-
/// (as is the case for the `vec!` macro), then a `Vec<T>` can be converted
257-
/// to and from a `Box<[T]>` without reallocating or moving the elements.
263+
/// `vec![x; n]`, `vec![a, b, c, d]`, and
264+
/// [`Vec::with_capacity(n)`][`Vec::with_capacity`], will all
265+
/// produce a `Vec` with exactly the requested capacity. If `[len()][`len()`] ==
266+
/// [capacity()][`capacity()`]`, (as is the case for the [`vec!`] macro), then a
267+
/// `Vec<T>` can be converted to and from a [`Box<[T]>`] without reallocating or
268+
/// moving the elements.
258269
///
259-
/// Vec will not specifically overwrite any data that is removed from it,
270+
/// `Vec` will not specifically overwrite any data that is removed from it,
260271
/// but also won't specifically preserve it. Its uninitialized memory is
261272
/// scratch space that it may use however it wants. It will generally just do
262273
/// whatever is most efficient or otherwise easy to implement. Do not rely on
263-
/// removed data to be erased for security purposes. Even if you drop a Vec, its
264-
/// buffer may simply be reused by another Vec. Even if you zero a Vec's memory
274+
/// removed data to be erased for security purposes. Even if you drop a `Vec`, its
275+
/// buffer may simply be reused by another `Vec`. Even if you zero a `Vec`'s memory
265276
/// first, that may not actually happen because the optimizer does not consider
266277
/// this a side-effect that must be preserved.
267278
///
268-
/// Vec does not currently guarantee the order in which elements are dropped
279+
/// `Vec` does not currently guarantee the order in which elements are dropped
269280
/// (the order has changed in the past, and may change again).
270281
///
282+
/// [`vec!`]: ../../std/macro.vec.html
283+
/// [`Index`]: ../../std/ops/trait.Index.html
284+
/// [`String`]: ../../std/string/struct.String.html
285+
/// [`&str`]: ../../std/primitive.str.html
286+
/// [`Vec::with_capacity`]: ../../std/vec/struct.Vec.html#method.with_capacity
287+
/// [`Vec::new()`]: ../../std/vec/struct.Vec.html#method.new
288+
/// [`shrink_to_fit()`]: ../../std/vec/struct.Vec.html#method.shrink_to_fit
289+
/// [`capacity()`]: ../../std/vec/struct.Vec.html#method.capacity
290+
/// [`mem::size_of::<T>()`]: ../../std/mem/fn.size_of.html
291+
/// [`len()`]: ../../std/vec/struct.Vec.html#method.len
292+
/// [`push`]: ../../std/vec/struct.Vec.html#method.push
293+
/// [`insert`]: ../../std/vec/struct.Vec.html#method.insert
294+
/// [`reserve`]: ../../std/vec/struct.Vec.html#method.reserve
295+
/// [`Box<[T]>`]: ../../std/boxed/struct.Box.html
271296
#[stable(feature = "rust1", since = "1.0.0")]
272297
pub struct Vec<T> {
273298
buf: RawVec<T>,
@@ -340,7 +365,7 @@ impl<T> Vec<T> {
340365
/// This is highly unsafe, due to the number of invariants that aren't
341366
/// checked:
342367
///
343-
/// * `ptr` needs to have been previously allocated via `String`/`Vec<T>`
368+
/// * `ptr` needs to have been previously allocated via [`String`]/`Vec<T>`
344369
/// (at least, it's highly likely to be incorrect if it wasn't).
345370
/// * `length` needs to be less than or equal to `capacity`.
346371
/// * `capacity` needs to be the capacity that the pointer was allocated with.
@@ -354,6 +379,8 @@ impl<T> Vec<T> {
354379
/// that nothing else uses the pointer after calling this
355380
/// function.
356381
///
382+
/// [`String`]: ../../std/string/struct.String.html
383+
///
357384
/// # Examples
358385
///
359386
/// ```
@@ -470,11 +497,15 @@ impl<T> Vec<T> {
470497
self.buf.shrink_to_fit(self.len);
471498
}
472499

473-
/// Converts the vector into Box<[T]>.
500+
/// Converts the vector into [`Box<[T]>`].
474501
///
475502
/// Note that this will drop any excess capacity. Calling this and
476-
/// converting back to a vector with `into_vec()` is equivalent to calling
477-
/// `shrink_to_fit()`.
503+
/// converting back to a vector with [`into_vec()`] is equivalent to calling
504+
/// [`shrink_to_fit()`].
505+
///
506+
/// [`Box<[T]>`]: ../../std/boxed/struct.Box.html
507+
/// [`into_vec()`]: ../../std/primitive.slice.html#method.into_vec
508+
/// [`shrink_to_fit()`]: #method.shrink_to_fit
478509
///
479510
/// # Examples
480511
///
@@ -673,7 +704,7 @@ impl<T> Vec<T> {
673704
///
674705
/// # Panics
675706
///
676-
/// Panics if `index` is greater than the vector's length.
707+
/// Panics if `index` is out of bounds.
677708
///
678709
/// # Examples
679710
///
@@ -933,9 +964,11 @@ impl<T> Vec<T> {
933964
}
934965
}
935966

936-
/// Removes the last element from a vector and returns it, or `None` if it
967+
/// Removes the last element from a vector and returns it, or [`None`] if it
937968
/// is empty.
938969
///
970+
/// [`None`]: ../../std/option/enum.Option.html#variant.None
971+
///
939972
/// # Examples
940973
///
941974
/// ```

‎src/libcore/iter/iterator.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,9 @@ pub trait Iterator {
195195
last
196196
}
197197

198-
/// Consumes the `n` first elements of the iterator, then returns the
199-
/// `next()` one.
198+
/// Returns the `n`th element of the iterator.
200199
///
201-
/// This method will evaluate the iterator `n` times, discarding those elements.
202-
/// After it does so, it will call [`next()`] and return its value.
203-
///
204-
/// [`next()`]: #tymethod.next
200+
/// Note that all preceding elements will be consumed (i.e. discarded).
205201
///
206202
/// Like most indexing operations, the count starts from zero, so `nth(0)`
207203
/// returns the first value, `nth(1)` the second, and so on.

‎src/libcore/prelude/v1.rs

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,36 +18,50 @@
1818

1919
// Reexported core operators
2020
#[stable(feature = "core_prelude", since = "1.4.0")]
21-
#[doc(no_inline)] pub use marker::{Copy, Send, Sized, Sync};
21+
#[doc(no_inline)]
22+
pub use marker::{Copy, Send, Sized, Sync};
2223
#[stable(feature = "core_prelude", since = "1.4.0")]
23-
#[doc(no_inline)] pub use ops::{Drop, Fn, FnMut, FnOnce};
24+
#[doc(no_inline)]
25+
pub use ops::{Drop, Fn, FnMut, FnOnce};
2426

2527
// Reexported functions
2628
#[stable(feature = "core_prelude", since = "1.4.0")]
27-
#[doc(no_inline)] pub use mem::drop;
29+
#[doc(no_inline)]
30+
pub use mem::drop;
2831

2932
// Reexported types and traits
3033
#[stable(feature = "core_prelude", since = "1.4.0")]
31-
#[doc(no_inline)] pub use clone::Clone;
34+
#[doc(no_inline)]
35+
pub use clone::Clone;
3236
#[stable(feature = "core_prelude", since = "1.4.0")]
33-
#[doc(no_inline)] pub use cmp::{PartialEq, PartialOrd, Eq, Ord};
37+
#[doc(no_inline)]
38+
pub use cmp::{PartialEq, PartialOrd, Eq, Ord};
3439
#[stable(feature = "core_prelude", since = "1.4.0")]
35-
#[doc(no_inline)] pub use convert::{AsRef, AsMut, Into, From};
40+
#[doc(no_inline)]
41+
pub use convert::{AsRef, AsMut, Into, From};
3642
#[stable(feature = "core_prelude", since = "1.4.0")]
37-
#[doc(no_inline)] pub use default::Default;
43+
#[doc(no_inline)]
44+
pub use default::Default;
3845
#[stable(feature = "core_prelude", since = "1.4.0")]
39-
#[doc(no_inline)] pub use iter::{Iterator, Extend, IntoIterator};
46+
#[doc(no_inline)]
47+
pub use iter::{Iterator, Extend, IntoIterator};
4048
#[stable(feature = "core_prelude", since = "1.4.0")]
41-
#[doc(no_inline)] pub use iter::{DoubleEndedIterator, ExactSizeIterator};
49+
#[doc(no_inline)]
50+
pub use iter::{DoubleEndedIterator, ExactSizeIterator};
4251
#[stable(feature = "core_prelude", since = "1.4.0")]
43-
#[doc(no_inline)] pub use option::Option::{self, Some, None};
52+
#[doc(no_inline)]
53+
pub use option::Option::{self, Some, None};
4454
#[stable(feature = "core_prelude", since = "1.4.0")]
45-
#[doc(no_inline)] pub use result::Result::{self, Ok, Err};
55+
#[doc(no_inline)]
56+
pub use result::Result::{self, Ok, Err};
4657

4758
// Reexported extension traits for primitive types
4859
#[stable(feature = "core_prelude", since = "1.4.0")]
49-
#[doc(no_inline)] pub use slice::SliceExt;
60+
#[doc(no_inline)]
61+
pub use slice::SliceExt;
5062
#[stable(feature = "core_prelude", since = "1.4.0")]
51-
#[doc(no_inline)] pub use str::StrExt;
63+
#[doc(no_inline)]
64+
pub use str::StrExt;
5265
#[stable(feature = "core_prelude", since = "1.4.0")]
53-
#[doc(no_inline)] pub use char::CharExt;
66+
#[doc(no_inline)]
67+
pub use char::CharExt;

‎src/librustc_data_structures/graph/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ impl<'g, N: Debug, E: Debug> DepthFirstTraversal<'g, N, E> {
380380
graph: graph,
381381
stack: vec![],
382382
visited: visited,
383-
direction: direction
383+
direction: direction,
384384
}
385385
}
386386

@@ -394,7 +394,7 @@ impl<'g, N: Debug, E: Debug> DepthFirstTraversal<'g, N, E> {
394394
graph: graph,
395395
stack: vec![start_node],
396396
visited: visited,
397-
direction: direction
397+
direction: direction,
398398
}
399399
}
400400

‎src/librustc_typeck/diagnostics.rs

Lines changed: 101 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1915,6 +1915,45 @@ More details can be found in [RFC 438].
19151915
[RFC 438]: https://github.com/rust-lang/rfcs/pull/438
19161916
"##,
19171917

1918+
E0182: r##"
1919+
You bound an associated type in an expression path which is not
1920+
allowed.
1921+
1922+
Erroneous code example:
1923+
1924+
```compile_fail,E0182
1925+
trait Foo {
1926+
type A;
1927+
fn bar() -> isize;
1928+
}
1929+
1930+
impl Foo for isize {
1931+
type A = usize;
1932+
fn bar() -> isize { 42 }
1933+
}
1934+
1935+
// error: unexpected binding of associated item in expression path
1936+
let x: isize = Foo::<A=usize>::bar();
1937+
```
1938+
1939+
To give a concrete type when using the Universal Function Call Syntax,
1940+
use "Type as Trait". Example:
1941+
1942+
```
1943+
trait Foo {
1944+
type A;
1945+
fn bar() -> isize;
1946+
}
1947+
1948+
impl Foo for isize {
1949+
type A = usize;
1950+
fn bar() -> isize { 42 }
1951+
}
1952+
1953+
let x: isize = <isize as Foo>::bar(); // ok!
1954+
```
1955+
"##,
1956+
19181957
E0184: r##"
19191958
Explicitly implementing both Drop and Copy for a type is currently disallowed.
19201959
This feature can make some sense in theory, but the current implementation is
@@ -2752,6 +2791,30 @@ fn main() {
27522791
```
27532792
"##,
27542793

2794+
E0230: r##"
2795+
The trait has more type parameters specified than appear in its definition.
2796+
2797+
Erroneous example code:
2798+
2799+
```compile_fail,E0230
2800+
#![feature(on_unimplemented)]
2801+
#[rustc_on_unimplemented = "Trait error on `{Self}` with `<{A},{B},{C}>`"]
2802+
// error: there is no type parameter C on trait TraitWithThreeParams
2803+
trait TraitWithThreeParams<A,B>
2804+
{}
2805+
```
2806+
2807+
Include the correct number of type parameters and the compilation should
2808+
proceed:
2809+
2810+
```
2811+
#![feature(on_unimplemented)]
2812+
#[rustc_on_unimplemented = "Trait error on `{Self}` with `<{A},{B},{C}>`"]
2813+
trait TraitWithThreeParams<A,B,C> // ok!
2814+
{}
2815+
```
2816+
"##,
2817+
27552818
E0232: r##"
27562819
The attribute must have a value. Erroneous code example:
27572820
@@ -3587,6 +3650,44 @@ fn together_we_will_rule_the_galaxy(son: &A<i32>) {} // Ok!
35873650
```
35883651
"##,
35893652

3653+
E0399: r##"
3654+
You implemented a trait, overriding one or more of its associated types but did
3655+
not reimplement its default methods.
3656+
3657+
Example of erroneous code:
3658+
3659+
```compile_fail,E0399
3660+
#![feature(associated_type_defaults)]
3661+
3662+
pub trait Foo {
3663+
type Assoc = u8;
3664+
fn bar(&self) {}
3665+
}
3666+
3667+
impl Foo for i32 {
3668+
// error - the following trait items need to be reimplemented as
3669+
// `Assoc` was overridden: `bar`
3670+
type Assoc = i32;
3671+
}
3672+
```
3673+
3674+
To fix this, add an implementation for each default method from the trait:
3675+
3676+
```
3677+
#![feature(associated_type_defaults)]
3678+
3679+
pub trait Foo {
3680+
type Assoc = u8;
3681+
fn bar(&self) {}
3682+
}
3683+
3684+
impl Foo for i32 {
3685+
type Assoc = i32;
3686+
fn bar(&self) {} // ok!
3687+
}
3688+
```
3689+
"##,
3690+
35903691
E0439: r##"
35913692
The length of the platform-intrinsic function `simd_shuffle`
35923693
wasn't specified. Erroneous code example:
@@ -4074,7 +4175,6 @@ register_diagnostics! {
40744175
// E0168,
40754176
// E0173, // manual implementations of unboxed closure traits are experimental
40764177
// E0174,
4077-
E0182,
40784178
E0183,
40794179
// E0187, // can't infer the kind of the closure
40804180
// E0188, // can not cast an immutable reference to a mutable pointer
@@ -4098,7 +4198,6 @@ register_diagnostics! {
40984198
E0226, // only a single explicit lifetime bound is permitted
40994199
E0227, // ambiguous lifetime bound, explicit lifetime bound required
41004200
E0228, // explicit lifetime bound required
4101-
E0230, // there is no type parameter on trait
41024201
E0231, // only named substitution parameters are allowed
41034202
// E0233,
41044203
// E0234,
@@ -4120,8 +4219,6 @@ register_diagnostics! {
41204219
// E0372, // coherence not object safe
41214220
E0377, // the trait `CoerceUnsized` may only be implemented for a coercion
41224221
// between structures with the same definition
4123-
E0399, // trait items need to be implemented because the associated
4124-
// type `{}` was overridden
41254222
E0436, // functional record update requires a struct
41264223
E0521, // redundant default implementations of trait
41274224
E0533, // `{}` does not name a unit variant, unit struct or a constant

‎src/test/run-pass/auxiliary/check_static_recursion_foreign_helper.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
#![feature(libc)]
1414

15-
#[crate_id = "check_static_recursion_foreign_helper"]
16-
#[crate_type = "lib"]
15+
#![crate_name = "check_static_recursion_foreign_helper"]
16+
#![crate_type = "lib"]
1717

1818
extern crate libc;
1919

0 commit comments

Comments
 (0)
Please sign in to comment.