Skip to content

Commit ca3900a

Browse files
committed
---
yaml --- r: 277613 b: refs/heads/try c: 676fd36 h: refs/heads/master i: 277611: b66b5ae
1 parent 1041cd3 commit ca3900a

File tree

193 files changed

+3844
-2747
lines changed

Some content is hidden

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

193 files changed

+3844
-2747
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 6dbb0e86aec11050480beb76eade6fb805010ba7
33
refs/heads/snap-stage3: 235d77457d80b549dad3ac36d94f235208a1eafb
4-
refs/heads/try: 237eb7285e5c2d47e4cfdb75116d9ad8e296a6f8
4+
refs/heads/try: 676fd362ff2face76a42cc73a25f3b554d5ed58d
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/src/doc/book/getting-started.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ we’ll talk about Cargo, Rust’s build system and package manager.
88

99
The first step to using Rust is to install it. Generally speaking, you’ll need
1010
an Internet connection to run the commands in this section, as we’ll be
11-
downloading Rust from the internet.
11+
downloading Rust from the Internet.
1212

1313
We’ll be showing off a number of commands using a terminal, and those lines all
1414
start with `$`. We don't need to type in the `$`s, they are there to indicate
@@ -399,13 +399,13 @@ Let’s convert the Hello World program to Cargo. To Cargo-fy a project, you nee
399399
to do three things:
400400

401401
1. Put your source file in the right directory.
402-
2. Get rid of the old executable (`main.exe` on Windows, `main` everywhere else)
403-
and make a new one.
402+
2. Get rid of the old executable (`main.exe` on Windows, `main` everywhere
403+
else).
404404
3. Make a Cargo configuration file.
405405

406406
Let's get started!
407407

408-
### Creating a new Executable and Source Directory
408+
### Creating a Source Directory and Removing the Old Executable
409409

410410
First, go back to your terminal, move to your *hello_world* directory, and
411411
enter the following commands:

branches/try/src/libcollections/fmt.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@
333333
//! precision := count | '*'
334334
//! type := identifier | ''
335335
//! count := parameter | integer
336-
//! parameter := integer '$'
336+
//! parameter := argument '$'
337337
//! ```
338338
//!
339339
//! # Formatting Parameters
@@ -403,11 +403,12 @@
403403
//! println!("Hello {:5}!", "x");
404404
//! println!("Hello {:1$}!", "x", 5);
405405
//! println!("Hello {1:0$}!", 5, "x");
406+
//! println!("Hello {:width$}!", "x", width = 5);
406407
//! ```
407408
//!
408409
//! Referring to an argument with the dollar syntax does not affect the "next
409-
//! argument" counter, so it's usually a good idea to refer to all arguments by
410-
//! their position explicitly.
410+
//! argument" counter, so it's usually a good idea to refer to arguments by
411+
//! position, or use named arguments.
411412
//!
412413
//! ## Precision
413414
//!
@@ -426,7 +427,7 @@
426427
//!
427428
//! the integer `N` itself is the precision.
428429
//!
429-
//! 2. An integer followed by dollar sign `.N$`:
430+
//! 2. An integer or name followed by dollar sign `.N$`:
430431
//!
431432
//! use format *argument* `N` (which must be a `usize`) as the precision.
432433
//!
@@ -456,6 +457,10 @@
456457
//! // Hello {next arg (x)} is {arg 2 (0.01) with precision
457458
//! // specified in its predecessor (5)}
458459
//! println!("Hello {} is {2:.*}", "x", 5, 0.01);
460+
//!
461+
//! // Hello {next arg (x)} is {arg "number" (0.01) with precision specified
462+
//! // in arg "prec" (5)}
463+
//! println!("Hello {} is {number:.prec$}", "x", prec = 5, number = 0.01);
459464
//! ```
460465
//!
461466
//! All print the same thing:

