Skip to content

Commit 4b79add

Browse files
committed
Auto merge of #27512 - Manishearth:rollup, r=Manishearth
- Successful merges: #27397, #27398, #27460, #27470, #27491, #27498, #27502 - Failed merges:
2 parents f971f86 + 614f640 commit 4b79add

File tree

9 files changed

+127
-79
lines changed

9 files changed

+127
-79
lines changed

RELEASES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Libraries
7979
are used by code generators to emit implementations of [`Debug`].
8080
* `str` has new [`to_uppercase`][strup] and [`to_lowercase`][strlow]
8181
methods that convert case, following Unicode case mapping.
82-
* It is now easier to handle to poisoned locks. The [`PoisonError`]
82+
* It is now easier to handle poisoned locks. The [`PoisonError`]
8383
type, returned by failing lock operations, exposes `into_inner`,
8484
`get_ref`, and `get_mut`, which all give access to the inner lock
8585
guard, and allow the poisoned lock to continue to operate. The

src/doc/trpl/guessing-game.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ use std::io;
9898

9999
We’ll need to take user input, and then print the result as output. As such, we
100100
need the `io` library from the standard library. Rust only imports a few things
101-
into every program, [the ‘prelude’][prelude]. If it’s not in the prelude,
102-
you’ll have to `use` it directly.
101+
by default into every program, [the ‘prelude’][prelude]. If it’s not in the
102+
prelude, you’ll have to `use` it directly.
103103

104104
[prelude]: ../std/prelude/index.html
105105

src/doc/trpl/hello-cargo.md

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ so it is assumed that Rust projects will use Cargo from the beginning.
88
[cratesio]: http://doc.crates.io
99

1010
Cargo manages three things: building your code, downloading the dependencies
11-
your code needs, and building those dependencies. At first, your
12-
program doesn’t have any dependencies, so we’ll only be using the first part of
13-
its functionality. Eventually, we’ll add more. Since we started off by using
14-
Cargo, it'll be easy to add later.
11+
your code needs, and building those dependencies. At first, your program doesn’t
12+
have any dependencies, so we’ll only be using the first part of its
13+
functionality. Eventually, we’ll add more. Since we started off by using Cargo,
14+
it'll be easy to add later.
1515

16-
If you installed Rust via the official installers you will also have Cargo. If
17-
you installed Rust some other way, you may want to [check the Cargo
16+
If we installed Rust via the official installers we will also have Cargo. If we
17+
installed Rust some other way, we may want to [check the Cargo
1818
README][cargoreadme] for specific instructions about installing it.
1919

2020
[cargoreadme]: https://github.com/rust-lang/cargo#installing-cargo-from-nightlies
@@ -23,20 +23,21 @@ README][cargoreadme] for specific instructions about installing it.
2323

2424
Let’s convert Hello World to Cargo.
2525

26-
To Cargo-ify our project, we need to do two things: Make a `Cargo.toml`
27-
configuration file, and put our source file in the right place. Let's
28-
do that part first:
26+
To Cargo-ify our project, we need to do three things: Make a `Cargo.toml`
27+
configuration file, put our source file in the right place, and get rid of the
28+
old executable (`main.exe` on Windows, `main` everywhere else). Let's do that part first:
2929

3030
```bash
3131
$ mkdir src
3232
$ mv main.rs src/main.rs
33+
$ rm main # or main.exe on Windows
3334
```
3435

35-
Note that since we're creating an executable, we used `main.rs`. If we
36-
want to make a library instead, we should use `lib.rs`. This convention is required
37-
for Cargo to successfully compile our projects, but it can be overridden if we wish.
38-
Custom file locations for the entry point can be specified
39-
with a [`[lib]` or `[[bin]]`][crates-custom] key in the TOML file.
36+
Note that since we're creating an executable, we retain `main.rs` as the source
37+
filename. If we want to make a library instead, we should use `lib.rs`. This
38+
convention is used by Cargo to successfully compile our projects, but it can be
39+
overridden if we wish. Custom file locations for the entry point can be
40+
specified with a [`[lib]` or `[[bin]]`][crates-custom] key in the TOML file.
4041

4142
[crates-custom]: http://doc.crates.io/manifest.html#configuring-a-target
4243

@@ -63,8 +64,8 @@ version = "0.0.1"
6364
authors = [ "Your name <[email protected]>" ]
6465
```
6566

66-
This file is in the [TOML][toml] format. TOML is similar to INI, but has some
67-
extra goodies. According to the TOML docs,
67+
This file is in the [TOML][toml] format. TOML is similar to INI, but has some
68+
extra goodies. According to the TOML docs,
6869

6970
> TOML aims to be a minimal configuration file format that's easy to read due
7071
> to obvious semantics. TOML is designed to map unambiguously to a hash table.
@@ -73,7 +74,8 @@ extra goodies. According to the TOML docs,
7374
7475
[toml]: https://github.com/toml-lang/toml
7576

76-
Once you have this file in place, we should be ready to build! To do so, run:
77+
Once we have this file in place in our project's root directory, we should be
78+
ready to build! To do so, run:
7779

7880
```bash
7981
$ cargo build

