Skip to content

Commit 1903882

Browse files
committed
---
yaml --- r: 274709 b: refs/heads/stable c: 523fa13 h: refs/heads/master i: 274707: ee75745
1 parent a420103 commit 1903882

Some content is hidden

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

79 files changed

+1218
-731
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: c0221c8897db309a79990367476177b1230bb264
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: d66f3948f5955c47b57eced6b83eee95acb9764b
32+
refs/heads/stable: 523fa1331eda875136d3a980a5d51c7706f23f30
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e

branches/stable/mk/crates.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ DEPS_rustc_passes := syntax rustc core rustc_front
106106
DEPS_rustc_mir := rustc rustc_front syntax
107107
DEPS_rustc_resolve := arena rustc rustc_front log syntax
108108
DEPS_rustc_platform_intrinsics := rustc rustc_llvm
109-
DEPS_rustc_plugin := rustc rustc_metadata syntax
109+
DEPS_rustc_plugin := rustc rustc_metadata syntax rustc_mir
110110
DEPS_rustc_privacy := rustc rustc_front log syntax
111111
DEPS_rustc_trans := arena flate getopts graphviz libc rustc rustc_back rustc_mir \
112112
log syntax serialize rustc_llvm rustc_front rustc_platform_intrinsics

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

Lines changed: 45 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ fn map<F, T, A>(option: Option<T>, f: F) -> Option<A> where F: FnOnce(T) -> A {
265265
```
266266

267267
Indeed, `map` is [defined as a method][2] on `Option<T>` in the standard library.
268-
As a method, it has a slighly different signature: methods take `self`, `&self`,
268+
As a method, it has a slightly different signature: methods take `self`, `&self`,
269269
or `&mut self` as their first argument.
270270

271271
Armed with our new combinator, we can rewrite our `extension_explicit` method
@@ -1592,7 +1592,7 @@ fn print_usage(program: &str, opts: Options) {
15921592
15931593
fn main() {
15941594
let args: Vec<String> = env::args().collect();
1595-
let program = args[0].clone();
1595+
let program = &args[0];
15961596
15971597
let mut opts = Options::new();
15981598
opts.optflag("h", "help", "Show this usage message.");
@@ -1605,10 +1605,10 @@ fn main() {
16051605
print_usage(&program, opts);
16061606
return;
16071607
}
1608-
let data_path = args[1].clone();
1609-
let city = args[2].clone();
1608+
let data_path = &args[1];
1609+
let city = &args[2];
16101610
1611-
// Do stuff with information
1611+
// Do stuff with information
16121612
}
16131613
```
16141614

@@ -1640,7 +1640,6 @@ sure to add `extern crate csv;` to the top of your file.)
16401640

16411641
```rust,ignore
16421642
use std::fs::File;
1643-
use std::path::Path;
16441643
16451644
// This struct represents the data in each row of the CSV file.
16461645
// Type based decoding absolves us of a lot of the nitty gritty error
@@ -1666,7 +1665,7 @@ fn print_usage(program: &str, opts: Options) {
16661665
16671666
fn main() {
16681667
let args: Vec<String> = env::args().collect();
1669-
let program = args[0].clone();
1668+
let program = &args[0];
16701669
16711670
let mut opts = Options::new();
16721671
opts.optflag("h", "help", "Show this usage message.");
@@ -1678,25 +1677,24 @@ fn main() {
16781677
16791678
if matches.opt_present("h") {
16801679
print_usage(&program, opts);
1681-
return;
1682-
}
1680+
return;
1681+
}
16831682
1684-
let data_file = args[1].clone();
1685-
let data_path = Path::new(&data_file);
1686-
let city = args[2].clone();
1683+
let data_path = &args[1];
1684+
let city: &str = &args[2];
16871685
1688-
let file = File::open(data_path).unwrap();
1689-
let mut rdr = csv::Reader::from_reader(file);
1686+
let file = File::open(data_path).unwrap();
1687+
let mut rdr = csv::Reader::from_reader(file);
16901688
1691-
for row in rdr.decode::<Row>() {
1692-
let row = row.unwrap();
1689+
for row in rdr.decode::<Row>() {
1690+
let row = row.unwrap();
16931691
1694-
if row.city == city {
1695-
println!("{}, {}: {:?}",
1696-
row.city, row.country,
1697-
row.population.expect("population count"));
1698-
}
1699-
}
1692+
if row.city == city {
1693+
println!("{}, {}: {:?}",
1694+
row.city, row.country,
1695+
row.population.expect("population count"));
1696+
}
1697+
}
17001698
}
17011699
```
17021700

