Skip to content

Commit ea422eb

Browse files
committed
Auto merge of #29749 - steveklabnik:rollup, r=steveklabnik
- Successful merges: #29420, #29688, #29708, #29715, #29729, #29731 - Failed merges: #29544
2 parents 05b66b8 + 4b0503f commit ea422eb

File tree

6 files changed

+63
-24
lines changed

6 files changed

+63
-24
lines changed

README.md

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
# The Rust Programming Language
22

3-
Rust is a fast systems programming language that guarantees
4-
memory safety and offers painless concurrency ([no data races]).
5-
It does not employ a garbage collector and has minimal runtime overhead.
3+
This is the main source code repository for [Rust]. It contains the compiler, standard library,
4+
and documentation.
65

7-
This repo contains the code for the compiler (`rustc`), as well
8-
as standard libraries, tools and documentation for Rust.
9-
10-
[no data races]: http://blog.rust-lang.org/2015/04/10/Fearless-Concurrency.html
6+
[Rust]: https://www.rust-lang.org
117

128
## Quick Start
139

src/doc/trpl/dining-philosophers.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ also called a ‘vector’, and it’s a growable array type. We then use a
232232
[`for`][for] loop to iterate through the vector, getting a reference to each
233233
philosopher in turn.
234234

235-
[for]: for-loops.html
235+
[for]: loops.html#for
236236

237237
In the body of the loop, we call `p.eat()`, which is defined above:
238238

src/doc/trpl/documentation.md

+30
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,36 @@ we can add the `#[macro_use]` attribute. Second, we’ll need to add our own
373373
`main()` as well. Finally, a judicious use of `#` to comment out those two
374374
things, so they don’t show up in the output.
375375

376+
Another case where the use of `#` is handy is when you want to ignore
377+
error handling. Lets say you want the following,
378+
379+
```rust,ignore
380+
/// use std::io;
381+
/// let mut input = String::new();
382+
/// try!(io::stdin().read_line(&mut input));
383+
```
384+
385+
The problem is that `try!` returns a `Result<T, E>` and test functions
386+
don't return anything so this will give a mismatched types error.
387+
388+
```rust,ignore
389+
/// A doc test using try!
390+
///
391+
/// ```
392+
/// use std::io;
393+
/// # fn foo() -> io::Result<()> {
394+
/// let mut input = String::new();
395+
/// try!(io::stdin().read_line(&mut input));
396+
/// # Ok(())
397+
/// # }
398+
/// ```
399+
# fn foo() {}
400+
```
401+
402+
You can get around this by wrapping the code in a function. This catches
403+
and swallows the `Result<T, E>` when running tests on the docs. This
404+
pattern appears regularly in the standard library.
405+
376406
### Running documentation tests
377407

378408
To run the tests, either:

src/libcollections/vec.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1220,8 +1220,7 @@ impl<T> FromIterator<T> for Vec<T> {
12201220
// expanded on this iteration in every case when the iterable is not
12211221
// empty, but the loop in extend_desugared() is not going to see the
12221222
// vector being full in the few subsequent loop iterations.
1223-
// So we get better branch prediction and the possibility to
1224-
// construct the vector with initial estimated capacity.
1223+
// So we get better branch prediction.
12251224
let mut iterator = iterable.into_iter();
12261225
let mut vector = match iterator.next() {
12271226
None => return Vec::new(),

src/libcore/iter.rs

+13-14
Original file line numberDiff line numberDiff line change
@@ -371,22 +371,21 @@ pub trait Iterator {
371371
///
372372
/// # Implementation notes
373373
///
374-
/// It is not enforced that an iterator implementation yields the
375-
/// declared number of elements. A buggy iterator may yield less
376-
/// than the lower bound or more than the upper bound of elements.
374+
/// It is not enforced that an iterator implementation yields the declared
375+
/// number of elements. A buggy iterator may yield less than the lower bound
376+
/// or more than the upper bound of elements.
377377
///
378-
/// `size_hint()` is primarily intended to be used for optimizations
379-
/// such as reserving space for the elements of the iterator, but
380-
/// must not be trusted to e.g. omit bounds checks in unsafe code.
381-
/// An incorrect implementation of `size_hint()` should not lead to
382-
/// memory safety violations.
378+
/// `size_hint()` is primarily intended to be used for optimizations such as
379+
/// reserving space for the elements of the iterator, but must not be
380+
/// trusted to e.g. omit bounds checks in unsafe code. An incorrect
381+
/// implementation of `size_hint()` should not lead to memory safety
382+
/// violations.
383383
///
384-
/// That said, the implementation should provide a correct
385-
/// estimation, because otherwise it would be a violation of the
386-
/// trait's protocol.
384+
/// That said, the implementation should provide a correct estimation,
385+
/// because otherwise it would be a violation of the trait's protocol.
387386
///
388-
/// The default implementation returns `(0, None)` which is correct
389-
/// for any iterator.
387+
/// The default implementation returns `(0, None)` which is correct for any
388+
/// iterator.
390389
///
391390
/// # Examples
392391
///
@@ -2750,7 +2749,7 @@ pub trait ExactSizeIterator: Iterator {
27502749
/// implementation, you can do so. See the [trait-level] docs for an
27512750
/// example.
27522751
///
2753-
/// This function has the same safety guarantees as [`size_hint()`]
2752+
/// This function has the same safety guarantees as the [`size_hint()`]
27542753
/// function.
27552754
///
27562755
/// [trait-level]: trait.ExactSizeIterator.html

src/libstd/path.rs

+15
Original file line numberDiff line numberDiff line change
@@ -1013,6 +1013,21 @@ impl PathBuf {
10131013
/// * if `path` has a root but no prefix (e.g. `\windows`), it
10141014
/// replaces everything except for the prefix (if any) of `self`.
10151015
/// * if `path` has a prefix but no root, it replaces `self`.
1016+
///
1017+
/// # Examples
1018+
///
1019+
/// ```
1020+
/// use std::path::PathBuf;
1021+
///
1022+
/// let mut path = PathBuf::new();
1023+
/// path.push("/tmp");
1024+
/// path.push("file.bk");
1025+
/// assert_eq!(path, PathBuf::from("/tmp/file.bk"));
1026+
///
1027+
/// // Pushing an absolute path replaces the current path
1028+
/// path.push("/etc/passwd");
1029+
/// assert_eq!(path, PathBuf::from("/etc/passwd"));
1030+
/// ```
10161031
#[stable(feature = "rust1", since = "1.0.0")]
10171032
pub fn push<P: AsRef<Path>>(&mut self, path: P) {
10181033
self._push(path.as_ref())

0 commit comments

Comments
 (0)