Skip to content

Commit a267d6c

Browse files
authored
Auto merge of #34200 - sanxiyn:rollup, r=sanxiyn
Rollup of 12 pull requests - Successful merges: #34088, #34129, #34136, #34145, #34146, #34148, #34159, #34160, #34165, #34175, #34184, #34185 - Failed merges:
2 parents 68241f0 + 107d423 commit a267d6c

File tree

10 files changed

+349
-262
lines changed

10 files changed

+349
-262
lines changed

README.md

+8-6
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ build.
7575
$ pacman -Sy pacman-mirrors
7676
```
7777
78-
Download [MinGW from
79-
here](http://mingw-w64.org/doku.php/download/mingw-builds), and choose the
80-
`version=4.9.x,threads=win32,exceptions=dwarf/seh` flavor when installing. Also, make sure to install to a path without spaces in it. After installing,
81-
add its `bin` directory to your `PATH`. This is due to [#28260](https://github.com/rust-lang/rust/issues/28260), in the future,
82-
installing from pacman should be just fine.
78+
Download [MinGW from
79+
here](http://mingw-w64.org/doku.php/download/mingw-builds), and choose the
80+
`version=4.9.x,threads=win32,exceptions=dwarf/seh` flavor when installing. Also, make sure to install to a path without spaces in it. After installing,
81+
add its `bin` directory to your `PATH`. This is due to [#28260](https://github.com/rust-lang/rust/issues/28260), in the future,
82+
installing from pacman should be just fine.
8383
84-
```
84+
```sh
8585
# Make git available in MSYS2 (if not already available on path)
8686
$ pacman -S git
8787
@@ -90,6 +90,8 @@ installing from pacman should be just fine.
9090
9191
3. Run `mingw32_shell.bat` or `mingw64_shell.bat` from wherever you installed
9292
MSYS2 (i.e. `C:\msys`), depending on whether you want 32-bit or 64-bit Rust.
93+
(As of the latest version of MSYS2 you have to run `msys2_shell.cmd -mingw32`
94+
or `msys2_shell.cmd -mingw64` from the command line instead)
9395
9496
4. Navigate to Rust's source code, configure and build it:
9597

src/doc/book/error-handling.md

+8-12
Original file line numberDiff line numberDiff line change
@@ -1829,7 +1829,7 @@ use std::error::Error;
18291829
18301830
fn search<P: AsRef<Path>>
18311831
(file_path: P, city: &str)
1832-
-> Result<Vec<PopulationCount>, Box<Error+Send+Sync>> {
1832+
-> Result<Vec<PopulationCount>, Box<Error>> {
18331833
let mut found = vec![];
18341834
let file = try!(File::open(file_path));
18351835
let mut rdr = csv::Reader::from_reader(file);
@@ -1858,20 +1858,17 @@ Instead of `x.unwrap()`, we now have `try!(x)`. Since our function returns a
18581858
`Result<T, E>`, the `try!` macro will return early from the function if an
18591859
error occurs.
18601860

1861-
There is one big gotcha in this code: we used `Box<Error + Send + Sync>`
1862-
instead of `Box<Error>`. We did this so we could convert a plain string to an
1863-
error type. We need these extra bounds so that we can use the
1864-
[corresponding `From`
1865-
impls](../std/convert/trait.From.html):
1861+
At the end of `search` we also convert a plain string to an error type
1862+
by using the [corresponding `From` impls](../std/convert/trait.From.html):
18661863

18671864
```rust,ignore
18681865
// We are making use of this impl in the code above, since we call `From::from`
18691866
// on a `&'static str`.
1870-
impl<'a, 'b> From<&'b str> for Box<Error + Send + Sync + 'a>
1867+
impl<'a> From<&'a str> for Box<Error>
18711868
18721869
// But this is also useful when you need to allocate a new string for an
18731870
// error message, usually with `format!`.
1874-
impl From<String> for Box<Error + Send + Sync>
1871+
impl From<String> for Box<Error>
18751872
```
18761873

18771874
Since `search` now returns a `Result<T, E>`, `main` should use case analysis
@@ -1964,7 +1961,7 @@ use std::io;
19641961
19651962
fn search<P: AsRef<Path>>
19661963
(file_path: &Option<P>, city: &str)
1967-
-> Result<Vec<PopulationCount>, Box<Error+Send+Sync>> {
1964+
-> Result<Vec<PopulationCount>, Box<Error>> {
19681965
let mut found = vec![];
19691966
let input: Box<io::Read> = match *file_path {
19701967
None => Box::new(io::stdin()),
@@ -2175,9 +2172,8 @@ heuristics!
21752172
`unwrap`. Be warned: if it winds up in someone else's hands, don't be
21762173
surprised if they are agitated by poor error messages!
21772174
* If you're writing a quick 'n' dirty program and feel ashamed about panicking
2178-
anyway, then use either a `String` or a `Box<Error + Send + Sync>` for your
2179-
error type (the `Box<Error + Send + Sync>` type is because of the
2180-
[available `From` impls](../std/convert/trait.From.html)).
2175+
anyway, then use either a `String` or a `Box<Error>` for your
2176+
error type.
21812177
* Otherwise, in a program, define your own error types with appropriate
21822178
[`From`](../std/convert/trait.From.html)
21832179
and

0 commit comments

Comments
 (0)