@@ -1745,6 +1743,8 @@ Note that we opt to handle the possibility of a missing population count by
17451743
simply ignoring that row.
17461744

17471745
```rust,ignore
1746+
use std::path::Path;
1747+
17481748
struct Row {
17491749
// unchanged
17501750
}
@@ -1782,27 +1782,26 @@ fn search<P: AsRef<Path>>(file_path: P, city: &str) -> Vec<PopulationCount> {
17821782
}
17831783
17841784
fn main() {
1785-
let args: Vec<String> = env::args().collect();
1786-
let program = args[0].clone();
1785+
let args: Vec<String> = env::args().collect();
1786+
let program = &args[0];
17871787
1788-
let mut opts = Options::new();
1789-
opts.optflag("h", "help", "Show this usage message.");
1788+
let mut opts = Options::new();
1789+
opts.optflag("h", "help", "Show this usage message.");
17901790
1791-
let matches = match opts.parse(&args[1..]) {
1792-
Ok(m) => { m }
1793-
Err(e) => { panic!(e.to_string()) }
1794-
};
1795-
if matches.opt_present("h") {
1796-
print_usage(&program, opts);
1797-
return;
1798-
}
1791+
let matches = match opts.parse(&args[1..]) {
1792+
Ok(m) => { m }
1793+
Err(e) => { panic!(e.to_string()) }
1794+
};
1795+
if matches.opt_present("h") {
1796+
print_usage(&program, opts);
1797+
return;
1798+
}
17991799
1800-
let data_file = args[1].clone();
1801-
let data_path = Path::new(&data_file);
1802-
let city = args[2].clone();
1803-
for pop in search(&data_path, &city) {
1804-
println!("{}, {}: {:?}", pop.city, pop.country, pop.count);
1805-
}
1800+
let data_path = &args[1];
1801+
let city = &args[2];
1802+
for pop in search(data_path, city) {
1803+
println!("{}, {}: {:?}", pop.city, pop.country, pop.count);
1804+
}
18061805
}
18071806
18081807
```
@@ -1912,7 +1911,7 @@ First, here's the new usage:
19121911

