Skip to content

Commit 11bed09

Browse files
committed
---
yaml --- r: 271373 b: refs/heads/auto c: 6a3c7d5 h: refs/heads/master i: 271371: fb67570
1 parent ecd0556 commit 11bed09

File tree

7 files changed

+89
-49
lines changed

7 files changed

+89
-49
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
88
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
99
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1010
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
11-
refs/heads/auto: a5d9057ca7f7b08adef7cfecea2cc446ee47cb85
11+
refs/heads/auto: 6a3c7d563025eb0df856aebe320965a494052b89
1212
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1313
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336
1414
refs/tags/0.2: 1754d02027f2924bed83b0160ee340c7f41d5ea1

branches/auto/src/doc/book/error-handling.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,6 +2019,16 @@ impl Error for CliError {
20192019
CliError::NotFound => "not found",
20202020
}
20212021
}
2022+
2023+
fn cause(&self) -> Option<&error::Error> {
2024+
match *self {
2025+
CliError::Io(ref err) => Some(err),
2026+
CliError::Parse(ref err) => Some(err),
2027+
// Our custom error doesn't have an underlying cause, but we could
2028+
// modify it so that it does.
2029+
CliError::NotFound() => None,
2030+
}
2031+
}
20222032
}
20232033
```
20242034

branches/auto/src/doc/book/primitive-types.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ of these ones, as well, but these are the most primitive.
77

88
# Booleans
99

10-
Rust has a built in boolean type, named `bool`. It has two values, `true` and `false`:
10+
Rust has a built-in boolean type, named `bool`. It has two values, `true` and `false`:
1111

1212
```rust
1313
let x = true;
@@ -89,13 +89,13 @@ Unsigned types use a `u` for their category, and signed types use `i`. The `i`
8989
is for ‘integer’. So `u8` is an eight-bit unsigned number, and `i8` is an
9090
eight-bit signed number.
9191

92-
## Fixed size types
92+
## Fixed-size types
9393

94-
Fixed size types have a specific number of bits in their representation. Valid
94+
Fixed-size types have a specific number of bits in their representation. Valid
9595
bit sizes are `8`, `16`, `32`, and `64`. So, `u32` is an unsigned, 32-bit integer,
9696
and `i64` is a signed, 64-bit integer.
9797

98-
## Variable sized types
98+
## Variable-size types
9999

100100
Rust also provides types whose size depends on the size of a pointer of the
101101
underlying machine. These types have ‘size’ as the category, and come in signed

