Skip to content

Rollup of 17 pull requests #25731

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions configure
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

msg() {
echo "configure: $1"
echo "configure: $*"
}

step_msg() {
Expand Down Expand Up @@ -33,8 +33,8 @@ need_ok() {

need_cmd() {
if command -v $1 >/dev/null 2>&1
then msg "found program $1"
else err "need program $1"
then msg "found program '$1'"
else err "program '$1' is missing, please install it"
fi
}

Expand Down Expand Up @@ -986,7 +986,7 @@ then
| cut -d ' ' -f 2)

case $CFG_CLANG_VERSION in
(3.2* | 3.3* | 3.4* | 3.5* | 3.6*)
(3.2* | 3.3* | 3.4* | 3.5* | 3.6* | 3.7*)
step_msg "found ok version of CLANG: $CFG_CLANG_VERSION"
if [ -z "$CC" ]
then
Expand Down
4 changes: 4 additions & 0 deletions src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -2003,6 +2003,10 @@ arbitrarily complex configurations through nesting.

The following configurations must be defined by the implementation:

* `debug_assertions`. Enabled by default when compiling without optimizations.
This can be used to enable extra debugging code in development but not in
production. For example, it controls the behavior of the standard library's
`debug_assert!` macro.
* `target_arch = "..."`. Target CPU architecture, such as `"x86"`, `"x86_64"`
`"mips"`, `"powerpc"`, `"arm"`, or `"aarch64"`.
* `target_endian = "..."`. Endianness of the target CPU, either `"little"` or
Expand Down
86 changes: 44 additions & 42 deletions src/doc/trpl/dining-philosophers.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,28 @@

For our second project, let’s look at a classic concurrency problem. It’s
called ‘the dining philosophers’. It was originally conceived by Dijkstra in
1965, but we’ll use the version from [this paper][paper] by Tony Hoare in 1985.
1965, but we’ll use a lightly adapted version from [this paper][paper] by Tony
Hoare in 1985.

[paper]: http://www.usingcsp.com/cspbook.pdf

> In ancient times, a wealthy philanthropist endowed a College to accommodate
> five eminent philosophers. Each philosopher had a room in which she could
> engage in her professional activity of thinking; there was also a common
> five eminent philosophers. Each philosopher had a room in which they could
> engage in their professional activity of thinking; there was also a common
> dining room, furnished with a circular table, surrounded by five chairs, each
> labelled by the name of the philosopher who was to sit in it. They sat
> anticlockwise around the table. To the left of each philosopher there was
> laid a golden fork, and in the centre stood a large bowl of spaghetti, which
> was constantly replenished. A philosopher was expected to spend most of her
> time thinking; but when she felt hungry, she went to the dining room, sat down
> in her own chair, picked up her own fork on her left, and plunged it into the
> spaghetti. But such is the tangled nature of spaghetti that a second fork is
> required to carry it to the mouth. The philosopher therefore had also to pick
> up the fork on her right. When she was finished she would put down both her
> forks, get up from her chair, and continue thinking. Of course, a fork can be
> used by only one philosopher at a time. If the other philosopher wants it, she
> just has to wait until the fork is available again.
> was constantly replenished. A philosopher was expected to spend most of
> their time thinking; but when they felt hungry, they went to the dining
> room, sat down in their own chair, picked up their own fork on their left,
> and plunged it into the spaghetti. But such is the tangled nature of
> spaghetti that a second fork is required to carry it to the mouth. The
> philosopher therefore had also to pick up the fork on their right. When
> they were finished they would put down both their forks, get up from their
> chair, and continue thinking. Of course, a fork can be used by only one
> philosopher at a time. If the other philosopher wants it, they just have
> to wait until the fork is available again.

This classic problem shows off a few different elements of concurrency. The
reason is that it's actually slightly tricky to implement: a simple
Expand Down Expand Up @@ -60,10 +62,10 @@ impl Philosopher {
}

fn main() {
let p1 = Philosopher::new("Baruch Spinoza");
let p1 = Philosopher::new("Judith Butler");
let p2 = Philosopher::new("Gilles Deleuze");
let p3 = Philosopher::new("Karl Marx");
let p4 = Philosopher::new("Friedrich Nietzsche");
let p4 = Philosopher::new("Emma Goldman");
let p5 = Philosopher::new("Michel Foucault");
}
```
Expand Down Expand Up @@ -159,10 +161,10 @@ look at `main()` again:
# }
#
fn main() {
let p1 = Philosopher::new("Baruch Spinoza");
let p1 = Philosopher::new("Judith Butler");
let p2 = Philosopher::new("Gilles Deleuze");
let p3 = Philosopher::new("Karl Marx");
let p4 = Philosopher::new("Friedrich Nietzsche");
let p4 = Philosopher::new("Emma Goldman");
let p5 = Philosopher::new("Michel Foucault");
}
```
Expand All @@ -176,10 +178,10 @@ that `new()` function, it would look like this:
# name: String,
# }
fn main() {
let p1 = Philosopher { name: "Baruch Spinoza".to_string() };
let p1 = Philosopher { name: "Judith Butler".to_string() };
let p2 = Philosopher { name: "Gilles Deleuze".to_string() };
let p3 = Philosopher { name: "Karl Marx".to_string() };
let p4 = Philosopher { name: "Friedrich Nietzche".to_string() };
let p4 = Philosopher { name: "Emma Goldman".to_string() };
let p5 = Philosopher { name: "Michel Foucault".to_string() };
}
```
Expand Down Expand Up @@ -211,10 +213,10 @@ impl Philosopher {

fn main() {
let philosophers = vec![
Philosopher::new("Baruch Spinoza"),
Philosopher::new("Judith Butler"),
Philosopher::new("Gilles Deleuze"),
Philosopher::new("Karl Marx"),
Philosopher::new("Friedrich Nietzsche"),
Philosopher::new("Emma Goldman"),
Philosopher::new("Michel Foucault"),
];

Expand Down Expand Up @@ -247,10 +249,10 @@ mention they’re done eating. Running this program should give you the followin
output:

```text
Baruch Spinoza is done eating.
Judith Butler is done eating.
Gilles Deleuze is done eating.
Karl Marx is done eating.
Friedrich Nietzsche is done eating.
Emma Goldman is done eating.
Michel Foucault is done eating.
```

Expand Down Expand Up @@ -285,10 +287,10 @@ impl Philosopher {

fn main() {
let philosophers = vec![
Philosopher::new("Baruch Spinoza"),
Philosopher::new("Judith Butler"),
Philosopher::new("Gilles Deleuze"),
Philosopher::new("Karl Marx"),
Philosopher::new("Friedrich Nietzsche"),
Philosopher::new("Emma Goldman"),
Philosopher::new("Michel Foucault"),
];

Expand Down Expand Up @@ -323,14 +325,14 @@ simulate the time it takes a philosopher to eat.
If you run this program, you should see each philosopher eat in turn:

```text
Baruch Spinoza is eating.
Baruch Spinoza is done eating.
Judith Butler is eating.
Judith Butler is done eating.
Gilles Deleuze is eating.
Gilles Deleuze is done eating.
Karl Marx is eating.
Karl Marx is done eating.
Friedrich Nietzsche is eating.
Friedrich Nietzsche is done eating.
Emma Goldman is eating.
Emma Goldman is done eating.
Michel Foucault is eating.
Michel Foucault is done eating.
```
Expand Down Expand Up @@ -366,10 +368,10 @@ impl Philosopher {

fn main() {
let philosophers = vec![
Philosopher::new("Baruch Spinoza"),
Philosopher::new("Judith Butler"),
Philosopher::new("Gilles Deleuze"),
Philosopher::new("Karl Marx"),
Philosopher::new("Friedrich Nietzsche"),
Philosopher::new("Emma Goldman"),
Philosopher::new("Michel Foucault"),
];

Expand Down Expand Up @@ -458,11 +460,11 @@ We have multi-threading!
```text
Gilles Deleuze is eating.
Gilles Deleuze is done eating.
Friedrich Nietzsche is eating.
Friedrich Nietzsche is done eating.
Emma Goldman is eating.
Emma Goldman is done eating.
Michel Foucault is eating.
Baruch Spinoza is eating.
Baruch Spinoza is done eating.
Judith Butler is eating.
Judith Butler is done eating.
Karl Marx is eating.
Karl Marx is done eating.
Michel Foucault is done eating.
Expand Down Expand Up @@ -532,10 +534,10 @@ fn main() {
]});