19131912
```rust,ignore
19141913
fn print_usage(program: &str, opts: Options) {
1915-
println!("{}", opts.usage(&format!("Usage: {} [options] <city>", program)));
1914+
println!("{}", opts.usage(&format!("Usage: {} [options] <city>", program)));
19161915
}
19171916
```
19181917
The next part is going to be only a little harder:
@@ -1924,16 +1923,16 @@ opts.optopt("f", "file", "Choose an input file, instead of using STDIN.", "NAME"
19241923
opts.optflag("h", "help", "Show this usage message.");
19251924
...
19261925
let file = matches.opt_str("f");
1927-
let data_file = file.as_ref().map(Path::new);
1926+
let data_file = &file.as_ref().map(Path::new);
19281927
19291928
let city = if !matches.free.is_empty() {
1930-
matches.free[0].clone()
1929+
&matches.free[0]
19311930
} else {
1932-
print_usage(&program, opts);
1933-
return;
1931+
print_usage(&program, opts);
1932+
return;
19341933
};
19351934
1936-
match search(&data_file, &city) {
1935+
match search(data_file, city) {
19371936
Ok(pops) => {
19381937
for pop in pops {
19391938
println!("{}, {}: {:?}", pop.city, pop.country, pop.count);

branches/stable/src/liballoc/arc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,9 +380,9 @@ impl<T: ?Sized> Deref for Arc<T> {
380380
}
381381

382382
impl<T: Clone> Arc<T> {
383-
/// Make a mutable reference into the given `Arc<T>` by cloning the inner
384-
/// data if the `Arc<T>` doesn't have one strong reference and no weak
385-
/// references.
383+
/// Make a mutable reference into the given `Arc<T>`.
384+
/// If the `Arc<T>` has more than one strong reference, or any weak
385+
/// references, the inner data is cloned.
386386
///
387387
/// This is also referred to as a copy-on-write.
388388
///

branches/stable/src/libbacktrace/ansidecl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* ANSI and traditional C compatability macros
1+
/* ANSI and traditional C compatibility macros
22
Copyright (C) 1991-2015 Free Software Foundation, Inc.
33
This file is part of the GNU C Library.
44

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
// }
2929
// ```
3030
//
31-
// Since Rust doesn't acutally have dependent types and polymorphic recursion,
31+
// Since Rust doesn't actually have dependent types and polymorphic recursion,
3232
// we make do with lots of unsafety.
3333

3434
use alloc::heap;

branches/stable/src/libcollections/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/",
2727
test(no_crate_inject, attr(allow(unused_variables), deny(warnings))))]
2828

29-
#![allow(trivial_casts)]
3029
#![cfg_attr(test, allow(deprecated))] // rand
3130
#![cfg_attr(not(stage0), deny(warnings))]
3231

branches/stable/src/libcollections/str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1808,7 +1808,7 @@ impl str {
18081808
// Σ maps to σ, except at the end of a word where it maps to ς.
18091809
// This is the only conditional (contextual) but language-independent mapping
18101810
// in `SpecialCasing.txt`,
1811-
// so hard-code it rather than have a generic "condition" mechanim.
1811+
// so hard-code it rather than have a generic "condition" mechanism.
18121812
// See https://github.com/rust-lang/rust/issues/26035
18131813
map_uppercase_sigma(self, i, &mut s)
18141814
} else {

branches/stable/src/libcollections/string.rs

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ use boxed::Box;
193193
/// mem::forget(story);
194194
///
195195
/// // We can re-build a String out of ptr, len, and capacity. This is all
196-
/// // unsafe becuase we are responsible for making sure the components are
196+
/// // unsafe because we are responsible for making sure the components are
197197
/// // valid:
198198
/// let s = unsafe { String::from_raw_parts(ptr as *mut _, len, capacity) } ;
199199
///
@@ -479,16 +479,15 @@ impl String {
479479
}
480480
}
481481

482-
/// Converts a slice of bytes to a `String`, including invalid characters.
482+
/// Converts a slice of bytes to a string, including invalid characters.
483483
///
484-
/// A string slice ([`&str`]) is made of bytes ([`u8`]), and a slice of
485-
/// bytes ([`&[u8]`][byteslice]) is made of bytes, so this function converts between
486-
/// the two. Not all byte slices are valid string slices, however: [`&str`]
487-
/// requires that it is valid UTF-8. During this conversion,
484+
/// Strings are made of bytes ([`u8`]), and a slice of bytes
485+
/// ([`&[u8]`][byteslice]) is made of bytes, so this function converts
486+
/// between the two. Not all byte slices are valid strings, however: strings
487+
/// are required to be valid UTF-8. During this conversion,
488488
/// `from_utf8_lossy()` will replace any invalid UTF-8 sequences with
489489
/// `U+FFFD REPLACEMENT CHARACTER`, which looks like this: �
490490
///
491-
/// [`&str`]: ../primitive.str.html
492491
/// [`u8`]: ../primitive.u8.html
493492
/// [byteslice]: ../primitive.slice.html
494493
///
@@ -499,10 +498,13 @@ impl String {
499498
///
500499
/// [`from_utf8_unchecked()`]: struct.String.html#method.from_utf8_unchecked
501500
///
502-
/// If you need a [`&str`] instead of a `String`, consider
503-
/// [`str::from_utf8()`].
501+
/// This function returns a [`Cow<'a, str>`]. If our byte slice is invalid
502+
/// UTF-8, then we need to insert the replacement characters, which will
503+
/// change the size of the string, and hence, require a `String`. But if
504+
/// it's already valid UTF-8, we don't need a new allocation. This return
505+
/// type allows us to handle both cases.
504506
///
505-
/// [`str::from_utf8()`]: ../str/fn.from_utf8.html
507+
/// [`Cow<'a, str>`]: ../borrow/enum.Cow.html
506508
///
507509
/// # Examples
508510
///
@@ -512,8 +514,7 @@ impl String {
512514
/// // some bytes, in a vector
513515
/// let sparkle_heart = vec![240, 159, 146, 150];
514516
///
515-
/// // We know these bytes are valid, so we'll use `unwrap()`.
516-
/// let sparkle_heart = String::from_utf8(sparkle_heart).unwrap();
517+
/// let sparkle_heart = String::from_utf8_lossy(&sparkle_heart);
517518
///
518519
/// assert_eq!("💖", sparkle_heart);
519520
/// ```
@@ -1841,6 +1842,12 @@ impl fmt::Write for String {
18411842
}
18421843

18431844
/// A draining iterator for `String`.
1845+
///
1846+
/// This struct is created by the [`drain()`] method on [`String`]. See its
1847+
/// documentation for more.
1848+
///
1849+
/// [`drain()`]: struct.String.html#method.drain
1850+
/// [`String`]: struct.String.html
18441851
#[stable(feature = "drain", since = "1.6.0")]
18451852
pub struct Drain<'a> {
18461853
/// Will be used as &'a mut String in the destructor

branches/stable/src/libcore/cmp.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,8 @@ impl Ordering {
165165
/// - total and antisymmetric: exactly one of `a < b`, `a == b` or `a > b` is true; and
166166
/// - transitive, `a < b` and `b < c` implies `a < c`. The same must hold for both `==` and `>`.
167167
///
168-
/// When this trait is `derive`d, it produces a lexicographic ordering.
169-
///
170-
/// This trait can be used with `#[derive]`.
168+
/// This trait can be used with `#[derive]`. When `derive`d, it will produce a lexicographic
169+
/// ordering based on the top-to-bottom declaration order of the struct's members.
171170
#[stable(feature = "rust1", since = "1.0.0")]
172171
pub trait Ord: Eq + PartialOrd<Self> {
173172
/// This method returns an `Ordering` between `self` and `other`.
@@ -225,7 +224,8 @@ impl PartialOrd for Ordering {
225224
/// total order. For example, for floating point numbers, `NaN < 0 == false` and `NaN >= 0 ==
226225
/// false` (cf. IEEE 754-2008 section 5.11).
227226
///
228-
/// This trait can be used with `#[derive]`.
227+
/// This trait can be used with `#[derive]`. When `derive`d, it will produce an ordering
228+
/// based on the top-to-bottom declaration order of the struct's members.
229229
#[lang = "ord"]
230230
#[stable(feature = "rust1", since = "1.0.0")]
231231
pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {

branches/stable/src/libcore/convert.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
//!
2020
//! - Impl the `As*` traits for reference-to-reference conversions
2121
//! - Impl the `Into` trait when you want to consume the value in the conversion
22-
//! - The `From` trait is the most flexible, usefull for values _and_ references conversions
22+
//! - The `From` trait is the most flexible, useful for values _and_ references conversions
2323
//!
2424
//! As a library writer, you should prefer implementing `From<T>` rather than
2525
//! `Into<U>`, as `From` provides greater flexibility and offer the equivalent `Into`

branches/stable/src/libcore/fmt/mod.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,26 +1414,20 @@ impl<T> Pointer for *const T {
14141414
#[stable(feature = "rust1", since = "1.0.0")]
14151415
impl<T> Pointer for *mut T {
14161416
fn fmt(&self, f: &mut Formatter) -> Result {
1417-
// FIXME(#23542) Replace with type ascription.
1418-
#![allow(trivial_casts)]
14191417
Pointer::fmt(&(*self as *const T), f)
14201418
}
14211419
}
14221420

14231421
#[stable(feature = "rust1", since = "1.0.0")]
14241422
impl<'a, T> Pointer for &'a T {
14251423
fn fmt(&self, f: &mut Formatter) -> Result {
1426-
// FIXME(#23542) Replace with type ascription.
1427-
#![allow(trivial_casts)]
14281424
Pointer::fmt(&(*self as *const T), f)
14291425
}
14301426
}
14311427

14321428
#[stable(feature = "rust1", since = "1.0.0")]
14331429
impl<'a, T> Pointer for &'a mut T {
14341430
fn fmt(&self, f: &mut Formatter) -> Result {
1435-
// FIXME(#23542) Replace with type ascription.
1436-
#![allow(trivial_casts)]
14371431
Pointer::fmt(&(&**self as *const T), f)
14381432
}
14391433
}

branches/stable/src/libcore/mem.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,5 @@ pub const POST_DROP_USIZE: usize = POST_DROP_U64 as usize;
578578
#[inline]
579579
#[stable(feature = "rust1", since = "1.0.0")]
580580
pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
581-
// FIXME(#23542) Replace with type ascription.
582-
#![allow(trivial_casts)]
583581
ptr::read(src as *const T as *const U)
584582
}

branches/stable/src/libcore/num/dec2flt/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,13 @@ from_str_float_impl!(f32);
149149
from_str_float_impl!(f64);
150150

151151
/// An error which can be returned when parsing a float.
152+
///
153+
/// This error is used as the error type for the [`FromStr`] implementation
154+
/// for [`f32`] and [`f64`].
155+
///
156+
/// [`FromStr`]: ../str/trait.FromStr.html
157+
/// [`f32`]: ../primitive.f32.html
158+
/// [`f64`]: ../primitive.f64.html
152159
#[derive(Debug, Clone, PartialEq)]
153160
#[stable(feature = "rust1", since = "1.0.0")]
154161
pub struct ParseFloatError {

0 commit comments

Comments
 (0)