Skip to content

Commit c394706

Browse files
committed
Auto merge of #24349 - Manishearth:rollup, r=Manishearth
- Successful merges: #24072, #24233, #24321, #24339, #24341, #24342, #24347 - Failed merges:
2 parents 37cb1d4 + 72dc6fc commit c394706

File tree

6 files changed

+80
-18
lines changed

6 files changed

+80
-18
lines changed

src/doc/trpl/traits.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,8 @@ not, because both the trait and the type aren't in our crate.
273273

274274
One last thing about traits: generic functions with a trait bound use
275275
*monomorphization* (*mono*: one, *morph*: form), so they are statically
276-
dispatched. What's that mean? Check out the chapter on [static and dynamic
277-
dispatch](static-and-dynamic-dispatch.html) for more.
276+
dispatched. What's that mean? Check out the chapter on [trait
277+
objects](trait-objects.html) for more.
278278

279279
## Multiple trait bounds
280280

src/libcore/iter.rs

+6-14
Original file line numberDiff line numberDiff line change
@@ -2197,13 +2197,9 @@ impl<I> Iterator for Fuse<I> where I: Iterator {
21972197
if self.done {
21982198
None
21992199
} else {
2200-
match self.iter.next() {
2201-
None => {
2202-
self.done = true;
2203-
None
2204-
}
2205-
x => x
2206-
}
2200+
let next = self.iter.next();
2201+
self.done = next.is_none();
2202+
next
22072203
}
22082204
}
22092205

@@ -2224,13 +2220,9 @@ impl<I> DoubleEndedIterator for Fuse<I> where I: DoubleEndedIterator {
22242220
if self.done {
22252221
None
22262222
} else {
2227-
match self.iter.next_back() {
2228-
None => {
2229-
self.done = true;
2230-
None
2231-
}
2232-
x => x
2233-
}
2223+
let next = self.iter.next_back();
2224+
self.done = next.is_none();
2225+
next
22342226
}
22352227
}
22362228
}

src/libcore/num/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2705,7 +2705,7 @@ macro_rules! from_str_radix_float_impl {
27052705
///
27062706
/// # Return value
27072707
///
2708-
/// `Err(ParseIntError)` if the string did not represent a valid number. Otherwise,
2708+
/// `Err(ParseFloatError)` if the string did not represent a valid number.
27092709
/// Otherwise, `Ok(n)` where `n` is the floating-point number represented by `src`.
27102710
#[inline]
27112711
#[allow(deprecated)]
@@ -2734,7 +2734,7 @@ macro_rules! from_str_radix_float_impl {
27342734
///
27352735
/// # Return value
27362736
///
2737-
/// `Err(ParseIntError)` if the string did not represent a valid number. Otherwise,
2737+
/// `Err(ParseFloatError)` if the string did not represent a valid number.
27382738
/// Otherwise, `Ok(n)` where `n` is the floating-point number represented by `src`.
27392739
fn from_str_radix(src: &str, radix: u32)
27402740
-> Result<$T, ParseFloatError> {

src/test/run-pass/issue-16602-1.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn main() {
12+
let mut t = [1; 2];
13+
t = [t[1] * 2, t[0] * 2];
14+
assert_eq!(&t[..], &[2, 2]);
15+
}

src/test/run-pass/issue-16602-2.rs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
struct A {
12+
pub x: u32,
13+
pub y: u32,
14+
}
15+
16+
fn main() {
17+
let mut a = A { x: 1, y: 1 };
18+
a = A { x: a.y * 2, y: a.x * 2 };
19+
assert_eq!(a.x, 2);
20+
assert_eq!(a.y, 2);
21+
}

src/test/run-pass/issue-16602-3.rs

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#[derive(Debug)]
12+
enum Foo {
13+
Bar(u32, u32),
14+
Baz(&'static u32, &'static u32)
15+
}
16+
17+
static NUM: u32 = 100;
18+
19+
fn main () {
20+
let mut b = Foo::Baz(&NUM, &NUM);
21+
b = Foo::Bar(f(&b), g(&b));
22+
}
23+
24+
static FNUM: u32 = 1;
25+
26+
fn f (b: &Foo) -> u32 {
27+
FNUM
28+
}
29+
30+
static GNUM: u32 = 2;
31+
32+
fn g (b: &Foo) -> u32 {
33+
GNUM
34+
}

0 commit comments

Comments
 (0)