src/doc/trpl/patterns.md

Lines changed: 38 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -112,26 +112,55 @@ match x {
112112
}
113113
```
114114

115-
# Ignoring variants
115+
# Ignoring bindings
116116

117-
If you’re matching on an enum which has variants, you can use `..` to
118-
ignore the value and type in the variant:
117+
You can use `_` in a pattern to disregard the type and value.
118+
For example, here’s a `match` against a `Result<T, E>`:
119119

120120
```rust
121-
enum OptionalInt {
122-
Value(i32),
121+
# let some_value: Result<i32, &'static str> = Err("There was an error");
122+
match some_value {
123+
Ok(value) => println!("got a value: {}", value),
124+
Err(_) => println!("an error occurred"),
125+
}
126+
```
127+
128+
In the first arm, we bind the value inside the `Ok` variant to `value`. But
129+
in the `Err` arm, we use `_` to disregard the specific error, and just print
130+
a general error message.
131+
132+
`_` is valid in any pattern that creates a binding. This can be useful to
133+
ignore parts of a larger structure:
134+
135+
```rust
136+
fn coordinate() -> (i32, i32, i32) {
137+
// generate and return some sort of triple tuple
138+
# (1, 2, 3)
139+
}
140+
141+
let (x, _, z) = coordinate();
142+
```
143+
144+
Here, we bind the first and last element of the tuple to `x` and `z`, but
145+
ignore the middle element.
146+
147+
Similarly, you can use `..` in a pattern to disregard multiple values.
148+
149+
```rust
150+
enum OptionalTuple {
151+
Value(i32, i32, i32),
123152
Missing,
124153
}
125154

126-
let x = OptionalInt::Value(5);
155+
let x = OptionalTuple::Value(5, -2, 3);
127156

128157
match x {
129-
OptionalInt::Value(..) => println!("Got an int!"),
130-
OptionalInt::Missing => println!("No such luck."),
158+
OptionalTuple::Value(..) => println!("Got a tuple!"),
159+
OptionalTuple::Missing => println!("No such luck."),
131160
}
132161
```
133162

134-
This prints `Got an int!`.
163+
This prints `Got a tuple!`.
135164

136165
# Guards
137166

@@ -282,38 +311,6 @@ This ‘destructuring’ behavior works on any compound data type, like
282311
[tuples]: primitive-types.html#tuples
283312
[enums]: enums.html
284313

285-
# Ignoring bindings
286-
287-
You can use `_` in a pattern to disregard the value. For example, here’s a
288-
`match` against a `Result<T, E>`:
289-
290-
```rust
291-
# let some_value: Result<i32, &'static str> = Err("There was an error");
292-
match some_value {
293-
Ok(value) => println!("got a value: {}", value),
294-
Err(_) => println!("an error occurred"),
295-
}
296-
```
297-
298-
In the first arm, we bind the value inside the `Ok` variant to `value`. But
299-
in the `Err` arm, we use `_` to disregard the specific error, and just print
300-
a general error message.
301-
302-
`_` is valid in any pattern that creates a binding. This can be useful to
303-
ignore parts of a larger structure:
304-
305-
```rust
306-
fn coordinate() -> (i32, i32, i32) {
307-
// generate and return some sort of triple tuple
308-
# (1, 2, 3)
309-
}
310-
311-
let (x, _, z) = coordinate();
312-
```
313-
314-
Here, we bind the first and last element of the tuple to `x` and `z`, but
315-
ignore the middle element.
316-
317314
# Mix and Match
318315

319316
Whew! That’s a lot of different ways to match things, and they can all be

src/libcore/mem.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -322,20 +322,16 @@ pub unsafe fn dropped<T>() -> T {
322322
/// println!("{:?}", &data[0]);
323323
/// ```
324324
///
325-
/// Hopefully this example emphasizes to you exactly how delicate
326-
/// and dangerous doing this is. Note that the `vec!` macro
327-
/// *does* let you initialize every element with a value that
328-
/// is only `Clone`, so the following is equivalent and vastly
329-
/// less dangerous, as long as you can live with an extra heap
325+
/// This example emphasizes exactly how delicate and dangerous doing this is.
326+
/// Note that the `vec!` macro *does* let you initialize every element with a
327+
/// value that is only `Clone`, so the following is semantically equivalent and
328+
/// vastly less dangerous, as long as you can live with an extra heap
330329
/// allocation:
331330
///
332331
/// ```
333332
/// let data: Vec<Vec<u32>> = vec![Vec::new(); 1000];
334333
/// println!("{:?}", &data[0]);
335334
/// ```
336-
///
337-
/// For large arrays this is probably advisable
338-
/// anyway to avoid blowing the stack.
339335
#[inline]
340336
#[stable(feature = "rust1", since = "1.0.0")]
341337
pub unsafe fn uninitialized<T>() -> T {

src/librustc_resolve/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,8 @@ fn resolve_error<'b, 'a:'b, 'tcx:'a>(resolver: &'b Resolver<'a, 'tcx>, span: syn
313313
},
314314
ResolutionError::StructVariantUsedAsFunction(path_name) => {
315315
span_err!(resolver.session, span, E0423,
316-
"`{}` is a struct variant name, but \
317-
this expression \
316+
"`{}` is the name of a struct or struct variant, \
317+
but this expression \
318318
uses it like a function name",
319319
path_name);
320320
},

src/librustc_typeck/diagnostics.rs

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,63 @@ struct Foo { x: Option<Box<Foo>> }
826826
Now it's possible to create at least one instance of `Foo`: `Foo { x: None }`.
827827
"##,
828828

829+
E0074: r##"
830+
When using the `#[simd]` attribute on a tuple struct, the components of the
831+
tuple struct must all be of a concrete, nongeneric type so the compiler can
832+
reason about how to use SIMD with them. This error will occur if the types
833+
are generic.
834+
835+
```
836+
#[simd]
837+
struct Bad<T>(T, T, T); // This will cause an error
838+
839+
#[simd]
840+
struct Good(u32, u32, u32); // This will not
841+
```
842+
"##,
843+
844+
E0075: r##"
845+
The `#[simd]` attribute can only be applied to non empty tuple structs, because
846+
it doesn't make sense to try to use SIMD operations when there are no values to
847+
operate on.
848+
849+
```
850+
#[simd]
851+
struct Bad; // This will cause an error
852+
853+
#[simd]
854+
struct Good(u32); // This will not
855+
```
856+
"##,
857+
858+
E0076: r##"
859+
When using the `#[simd]` attribute to automatically use SIMD operations in tuple
860+
struct, the types in the struct must all be of the same type, or the compiler
861+
will trigger this error.
862+
863+
```
864+
#[simd]
865+
struct Bad(u16, u32, u32); // This will cause an error
866+
867+
#[simd]
868+
struct Good(u32, u32, u32); // This will not
869+
```
870+
871+
"##,
872+
873+
E0077: r##"
874+
When using the `#[simd]` attribute on a tuple struct, the elements in the tuple
875+
must be machine types so SIMD operations can be applied to them.
876+
877+
```
878+
#[simd]
879+
struct Bad(String); // This will cause an error
880+
881+
#[simd]
882+
struct Good(u32, u32, u32); // This will not
883+
```
884+
"##,
885+
829886
E0081: r##"
830887
Enum discriminants are used to differentiate enum variants stored in memory.
831888
This error indicates that the same value was used for two or more variants,
@@ -2378,10 +2435,6 @@ https://doc.rust-lang.org/std/marker/struct.PhantomData.html
23782435

23792436
register_diagnostics! {
23802437
E0068,
2381-
E0074,
2382-
E0075,
2383-
E0076,
2384-
E0077,
23852438
E0085,
23862439
E0086,
23872440
E0090,

src/libstd/prelude/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
//! The Rust Prelude
1212
//!
1313
//! Because `std` is required by most serious Rust software, it is
14-
//! imported at the topmost level of every crate by default, as if the
15-
//! first line of each crate was
14+
//! imported at the topmost level of every crate by default, as if
15+
//! each crate contains the following:
1616
//!
1717
//! ```ignore
1818
//! extern crate std;
@@ -23,7 +23,7 @@
2323
//! etc.
2424
//!
2525
//! Additionally, `std` contains a versioned *prelude* that reexports many of the
26-
//! most common traits, types and functions. *The contents of the prelude are
26+
//! most common traits, types, and functions. *The contents of the prelude are
2727
//! imported into every module by default*. Implicitly, all modules behave as if
2828
//! they contained the following [`use` statement][book-use]:
2929
//!

src/test/compile-fail/issue-6702.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ struct Monster {
1414

1515

1616
fn main() {
17-
let _m = Monster(); //~ ERROR `Monster` is a struct variant name, but
17+
let _m = Monster(); //~ ERROR `Monster` is the name of a struct or
1818
//~^ HELP did you mean to write: `Monster { /* fields */ }`?
1919
}

0 commit comments

Comments
 (0)