Skip to content

Commit ac67354

Browse files
committed
Auto merge of #26150 - steveklabnik:rollup, r=steveklabnik
- Successful merges: #26111, #26125, #26129, #26131, #26132, #26133, #26134, #26136, #26140, #26144 - Failed merges:
2 parents f06e026 + 6b6b380 commit ac67354

File tree

9 files changed

+47
-18
lines changed

9 files changed

+47
-18
lines changed

src/doc/reference.md

-1
Original file line numberDiff line numberDiff line change
@@ -1367,7 +1367,6 @@ Traits can include default implementations of methods, as in:
13671367
```
13681368
trait Foo {
13691369
fn bar(&self);
1370-
13711370
fn baz(&self) { println!("We called baz."); }
13721371
}
13731372
```

src/doc/trpl/const-and-static.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ unsafe {
6464

6565
[unsafe]: unsafe.html
6666

67-
Furthermore, any type stored in a `static` must be `Sync`.
67+
Furthermore, any type stored in a `static` must be `Sync`, and may not have
68+
a [`Drop`][drop] implementation.
69+
70+
[drop]: drop.html
6871

6972
# Initializing
7073

@@ -78,7 +81,3 @@ Almost always, if you can choose between the two, choose `const`. It’s pretty
7881
rare that you actually want a memory location associated with your constant,
7982
and using a const allows for optimizations like constant propagation not only
8083
in your crate but downstream crates.
81-
82-
A const can be thought of as a `#define` in C: it has metadata overhead but it
83-
has no runtime overhead. “Should I use a #define or a static in C,” is largely
84-
the same question as whether you should use a const or a static in Rust.

src/doc/trpl/dining-philosophers.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -674,9 +674,13 @@ let handles: Vec<_> = philosophers.into_iter().map(|p| {
674674

675675
Finally, inside of our `map()`/`collect()` loop, we call `table.clone()`. The
676676
`clone()` method on `Arc<T>` is what bumps up the reference count, and when it
677-
goes out of scope, it decrements the count. You’ll notice we can introduce a
678-
new binding to `table` here, and it will shadow the old one. This is often used
679-
so that you don’t need to come up with two unique names.
677+
goes out of scope, it decrements the count. This is needed so that we know how
678+
many references to `table` exist across our threads. If we didn’t have a count,
679+
we wouldn’t know how to deallocate it.
680+
681+
You’ll notice we can introduce a new binding to `table` here, and it will
682+
shadow the old one. This is often used so that you don’t need to come up with
683+
two unique names.
680684

681685
With this, our program works! Only two philosophers can eat at any one time,
682686
and so you’ll get some output like this:

src/doc/trpl/ffi.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,10 @@ Note that frameworks are only available on OSX targets.
342342
The different `kind` values are meant to differentiate how the native library
343343
participates in linkage. From a linkage perspective, the rust compiler creates
344344
two flavors of artifacts: partial (rlib/staticlib) and final (dylib/binary).
345-
Native dynamic libraries and frameworks are propagated to the final artifact
346-
boundary, while static libraries are not propagated at all.
345+
Native dynamic library and framework dependencies are propagated to the final
346+
artifact boundary, while static library dependencies are not propagated at
347+
all, because the static libraries are integrated directly into the subsequent
348+
artifact.
347349
348350
A few examples of how this model can be used are:
349351

src/doc/trpl/method-syntax.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ impl Circle {
8686
# Chaining method calls
8787

8888
So, now we know how to call a method, such as `foo.bar()`. But what about our
89-
original example, `foo.bar().baz()`? This is called ‘method chaining’, and we
90-
can do it by returning `self`.
89+
original example, `foo.bar().baz()`? This is called ‘method chaining’. Let’s
90+
look at an example:
9191

9292
```rust
9393
struct Circle {

src/doc/trpl/patterns.md

+25
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,31 @@ match x {
154154

155155
This prints `Got an int!`.
156156

157+
If you’re using `if` with multiple patterns, the `if` applies to both sides:
158+
159+
```rust
160+
let x = 4;
161+
let y = false;
162+
163+
match x {
164+
4 | 5 if y => println!("yes"),
165+
_ => println!("no"),
166+
}
167+
```
168+
169+
This prints `no`, because the `if` applies to the whole of `4 | 5`, and not to
170+
just the `5`, In other words, the the precedence of `if` behaves like this:
171+
172+
```text
173+
(4 | 5) if y => ...
174+
```
175+
176+
not this:
177+
178+
```text
179+
4 | (5 if y) => ...
180+
```
181+
157182
# ref and ref mut
158183

159184
If you want to get a [reference][ref], use the `ref` keyword:

src/doc/trpl/references-and-borrowing.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ As it turns out, there are rules.
151151

152152
Here’s the rules about borrowing in Rust:
153153

154-
First, any borrow must last for a smaller scope than the owner. Second, you may
155-
have one or the other of these two kinds of borrows, but not both at the same
156-
time:
154+
First, any borrow must last for a scope no greater than that of the owner.
155+
Second, you may have one or the other of these two kinds of borrows, but not
156+
both at the same time:
157157

158158
* one or more references (`&T`) to a resource.
159159
* exactly one mutable reference (`&mut T`)

src/librustc/middle/traits/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ implement `Convert` like so:
120120

121121
```rust
122122
impl Convert<uint> for int { ... } // int -> uint
123-
impl Convert<int> for uint { ... } // uint -> uint
123+
impl Convert<int> for uint { ... } // uint -> int
124124
```
125125

126126
Now imagine there is some code like the following:

src/libstd/sys/common/backtrace.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub const HEX_WIDTH: usize = 10;
2727
// 2. For each element of the path, emit the length plus the element
2828
// 3. End the path with "E"
2929
//
30-
// For example, "_ZN4testE" => "test" and "_ZN3foo3bar" => "foo::bar".
30+
// For example, "_ZN4testE" => "test" and "_ZN3foo3barE" => "foo::bar".
3131
//
3232
// We're the ones printing our backtraces, so we can't rely on anything else to
3333
// demangle our symbols. It's *much* nicer to look at demangled symbols, so

0 commit comments

Comments
 (0)