Skip to content

Commit 302b8a5

Browse files
committed
---
yaml --- r: 209579 b: refs/heads/try c: 1284be4 h: refs/heads/master i: 209577: 3c2f7e0 209575: 91efb32 v: v3
1 parent acff39e commit 302b8a5

File tree

192 files changed

+2506
-1167
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

192 files changed

+2506
-1167
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 3e561f05c00cd180ec02db4ccab2840a4aba93d2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: ba0e1cd8147d452c356aacb29fb87568ca26f111
5-
refs/heads/try: ed437cd8fcbb9ee89849a7eafff94ea97252189e
5+
refs/heads/try: 1284be4044420bc4c41767284ae26be61a38d331
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/src/compiletest/compiletest.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ pub fn make_metrics_test_closure(config: &Config, testfile: &Path) -> test::Test
368368
fn extract_gdb_version(full_version_line: Option<String>) -> Option<String> {
369369
match full_version_line {
370370
Some(ref full_version_line)
371-
if full_version_line.trim().len() > 0 => {
371+
if !full_version_line.trim().is_empty() => {
372372
let full_version_line = full_version_line.trim();
373373

374374
// used to be a regex "(^|[^0-9])([0-9]\.[0-9])([^0-9]|$)"
@@ -408,7 +408,7 @@ fn extract_lldb_version(full_version_line: Option<String>) -> Option<String> {
408408

409409
match full_version_line {
410410
Some(ref full_version_line)
411-
if full_version_line.trim().len() > 0 => {
411+
if !full_version_line.trim().is_empty() => {
412412
let full_version_line = full_version_line.trim();
413413

414414
for (pos, l) in full_version_line.char_indices() {
@@ -426,7 +426,7 @@ fn extract_lldb_version(full_version_line: Option<String>) -> Option<String> {
426426
let vers = full_version_line[pos + 5..].chars().take_while(|c| {
427427
c.is_digit(10)
428428
}).collect::<String>();
429-
if vers.len() > 0 { return Some(vers) }
429+
if !vers.is_empty() { return Some(vers) }
430430
}
431431
println!("Could not extract LLDB version from line '{}'",
432432
full_version_line);

branches/try/src/compiletest/runtest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ fn check_debugger_output(debugger_run_result: &ProcRes, check_lines: &[String])
864864
}
865865
first = false;
866866
}
867-
if !failed && rest.len() == 0 {
867+
if !failed && rest.is_empty() {
868868
i += 1;
869869
}
870870
if i == num_check_lines {
@@ -1662,7 +1662,7 @@ fn _arm_push_aux_shared_library(config: &Config, testfile: &Path) {
16621662
// codegen tests (vs. clang)
16631663

16641664
fn append_suffix_to_stem(p: &Path, suffix: &str) -> PathBuf {
1665-
if suffix.len() == 0 {
1665+
if suffix.is_empty() {
16661666
p.to_path_buf()
16671667
} else {
16681668
let mut stem = p.file_stem().unwrap().to_os_string();

branches/try/src/doc/complement-design-faq.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Types which are [`Sync`][sync] are thread-safe when multiple shared
5656
references to them are used concurrently. Types which are not `Sync` are not
5757
thread-safe, and thus when used in a global require unsafe code to use.
5858

59-
[sync]: core/kinds/trait.Sync.html
59+
[sync]: core/marker/trait.Sync.html
6060

6161
### If mutable static items that implement `Sync` are safe, why is taking &mut SHARABLE unsafe?
6262

@@ -139,7 +139,7 @@ and explicitly calling the `clone` method. Making user-defined copy operators
139139
explicit surfaces the underlying complexity, forcing the developer to opt-in
140140
to potentially expensive operations.
141141

142-
[copy]: core/kinds/trait.Copy.html
142+
[copy]: core/marker/trait.Copy.html
143143
[clone]: core/clone/trait.Clone.html
144144

145145
## No move constructors

branches/try/src/doc/reference.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2177,6 +2177,14 @@ The following configurations must be defined by the implementation:
21772177
* `unix`. See `target_family`.
21782178
* `windows`. See `target_family`.
21792179

2180+
You can also set another attribute based on a `cfg` variable with `cfg_attr`:
2181+
2182+
```rust,ignore
2183+
#[cfg_attr(a, b)]
2184+
```
2185+
2186+
Will be the same as `#[b]` if `a` is set by `cfg`, and nothing otherwise.
2187+
21802188
### Lint check attributes
21812189

21822190
A lint check names a potentially undesirable coding pattern, such as
@@ -2368,7 +2376,7 @@ The currently implemented features of the reference compiler are:
23682376
removed entirely for something more wholesome.
23692377

23702378
* `custom_attribute` - Allows the usage of attributes unknown to the compiler
2371-
so that new attributes can be added in a bacwards compatible
2379+
so that new attributes can be added in a backwards compatible
23722380
manner (RFC 572).
23732381

23742382
* `custom_derive` - Allows the use of `#[derive(Foo,Bar)]` as sugar for
@@ -2397,7 +2405,7 @@ The currently implemented features of the reference compiler are:
23972405
nasty hack that will certainly be removed.
23982406

23992407
* `main` - Allows use of the `#[main]` attribute, which changes the entry point
2400-
into a Rust program. This capabiilty is subject to change.
2408+
into a Rust program. This capability is subject to change.
24012409

24022410
* `macro_reexport` - Allows macros to be re-exported from one crate after being imported
24032411
from another. This feature was originally designed with the sole
@@ -2444,7 +2452,9 @@ The currently implemented features of the reference compiler are:
24442452
* `simd_ffi` - Allows use of SIMD vectors in signatures for foreign functions.
24452453
The SIMD interface is subject to change.
24462454

2447-
* `staged_api` - Allows usage of stability markers and `#![staged_api]` in a crate
2455+
* `staged_api` - Allows usage of stability markers and `#![staged_api]` in a
2456+
crate. Stability markers are also attributes: `#[stable]`,
2457+
`#[unstable]`, and `#[deprecated]` are the three levels.
24482458

24492459
* `static_assert` - The `#[static_assert]` functionality is experimental and
24502460
unstable. The attribute can be attached to a `static` of
@@ -2453,7 +2463,7 @@ The currently implemented features of the reference compiler are:
24532463
is unintuitive and suboptimal.
24542464

24552465
* `start` - Allows use of the `#[start]` attribute, which changes the entry point
2456-
into a Rust program. This capabiilty, especially the signature for the
2466+
into a Rust program. This capability, especially the signature for the
24572467
annotated function, is subject to change.
24582468

24592469
* `struct_inherit` - Allows using struct inheritance, which is barely
@@ -3788,7 +3798,7 @@ its type parameters are types:
37883798

37893799
```ignore
37903800
fn map<A: Clone, B: Clone>(f: |A| -> B, xs: &[A]) -> Vec<B> {
3791-
if xs.len() == 0 {
3801+
if xs.is_empty() {
37923802
return vec![];
37933803
}
37943804
let first: B = f(xs[0].clone());

branches/try/src/doc/trpl/closures.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,11 @@ you tons of control over what your code does, and closures are no different.
205205

206206
Rust's implementation of closures is a bit different than other languages. They
207207
are effectively syntax sugar for traits. You'll want to make sure to have read
208-
the [traits chapter][traits] before this one, as well as the chapter on [static
209-
and dynamic dispatch][dispatch], which talks about trait objects.
208+
the [traits chapter][traits] before this one, as well as the chapter on [trait
209+
objects][trait-objects].
210210

211211
[traits]: traits.html
212-
[dispatch]: static-and-dynamic-dispatch.html
212+
[trait-objects]: trait-objects.html
213213

214214
Got all that? Good.
215215

branches/try/src/doc/trpl/concurrency.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ Here's the error:
176176
^~~~~~~~~~~~~
177177
```
178178

179-
You see, [`Mutex`](std/sync/struct.Mutex.html) has a
180-
[`lock`](http://doc.rust-lang.org/nightly/std/sync/struct.Mutex.html#method.lock)
179+
You see, [`Mutex`](../std/sync/struct.Mutex.html) has a
180+
[`lock`](../std/sync/struct.Mutex.html#method.lock)
181181
method which has this signature:
182182

183183
```ignore

branches/try/src/doc/trpl/documentation.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,10 @@ $ rustdoc --test path/to/my/crate/root.rs
380380
$ cargo test
381381
```
382382

383-
That's right, `cargo test` tests embedded documentation too.
383+
That's right, `cargo test` tests embedded documentation too. However,
384+
`cargo test` will not test binary crates, only library ones. This is
385+
due to the way `rustdoc` works: it links against the library to be tested,
386+
but with a binary, there’s nothing to link to.
384387

385388
There are a few more annotations that are useful to help `rustdoc` do the right
386389
thing when testing your code:
@@ -560,3 +563,13 @@ This sets a few different options, with a logo, favicon, and a root URL.
560563
- `--html-before-content FILE`: includes the contents of FILE directly after
561564
`<body>`, before the rendered content (including the search bar).
562565
- `--html-after-content FILE`: includes the contents of FILE after all the rendered content.
566+
567+
## Security note
568+
569+
The Markdown in documentation comments is placed without processing into
570+
the final webpage. Be careful with literal HTML:
571+
572+
```rust
573+
/// <script>alert(document.cookie)</script>
574+
# fn foo() {}
575+
```

branches/try/src/doc/trpl/error-handling.md

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@ panic. A *failure* is an error that can be recovered from in some way. A
2020
*panic* is an error that cannot be recovered from.
2121

2222
What do we mean by "recover"? Well, in most cases, the possibility of an error
23-
is expected. For example, consider the `from_str` function:
23+
is expected. For example, consider the `parse` function:
2424

25-
```{rust,ignore}
26-
from_str("5");
25+
```ignore
26+
"5".parse();
2727
```
2828

29-
This function takes a string argument and converts it into another type. But
30-
because it's a string, you can't be sure that the conversion actually works.
31-
For example, what should this convert to?
29+
This method converts a string into another type. But because it's a string, you
30+
can't be sure that the conversion actually works. For example, what should this
31+
convert to?
3232

33-
```{rust,ignore}
34-
from_str("hello5world");
33+
```ignore
34+
"hello5world".parse();
3535
```
3636

3737
This won't work. So we know that this function will only work properly for some
@@ -40,7 +40,8 @@ inputs. It's expected behavior. We call this kind of error a *failure*.
4040
On the other hand, sometimes, there are errors that are unexpected, or which
4141
we cannot recover from. A classic example is an `assert!`:
4242

43-
```{rust,ignore}
43+
```rust
44+
# let x = 5;
4445
assert!(x == 5);
4546
```
4647

@@ -119,17 +120,19 @@ Rust calls these sorts of errors *panics*.
119120
# Handling errors with `Option` and `Result`
120121

121122
The simplest way to indicate that a function may fail is to use the `Option<T>`
122-
type. Remember our `from_str()` example? Here's its type signature:
123+
type. For example, the `find` method on strings attempts to find a pattern
124+
in a string, and returns an `Option`:
123125

124-
```{rust,ignore}
125-
pub fn from_str<A: FromStr>(s: &str) -> Option<A>
126+
```rust
127+
let s = "foo";
128+
129+
assert_eq!(s.find('f'), Some(0));
130+
assert_eq!(s.find('z'), None);
126131
```
127132

128-
`from_str()` returns an `Option<A>`. If the conversion succeeds, it will return
129-
`Some(value)`, and if it fails, it will return `None`.
130133

131134
This is appropriate for the simplest of cases, but doesn't give us a lot of
132-
information in the failure case. What if we wanted to know _why_ the conversion
135+
information in the failure case. What if we wanted to know _why_ the function
133136
failed? For this, we can use the `Result<T, E>` type. It looks like this:
134137

135138
```rust
@@ -297,5 +300,5 @@ It's worth noting that you can only use `try!` from a function that returns a
297300
`Result`, which means that you cannot use `try!` inside of `main()`, because
298301
`main()` doesn't return anything.
299302

300-
`try!` makes use of [`From<Error>`](../std/convert/trait.From.hml) to determine
303+
`try!` makes use of [`From<Error>`](../std/convert/trait.From.html) to determine
301304
what to return in the error case.

branches/try/src/doc/trpl/hello-cargo.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ we hadn’t changed the source file, and so it just ran the binary. If we had
8989
made a modification, we would have seen it do both:
9090

9191
```bash
92-
$ cargo build
92+
$ cargo run
9393
Compiling hello_world v0.0.1 (file:///home/yourname/projects/hello_world)
9494
Running `target/debug/hello_world`
9595
Hello, world!

branches/try/src/doc/trpl/installing-rust.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ If not, there are a number of places where you can get help. The easiest is
9191
[Mibbit][mibbit]. Click that link, and you'll be chatting with other Rustaceans
9292
(a silly nickname we call ourselves), and we can help you out. Other great
9393
resources include [the user’s forum][users], and
94-
[Stack Overflow][stack overflow].
94+
[Stack Overflow][stackoverflow].
9595

9696
[irc]: irc://irc.mozilla.org/#rust
9797
[mibbit]: http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust
9898
[users]: http://users.rust-lang.org/
99-
[stack overflow]: http://stackoverflow.com/questions/tagged/rust
99+
[stackoverflow]: http://stackoverflow.com/questions/tagged/rust

branches/try/src/doc/trpl/macros.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ mind.
3333
You may have seen the `vec!` macro, used to initialize a [vector][] with any
3434
number of elements.
3535

36-
[vector]: arrays-vectors-and-slices.html
36+
[vector]: vectors.html
3737

3838
```rust
3939
let x: Vec<u32> = vec![1, 2, 3];

branches/try/src/doc/trpl/primitive-types.md

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,18 @@ In systems programming languages, strings are a bit more complex than in other
216216
languages. For now, just read `&str` as a *string slice*, and we’ll learn more
217217
soon.
218218

219+
You can assign one tuple into another, if they have the same contained types
220+
and [arity]. Tuples have the same arity when they have the same length.
221+
222+
[arity]: glossary.html#arity
223+
224+
```rust
225+
let mut x = (1, 2); // x: (i32, i32)
226+
let y = (2, 3); // y: (i32, i32)
227+
228+
x = y;
229+
```
230+
219231
You can access the fields in a tuple through a *destructuring let*. Here’s
220232
an example:
221233

@@ -235,20 +247,24 @@ or "breaks up," the tuple, and assigns the bits to three bindings.
235247

236248
This pattern is very powerful, and we’ll see it repeated more later.
237249

238-
There are also a few things you can do with a tuple as a whole, without
239-
destructuring. You can assign one tuple into another, if they have the same
240-
contained types and [arity]. Tuples have the same arity when they have the same
241-
length.
250+
## Tuple Indexing
251+
252+
You can also access fields of a tuple with indexing syntax:
242253

243-
[arity]: glossary.html#arity
244254

245255
```rust
246-
let mut x = (1, 2); // x: (i32, i32)
247-
let y = (2, 3); // y: (i32, i32)
256+
let tuple = (1, 2, 3);
248257

249-
x = y;
258+
let x = tuple.0;
259+
let y = tuple.1;
260+
let z = tuple.2;
261+
262+
println!("x is {}", x);
250263
```
251264

265+
Like array indexing, it starts at zero, but unlike array indexing, it uses a
266+
`.`, rather than `[]`s.
267+
252268
You can find more documentation for tuples [in the standard library
253269
documentation][tuple].
254270

branches/try/src/doc/trpl/vectors.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
% Vectors
22

33
A *vector* is a dynamic or "growable" array, implemented as the standard
4-
library type [`Vec<T>`](../std/vec/) (Where `<T>` is a [Generic](./generics.md) statement). Vectors always allocate their data on the heap. Vectors are to slices
5-
what `String` is to `&str`. You can create them with the `vec!` macro:
4+
library type [`Vec<T>`](../std/vec/) (Where `<T>` is a [Generic](./generics.md)
5+
statement). Vectors always allocate their data on the heap. Vectors are to
6+
[slices][slices] what [`String`][string] is to `&str`. You can
7+
create them with the `vec!` macro:
68

79
```{rust}
810
let v = vec![1, 2, 3]; // v: Vec<i32>
911
```
1012

13+
[slices]: primitive-types.html#slices
14+
[string]: strings.html
15+
1116
(Notice that unlike the `println!` macro we've used in the past, we use square
1217
brackets `[]` with `vec!`. Rust allows you to use either in either situation,
1318
this is just convention.)

branches/try/src/libcollections/btree/map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ mod stack {
692692
// We've reached the root, so no matter what, we're done. We manually
693693
// access the root via the tree itself to avoid creating any dangling
694694
// pointers.
695-
if self.map.root.len() == 0 && !self.map.root.is_leaf() {
695+
if self.map.root.is_empty() && !self.map.root.is_leaf() {
696696
// We've emptied out the root, so make its only child the new root.
697697
// If it's a leaf, we just let it become empty.
698698
self.map.depth -= 1;

branches/try/src/libcollections/btree/node.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,9 @@ impl <K, V> Node<K, V> {
585585
self._len
586586
}
587587

588+
/// Does the node not contain any key-value pairs
589+
pub fn is_empty(&self) -> bool { self.len() == 0 }
590+
588591
/// How many key-value pairs the node can fit
589592
pub fn capacity(&self) -> usize {
590593
self._capacity
@@ -1097,7 +1100,7 @@ impl<K, V> Node<K, V> {
10971100
/// When a node has no keys or values and only a single edge, extract that edge.
10981101
pub fn hoist_lone_child(&mut self) {
10991102
// Necessary for correctness, but in a private module
1100-
debug_assert!(self.len() == 0);
1103+
debug_assert!(self.is_empty());
11011104
debug_assert!(!self.is_leaf());
11021105

11031106
unsafe {
@@ -1225,7 +1228,7 @@ impl<K, V> Node<K, V> {
12251228
/// because we have one too many, and our parent now has one too few
12261229
fn split(&mut self) -> (K, V, Node<K, V>) {
12271230
// Necessary for correctness, but in a private function
1228-
debug_assert!(self.len() > 0);
1231+
debug_assert!(!self.is_empty());
12291232

12301233
let mut right = if self.is_leaf() {
12311234
Node::new_leaf(self.capacity())

0 commit comments

Comments
 (0)