branches/try/src/libcore/intrinsics.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,8 @@ extern "rust-intrinsic" {
192192

193193
/// The size of a type in bytes.
194194
///
195-
/// This is the exact number of bytes in memory taken up by a
196-
/// value of the given type. In other words, a memset of this size
197-
/// would *exactly* overwrite a value. When laid out in vectors
198-
/// and structures there may be additional padding between
199-
/// elements.
195+
/// More specifically, this is the offset in bytes between successive
196+
/// items of the same type, including alignment padding.
200197
pub fn size_of<T>() -> usize;
201198

202199
/// Moves a value to an uninitialized memory location.

branches/try/src/libcore/mem.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ pub fn forget<T>(t: T) {
118118

119119
/// Returns the size of a type in bytes.
120120
///
121+
/// More specifically, this is the offset in bytes between successive
122+
/// items of the same type, including alignment padding.
123+
///
121124
/// # Examples
122125
///
123126
/// ```

branches/try/src/librustc/diagnostics.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,17 @@ fn foo(x: u8) -> u8 {
635635
```
636636
637637
It is advisable to find out what the unhandled cases are and check for them,
638-
returning an appropriate value or panicking if necessary.
638+
returning an appropriate value or panicking if necessary. Check if you need
639+
to remove a semicolon from the last expression, like in this case:
640+
641+
```ignore
642+
fn foo(x: u8) -> u8 {
643+
inner(2*x + 1);
644+
}
645+
```
646+
647+
The semicolon discards the return value of `inner`, instead of returning
648+
it from `foo`.
639649
"##,
640650

641651
E0270: r##"
@@ -1569,5 +1579,5 @@ register_diagnostics! {
15691579
E0490, // a value of type `..` is borrowed for too long
15701580
E0491, // in type `..`, reference has a longer lifetime than the data it...
15711581
E0495, // cannot infer an appropriate lifetime due to conflicting requirements
1572-
E0524, // expected a closure that implements `..` but this closure only implements `..`
1582+
E0525, // expected a closure that implements `..` but this closure only implements `..`
15731583
}

branches/try/src/librustc/infer/error_reporting.rs

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -249,12 +249,12 @@ pub trait ErrorReporting<'tcx> {
249249
terr: &TypeError<'tcx>)
250250
-> DiagnosticBuilder<'tcx>;
251251

252-
fn values_str(&self, values: &ValuePairs<'tcx>) -> Option<String>;
252+
fn values_str(&self, values: &ValuePairs<'tcx>) -> Option<(String, String)>;
253253

254254
fn expected_found_str<T: fmt::Display + Resolvable<'tcx> + TypeFoldable<'tcx>>(
255255
&self,
256256
exp_found: &ty::error::ExpectedFound<T>)
257-
-> Option<String>;
257+
-> Option<(String, String)>;
258258

259259
fn report_concrete_failure(&self,
260260
origin: SubregionOrigin<'tcx>,
@@ -535,7 +535,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
535535
trace: TypeTrace<'tcx>,
536536
terr: &TypeError<'tcx>)
537537
-> DiagnosticBuilder<'tcx> {
538-
let expected_found_str = match self.values_str(&trace.values) {
538+
let (expected, found) = match self.values_str(&trace.values) {
539539
Some(v) => v,
540540
None => {
541541
return self.tcx.sess.diagnostic().struct_dummy(); /* derived error */
@@ -548,18 +548,17 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
548548
false
549549
};
550550

551-
let expected_found_str = if is_simple_error {
552-
expected_found_str
553-
} else {
554-
format!("{} ({})", expected_found_str, terr)
555-
};
556-
557551
let mut err = struct_span_err!(self.tcx.sess,
558552
trace.origin.span(),
559553
E0308,
560-
"{}: {}",
561-
trace.origin,
562-
expected_found_str);
554+
"{}",
555+
trace.origin);
556+
557+
if !is_simple_error {
558+
err = err.note_expected_found(&"type", &expected, &found);
559+
}
560+
561+
err = err.span_label(trace.origin.span(), &terr);
563562

564563
self.check_and_note_conflicting_crates(&mut err, terr, trace.origin.span());
565564

@@ -574,6 +573,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
574573
},
575574
_ => ()
576575
}
576+
577577
err
578578
}
579579

@@ -631,7 +631,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
631631

632632
/// Returns a string of the form "expected `{}`, found `{}`", or None if this is a derived
633633
/// error.
634-
fn values_str(&self, values: &ValuePairs<'tcx>) -> Option<String> {
634+
fn values_str(&self, values: &ValuePairs<'tcx>) -> Option<(String, String)> {
635635
match *values {
636636
infer::Types(ref exp_found) => self.expected_found_str(exp_found),
637637
infer::TraitRefs(ref exp_found) => self.expected_found_str(exp_found),
@@ -642,7 +642,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
642642
fn expected_found_str<T: fmt::Display + Resolvable<'tcx> + TypeFoldable<'tcx>>(
643643
&self,
644644
exp_found: &ty::error::ExpectedFound<T>)
645-
-> Option<String>
645+
-> Option<(String, String)>
646646
{
647647
let expected = exp_found.expected.resolve(self);
648648
if expected.references_error() {
@@ -654,9 +654,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
654654
return None;
655655
}
656656

657-
Some(format!("expected `{}`, found `{}`",
658-
expected,
659-
found))
657+
Some((format!("{}", expected), format!("{}", found)))
660658
}
661659

662660
fn report_generic_bound_failure(&self,
@@ -684,10 +682,9 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
684682
E0309,
685683
"{} may not live long enough",
686684
labeled_user_string);
687-
err.fileline_help(origin.span(),
688-
&format!("consider adding an explicit lifetime bound `{}: {}`...",
689-
bound_kind,
690-
sub));
685+
err.help(&format!("consider adding an explicit lifetime bound `{}: {}`...",
686+
bound_kind,
687+
sub));
691688
err
692689
}
693690

@@ -698,10 +695,9 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
698695
E0310,
699696
"{} may not live long enough",
700697
labeled_user_string);
701-
err.fileline_help(origin.span(),
702-
&format!("consider adding an explicit lifetime \
703-
bound `{}: 'static`...",
704-
bound_kind));
698+
err.help(&format!("consider adding an explicit lifetime \
699+
bound `{}: 'static`...",
700+
bound_kind));
705701
err
706702
}
707703