let philosophers = vec![
Philosopher::new("Baruch Spinoza", 0, 1),
Philosopher::new("Judith Butler", 0, 1),
Philosopher::new("Gilles Deleuze", 1, 2),
Philosopher::new("Karl Marx", 2, 3),
Philosopher::new("Friedrich Nietzsche", 3, 4),
Philosopher::new("Emma Goldman", 3, 4),
Philosopher::new("Michel Foucault", 0, 4),
];

Expand Down Expand Up @@ -643,10 +645,10 @@ count will go up, and when each thread ends, it will go back down.

```rust,ignore
let philosophers = vec![
Philosopher::new("Baruch Spinoza", 0, 1),
Philosopher::new("Judith Butler", 0, 1),
Philosopher::new("Gilles Deleuze", 1, 2),
Philosopher::new("Karl Marx", 2, 3),
Philosopher::new("Friedrich Nietzsche", 3, 4),
Philosopher::new("Emma Goldman", 3, 4),
Philosopher::new("Michel Foucault", 0, 4),
];
```
Expand Down Expand Up @@ -679,12 +681,12 @@ and so you’ll get some output like this:

```text
Gilles Deleuze is eating.
Friedrich Nietzsche is eating.
Friedrich Nietzsche is done eating.
Emma Goldman is eating.
Emma Goldman is done eating.
Gilles Deleuze is done eating.
Baruch Spinoza is eating.
Judith Butler is eating.
Karl Marx is eating.
Baruch Spinoza is done eating.
Judith Butler is done eating.
Michel Foucault is eating.
Karl Marx is done eating.
Michel Foucault is done eating.
Expand Down
2 changes: 1 addition & 1 deletion src/doc/trpl/guessing-game.md
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ When we wrote `let guess = String::new()`, Rust was able to infer that `guess`
should be a `String`, and so it doesn’t make us write out the type. And with
our `secret_number`, there are a number of types which can have a value
between one and a hundred: `i32`, a thirty-two-bit number, or `u32`, an
unsigned thirty-two-bit number, or `i64`, a sixty-four-bit number. Or others.
unsigned thirty-two-bit number, or `i64`, a sixty-four-bit number or others.
So far, that hasn’t mattered, and so Rust defaults to an `i32`. However, here,
Rust doesn’t know how to compare the `guess` and the `secret_number`. They
need to be the same type. Ultimately, we want to convert the `String` we
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
//! // At the end of the method, gadget_owner, gadget1 and gadget2 get
//! // destroyed. There are now no strong (`Rc<T>`) references to the gadgets.
//! // Once they get destroyed, the Gadgets get destroyed. This zeroes the
//! // reference count on Gadget Man, so he gets destroyed as well.
//! // reference count on Gadget Man, they get destroyed as well.
//! }
//! ```

Expand Down
5 changes: 2 additions & 3 deletions src/libcollections/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1110,9 +1110,8 @@ impl str {
/// such as leaving a combining character as the first code point of the
/// string.
///
/// Due to the design of UTF-8, this operation is `O(end)`. See `slice`,
/// `slice_to` and `slice_from` for `O(1)` variants that use byte indices
/// rather than code point indices.
/// Due to the design of UTF-8, this operation is `O(end)`. Use slicing
/// syntax if you want to use byte indices rather than codepoint indices.
///
/// # Panics
///
Expand Down
3 changes: 2 additions & 1 deletion src/libcollections/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
//! A growable list type with heap-allocated contents, written `Vec<T>` but
//! pronounced 'vector.'
//!
//! Vectors have `O(1)` indexing, push (to the end) and pop (from the end).
//! Vectors have `O(1)` indexing, amortized `O(1)` push (to the end) and
//! `O(1)` pop (from the end).
//!
//! # Examples
//!
Expand Down
Loading