branches/auto/src/doc/book/references-and-borrowing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ fn main() {
212212

213213
In other words, the mutable borrow is held through the rest of our example. What
214214
we want is for the mutable borrow by `y` to end so that the resource can be
215-
returned to the owner, `x`. `x` can then provide a mutable borrow to `println!`.
215+
returned to the owner, `x`. `x` can then provide a immutable borrow to `println!`.
216216
In Rust, borrowing is tied to the scope that the borrow is valid for. And our
217217
scopes look like this:
218218

branches/auto/src/libcore/cmp.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,21 @@
1414
//! by the compiler to implement comparison operators. Rust programs may
1515
//! implement `PartialOrd` to overload the `<`, `<=`, `>`, and `>=` operators,
1616
//! and may implement `PartialEq` to overload the `==` and `!=` operators.
17+
//!
18+
//! # Examples
19+
//!
20+
//! ```
21+
//! let x: u32 = 0;
22+
//! let y: u32 = 1;
23+
//!
24+
//! // these two lines are equivalent
25+
//! assert_eq!(x < y, true);
26+
//! assert_eq!(x.lt(&y), true);
27+
//!
28+
//! // these two lines are also equivalent
29+
//! assert_eq!(x == y, false);
30+
//! assert_eq!(x.eq(&y), false);
31+
//! ```
1732
1833
#![stable(feature = "rust1", since = "1.0.0")]
1934

@@ -44,6 +59,16 @@ use option::Option::{self, Some};
4459
/// only if `a != b`.
4560
///
4661
/// This trait can be used with `#[derive]`.
62+
///
63+
/// # Examples
64+
///
65+
/// ```
66+
/// let x: u32 = 0;
67+
/// let y: u32 = 1;
68+
///
69+
/// assert_eq!(x == y, false);
70+
/// assert_eq!(x.eq(&y), false);
71+
/// ```
4772
#[lang = "eq"]
4873
#[stable(feature = "rust1", since = "1.0.0")]
4974
pub trait PartialEq<Rhs: ?Sized = Self> {
@@ -226,6 +251,16 @@ impl PartialOrd for Ordering {
226251
///
227252
/// This trait can be used with `#[derive]`. When `derive`d, it will produce an ordering
228253
/// based on the top-to-bottom declaration order of the struct's members.
254+
///
255+
/// # Examples
256+
///
257+
/// ```
258+
/// let x : u32 = 0;
259+
/// let y : u32 = 1;
260+
///
261+
/// assert_eq!(x < y, true);
262+
/// assert_eq!(x.lt(&y), true);
263+
/// ```
229264
#[lang = "ord"]
230265
#[stable(feature = "rust1", since = "1.0.0")]
231266
pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {

branches/auto/src/librustc_driver/lib.rs

Lines changed: 36 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ pub fn run_compiler<'a>(args: &[String],
157157
}
158158
}}
159159

160-
let matches = match handle_options(args.to_vec()) {
160+
let matches = match handle_options(args) {
161161
Some(matches) => matches,
162162
None => return (Ok(()), None),
163163
};
@@ -335,10 +335,10 @@ pub struct RustcDefaultCalls;
335335
fn handle_explain(code: &str,
336336
descriptions: &diagnostics::registry::Registry,
337337
output: ErrorOutputType) {
338-
let normalised = if !code.starts_with("E") {
339-
format!("E{0:0>4}", code)
340-
} else {
338+
let normalised = if code.starts_with("E") {
341339
code.to_string()
340+
} else {
341+
format!("E{0:0>4}", code)
342342
};
343343
match descriptions.find_description(&normalised) {
344344
Some(ref description) => {
@@ -870,9 +870,9 @@ fn print_flag_list<T>(cmdline_opt: &str,
870870
///
871871
/// So with all that in mind, the comments below have some more detail about the
872872
/// contortions done here to get things to work out correctly.
873-
pub fn handle_options(mut args: Vec<String>) -> Option<getopts::Matches> {
873+
pub fn handle_options(args: &[String]) -> Option<getopts::Matches> {
874874
// Throw away the first argument, the name of the binary
875-
let _binary = args.remove(0);
875+
let args = &args[1..];
876876

877877
if args.is_empty() {
878878
// user did not write `-v` nor `-Z unstable-options`, so do not
@@ -916,10 +916,10 @@ pub fn handle_options(mut args: Vec<String>) -> Option<getopts::Matches> {
916916
if opt.stability == OptionStability::Stable {
917917
continue
918918
}
919-
let opt_name = if !opt.opt_group.long_name.is_empty() {
920-
&opt.opt_group.long_name
921-
} else {
919+
let opt_name = if opt.opt_group.long_name.is_empty() {
922920
&opt.opt_group.short_name
921+
} else {
922+
&opt.opt_group.long_name
923923
};
924924
if !matches.opt_present(opt_name) {
925925
continue
@@ -1033,43 +1033,38 @@ pub fn monitor<F: FnOnce() + Send + 'static>(f: F) {
10331033
cfg = cfg.stack_size(STACK_SIZE);
10341034
}
10351035

1036-
match cfg.spawn(move || {
1037-
io::set_panic(box err);
1038-
f()
1039-
})
1040-
.unwrap()
1041-
.join() {
1042-
Ok(()) => {
1043-
// fallthrough
1044-
}
1045-
Err(value) => {
1046-
// Thread panicked without emitting a fatal diagnostic
1047-
if !value.is::<errors::FatalError>() {
1048-
let mut emitter = errors::emitter::BasicEmitter::stderr(errors::ColorConfig::Auto);
1049-
1050-
// a .span_bug or .bug call has already printed what
1051-
// it wants to print.
1052-
if !value.is::<errors::ExplicitBug>() {
1053-
emitter.emit(None, "unexpected panic", None, errors::Level::Bug);
1054-
}
1036+
let thread = cfg.spawn(move || {
1037+
io::set_panic(box err);
1038+
f()
1039+
});
10551040

1056-
let xs = ["the compiler unexpectedly panicked. this is a bug.".to_string(),
1057-
format!("we would appreciate a bug report: {}", BUG_REPORT_URL)];
1058-
for note in &xs {
1059-
emitter.emit(None, &note[..], None, errors::Level::Note)
1060-
}
1061-
if let None = env::var_os("RUST_BACKTRACE") {
1062-
emitter.emit(None,
1063-
"run with `RUST_BACKTRACE=1` for a backtrace",
1064-
None,
1065-
errors::Level::Note);
1066-
}
1041+
if let Err(value) = thread.unwrap().join() {
1042+
// Thread panicked without emitting a fatal diagnostic
1043+
if !value.is::<errors::FatalError>() {
1044+
let mut emitter = errors::emitter::BasicEmitter::stderr(errors::ColorConfig::Auto);
10671045

1068-
println!("{}", str::from_utf8(&data.lock().unwrap()).unwrap());
1046+
// a .span_bug or .bug call has already printed what
1047+
// it wants to print.
1048+
if !value.is::<errors::ExplicitBug>() {
1049+
emitter.emit(None, "unexpected panic", None, errors::Level::Bug);
10691050
}
10701051

1071-
exit_on_err();
1052+
let xs = ["the compiler unexpectedly panicked. this is a bug.".to_string(),
1053+
format!("we would appreciate a bug report: {}", BUG_REPORT_URL)];
1054+
for note in &xs {
1055+
emitter.emit(None, &note[..], None, errors::Level::Note)
1056+
}
1057+
if let None = env::var_os("RUST_BACKTRACE") {
1058+
emitter.emit(None,
1059+
"run with `RUST_BACKTRACE=1` for a backtrace",
1060+
None,
1061+
errors::Level::Note);
1062+
}
1063+
1064+
println!("{}", str::from_utf8(&data.lock().unwrap()).unwrap());
10721065
}
1066+
1067+
exit_on_err();
10731068
}
10741069
}
10751070

branches/auto/src/librustc_typeck/diagnostics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3167,8 +3167,8 @@ x <<= 2;
31673167
To fix this error, please check that this type implements this binary
31683168
operation. Example:
31693169
3170-
```compile_fail
3171-
let x = 12u32; // the `u32` type does implement the `ShlAssign` trait
3170+
```
3171+
let mut x = 12u32; // the `u32` type does implement the `ShlAssign` trait
31723172
31733173
x <<= 2; // ok!
31743174
```

0 commit comments

Comments
 (0)