@@ -712,9 +708,8 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
712708
E0311,
713709
"{} may not live long enough",
714710
labeled_user_string);
715-
err.fileline_help(origin.span(),
716-
&format!("consider adding an explicit lifetime bound for `{}`",
717-
bound_kind));
711+
err.help(&format!("consider adding an explicit lifetime bound for `{}`",
712+
bound_kind));
718713
self.tcx.note_and_explain_region(
719714
&mut err,
720715
&format!("{} must be valid for ", labeled_user_string),
@@ -1751,11 +1746,11 @@ impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> {
17511746
};
17521747

17531748
match self.values_str(&trace.values) {
1754-
Some(values_str) => {
1749+
Some((expected, found)) => {
17551750
err.span_note(
17561751
trace.origin.span(),
1757-
&format!("...so that {} ({})",
1758-
desc, values_str));
1752+
&format!("...so that {} (expected {}, found {})",
1753+
desc, expected, found));
17591754
}
17601755
None => {
17611756
// Really should avoid printing this error at

branches/try/src/librustc/lint/context.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -456,17 +456,13 @@ pub fn raw_struct_lint<'a>(sess: &'a Session,
456456
it will become a hard error in a future release!");
457457
let citation = format!("for more information, see {}",
458458
future_incompatible.reference);
459-
if let Some(sp) = span {
460-
err.fileline_warn(sp, &explanation);
461-
err.fileline_note(sp, &citation);
462-
} else {
463-
err.warn(&explanation);
464-
err.note(&citation);
465-
}
459+
err.warn(&explanation);
460+
err.note(&citation);
466461
}
467462

468463
if let Some(span) = def {
469-
err.span_note(span, "lint level defined here");
464+
let explanation = "lint level defined here";
465+
err.span_note(span, &explanation);
470466
}
471467

472468
err
@@ -542,7 +538,7 @@ pub trait LintContext: Sized {
542538
let mut err = self.lookup(lint, Some(span), msg);
543539
if self.current_level(lint) != Level::Allow {
544540
if note_span == span {
545-
err.fileline_note(note_span, note);
541+
err.note(note);
546542
} else {
547543
err.span_note(note_span, note);
548544
}

branches/try/src/librustc/session/config.rs

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ pub enum OptLevel {
4848
No, // -O0
4949
Less, // -O1
5050
Default, // -O2
51-
Aggressive // -O3
51+
Aggressive, // -O3
52+
Size, // -Os
53+
SizeMin, // -Oz
5254
}
5355

5456
#[derive(Clone, Copy, PartialEq)]
@@ -567,8 +569,8 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
567569
debuginfo: Option<usize> = (None, parse_opt_uint,
568570
"debug info emission level, 0 = no debug info, 1 = line tables only, \
569571
2 = full debug info with variable and type information"),
570-
opt_level: Option<usize> = (None, parse_opt_uint,
571-
"optimize with possible levels 0-3"),
572+
opt_level: Option<String> = (None, parse_opt_string,
573+
"optimize with possible levels 0-3, s, or z"),
572574
debug_assertions: Option<bool> = (None, parse_opt_bool,
573575
"explicitly enable the cfg(debug_assertions) directive"),
574576
inline_threshold: Option<usize> = (None, parse_opt_uint,
@@ -1125,13 +1127,20 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
11251127
}
11261128
OptLevel::Default
11271129
} else {
1128-
match cg.opt_level {
1129-
None => OptLevel::No,
1130-
Some(0) => OptLevel::No,
1131-
Some(1) => OptLevel::Less,
1132-
Some(2) => OptLevel::Default,
1133-
Some(3) => OptLevel::Aggressive,
1134-
Some(arg) => {
1130+
match (cg.opt_level.as_ref().map(String::as_ref),
1131+
nightly_options::is_nightly_build()) {
1132+
(None, _) => OptLevel::No,
1133+
(Some("0"), _) => OptLevel::No,
1134+
(Some("1"), _) => OptLevel::Less,
1135+
(Some("2"), _) => OptLevel::Default,
1136+
(Some("3"), _) => OptLevel::Aggressive,
1137+
(Some("s"), true) => OptLevel::Size,
1138+
(Some("z"), true) => OptLevel::SizeMin,
1139+
(Some("s"), false) | (Some("z"), false) => {
1140+
early_error(error_format, &format!("the optimizations s or z are only \
1141+
accepted on the nightly compiler"));
1142+
},
1143+
(Some(arg), _) => {
11351144
early_error(error_format, &format!("optimization level needs to be \
11361145
between 0-3 (instead was `{}`)",
11371146
arg));
@@ -1304,7 +1313,7 @@ pub mod nightly_options {
13041313
is_nightly_build() && matches.opt_strs("Z").iter().any(|x| *x == "unstable-options")
13051314
}
13061315

1307-
fn is_nightly_build() -> bool {
1316+
pub fn is_nightly_build() -> bool {
13081317
match get_unstable_features_setting() {
13091318
UnstableFeatures::Allow | UnstableFeatures::Cheat => true,
13101319
_ => false,

branches/try/src/librustc/session/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ pub fn early_error(output: config::ErrorOutputType, msg: &str) -> ! {
567567
}
568568
config::ErrorOutputType::Json => Box::new(JsonEmitter::basic()),
569569
};
570-
emitter.emit(None, msg, None, errors::Level::Fatal);
570+
emitter.emit(&MultiSpan::new(), msg, None, errors::Level::Fatal);
571571
panic!(errors::FatalError);
572572
}
573573

@@ -578,7 +578,7 @@ pub fn early_warn(output: config::ErrorOutputType, msg: &str) {
578578
}
579579
config::ErrorOutputType::Json => Box::new(JsonEmitter::basic()),
580580
};
581-
emitter.emit(None, msg, None, errors::Level::Warning);
581+
emitter.emit(&MultiSpan::new(), msg, None, errors::Level::Warning);
582582
}
583583

584584
// Err(0) means compilation was stopped, but no errors were found.

0 commit comments

Comments
 (0)