Skip to content

Commit 5da602b

Browse files
committed
Auto merge of #33959 - Manishearth:rollup, r=Manishearth
Rollup of 8 pull requests - Successful merges: #33793, #33893, #33912, #33913, #33914, #33917, #33937, #33938 - Failed merges:
2 parents bf9c60c + 9d2ec40 commit 5da602b

File tree

26 files changed

+261
-104
lines changed

26 files changed

+261
-104
lines changed

src/liballoc/arc.rs

+13-9
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
use boxed::Box;
7373

7474
use core::sync::atomic;
75-
use core::sync::atomic::Ordering::{Relaxed, Release, Acquire, SeqCst};
75+
use core::sync::atomic::Ordering::{Acquire, Relaxed, Release, SeqCst};
7676
use core::borrow;
7777
use core::fmt;
7878
use core::cmp::Ordering;
@@ -85,7 +85,7 @@ use core::ops::CoerceUnsized;
8585
use core::ptr::{self, Shared};
8686
use core::marker::Unsize;
8787
use core::hash::{Hash, Hasher};
88-
use core::{usize, isize};
88+
use core::{isize, usize};
8989
use core::convert::From;
9090
use heap::deallocate;
9191

@@ -608,11 +608,13 @@ impl<T> Weak<T> {
608608
#[stable(feature = "downgraded_weak", since = "1.10.0")]
609609
pub fn new() -> Weak<T> {
610610
unsafe {
611-
Weak { ptr: Shared::new(Box::into_raw(box ArcInner {
612-
strong: atomic::AtomicUsize::new(0),
613-
weak: atomic::AtomicUsize::new(1),
614-
data: uninitialized(),
615-
}))}
611+
Weak {
612+
ptr: Shared::new(Box::into_raw(box ArcInner {
613+
strong: atomic::AtomicUsize::new(0),
614+
weak: atomic::AtomicUsize::new(1),
615+
data: uninitialized(),
616+
})),
617+
}
616618
}
617619
}
618620
}
@@ -655,7 +657,9 @@ impl<T: ?Sized> Weak<T> {
655657

656658
// See comments in `Arc::clone` for why we do this (for `mem::forget`).
657659
if n > MAX_REFCOUNT {
658-
unsafe { abort(); }
660+
unsafe {
661+
abort();
662+
}
659663
}
660664

661665
// Relaxed is valid for the same reason it is on Arc's Clone impl
@@ -946,7 +950,7 @@ mod tests {
946950
use std::mem::drop;
947951
use std::ops::Drop;
948952
use std::option::Option;
949-
use std::option::Option::{Some, None};
953+
use std::option::Option::{None, Some};
950954
use std::sync::atomic;
951955
use std::sync::atomic::Ordering::{Acquire, SeqCst};
952956
use std::thread;

src/liballoc/boxed.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ use core::hash::{self, Hash};
6464
use core::marker::{self, Unsize};
6565
use core::mem;
6666
use core::ops::{CoerceUnsized, Deref, DerefMut};
67-
use core::ops::{Placer, Boxed, Place, InPlace, BoxPlace};
67+
use core::ops::{BoxPlace, Boxed, InPlace, Place, Placer};
6868
use core::ptr::{self, Unique};
6969
use core::raw::TraitObject;
7070
use core::convert::From;
@@ -535,7 +535,8 @@ pub trait FnBox<A> {
535535

536536
#[unstable(feature = "fnbox",
537537
reason = "will be deprecated if and when Box<FnOnce> becomes usable", issue = "28796")]
538-
impl<A, F> FnBox<A> for F where F: FnOnce<A>
538+
impl<A, F> FnBox<A> for F
539+
where F: FnOnce<A>
539540
{
540541
type Output = F::Output;
541542

src/liballoc/boxed_test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
use core::any::Any;
1414
use core::ops::Deref;
15-
use core::result::Result::{Ok, Err};
15+
use core::result::Result::{Err, Ok};
1616
use core::clone::Clone;
1717

1818
use std::boxed::Box;

src/liballoc/heap.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
use core::{isize, usize};
1919
#[cfg(not(test))]
20-
use core::intrinsics::{size_of, min_align_of};
20+
use core::intrinsics::{min_align_of, size_of};
2121

2222
#[allow(improper_ctypes)]
2323
extern "C" {

src/liballoc/rc.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,11 @@ use core::borrow;
159159
use core::cell::Cell;
160160
use core::cmp::Ordering;
161161
use core::fmt;
162-
use core::hash::{Hasher, Hash};
163-
use core::intrinsics::{assume, abort};
162+
use core::hash::{Hash, Hasher};
163+
use core::intrinsics::{abort, assume};
164164
use core::marker;
165165
use core::marker::Unsize;
166-
use core::mem::{self, align_of_val, size_of_val, forget, uninitialized};
166+
use core::mem::{self, align_of_val, forget, size_of_val, uninitialized};
167167
use core::ops::Deref;
168168
use core::ops::CoerceUnsized;
169169
use core::ptr::{self, Shared};
@@ -935,7 +935,7 @@ mod tests {
935935
use std::boxed::Box;
936936
use std::cell::RefCell;
937937
use std::option::Option;
938-
use std::option::Option::{Some, None};
938+
use std::option::Option::{None, Some};
939939
use std::result::Result::{Err, Ok};
940940
use std::mem::drop;
941941
use std::clone::Clone;

src/libcollections/str.rs

+28-2
Original file line numberDiff line numberDiff line change
@@ -1097,8 +1097,34 @@ impl str {
10971097
/// assert_eq!(d, &["", "", "", "", "a", "", "b", "c"]);
10981098
/// ```
10991099
///
1100-
/// This can lead to possibly surprising behavior when whitespace is used
1101-
/// as the separator. This code is correct:
1100+
/// Contiguous separators are separated by the empty string.
1101+
///
1102+
/// ```
1103+
/// let x = "(///)".to_string();
1104+
/// let d: Vec<_> = x.split('/').collect();;
1105+
///
1106+
/// assert_eq!(d, &["(", "", "", ")"]);
1107+
/// ```
1108+
///
1109+
/// Separators at the start or end of a string are neighbored
1110+
/// by empty strings.
1111+
///
1112+
/// ```
1113+
/// let d: Vec<_> = "010".split("0").collect();
1114+
/// assert_eq!(d, &["", "1", ""]);
1115+
/// ```
1116+
///
1117+
/// When the empty string is used as a separator, it separates
1118+
/// every character in the string, along with the beginning
1119+
/// and end of the string.
1120+
///
1121+
/// ```
1122+
/// let f: Vec<_> = "rust".split("").collect();
1123+
/// assert_eq!(f, &["", "r", "u", "s", "t", ""]);
1124+
/// ```
1125+
///
1126+
/// Contiguous separators can lead to possibly surprising behavior
1127+
/// when whitespace is used as the separator. This code is correct:
11021128
///
11031129
/// ```
11041130
/// let x = " a b c".to_string();

src/librand/chacha.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
//! The ChaCha random number generator.
1212
13-
use {Rng, SeedableRng, Rand};
13+
use {Rand, Rng, SeedableRng};
1414

1515
const KEY_WORDS: usize = 8; // 8 words for the 256-bit key
1616
const STATE_WORDS: usize = 16;
@@ -216,7 +216,8 @@ mod tests {
216216
let s = ::test::rng().gen_iter::<u32>().take(8).collect::<Vec<u32>>();
217217
let mut ra: ChaChaRng = SeedableRng::from_seed(&*s);
218218
let mut rb: ChaChaRng = SeedableRng::from_seed(&*s);
219-
assert!(ra.gen_ascii_chars().take(100)
219+
assert!(ra.gen_ascii_chars()
220+
.take(100)
220221
.eq(rb.gen_ascii_chars().take(100)));
221222
}
222223

@@ -225,7 +226,8 @@ mod tests {
225226
let seed: &[_] = &[0, 1, 2, 3, 4, 5, 6, 7];
226227
let mut ra: ChaChaRng = SeedableRng::from_seed(seed);
227228
let mut rb: ChaChaRng = SeedableRng::from_seed(seed);
228-
assert!(ra.gen_ascii_chars().take(100)
229+
assert!(ra.gen_ascii_chars()
230+
.take(100)
229231
.eq(rb.gen_ascii_chars().take(100)));
230232
}
231233

src/librand/distributions/exponential.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
#[cfg(not(test))] // only necessary for no_std
1414
use FloatMath;
1515

16-
use {Rng, Rand};
17-
use distributions::{ziggurat, ziggurat_tables, Sample, IndependentSample};
16+
use {Rand, Rng};
17+
use distributions::{IndependentSample, Sample, ziggurat, ziggurat_tables};
1818

1919
/// A wrapper around an `f64` to generate Exp(1) random numbers.
2020
///
@@ -88,7 +88,7 @@ impl IndependentSample<f64> for Exp {
8888

8989
#[cfg(test)]
9090
mod tests {
91-
use distributions::{Sample, IndependentSample};
91+
use distributions::{IndependentSample, Sample};
9292
use super::Exp;
9393

9494
#[test]

src/librand/distributions/gamma.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ use self::ChiSquaredRepr::*;
1616
#[cfg(not(test))] // only necessary for no_std
1717
use FloatMath;
1818

19-
use {Rng, Open01};
19+
use {Open01, Rng};
2020
use super::normal::StandardNormal;
21-
use super::{IndependentSample, Sample, Exp};
21+
use super::{Exp, IndependentSample, Sample};
2222

2323
/// The Gamma distribution `Gamma(shape, scale)` distribution.
2424
///
@@ -291,8 +291,8 @@ impl IndependentSample<f64> for StudentT {
291291

292292
#[cfg(test)]
293293
mod tests {
294-
use distributions::{Sample, IndependentSample};
295-
use super::{ChiSquared, StudentT, FisherF};
294+
use distributions::{IndependentSample, Sample};
295+
use super::{ChiSquared, FisherF, StudentT};
296296

297297
#[test]
298298
fn test_chi_squared_one() {

src/librand/distributions/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ use core::num::Float;
2222

2323
use core::marker::PhantomData;
2424

25-
use {Rng, Rand};
25+
use {Rand, Rng};
2626

2727
pub use self::range::Range;
28-
pub use self::gamma::{Gamma, ChiSquared, FisherF, StudentT};
29-
pub use self::normal::{Normal, LogNormal};
28+
pub use self::gamma::{ChiSquared, FisherF, Gamma, StudentT};
29+
pub use self::normal::{LogNormal, Normal};
3030
pub use self::exponential::Exp;
3131

3232
pub mod range;
@@ -266,8 +266,8 @@ fn ziggurat<R: Rng, P, Z>(rng: &mut R,
266266

267267
#[cfg(test)]
268268
mod tests {
269-
use {Rng, Rand};
270-
use super::{RandSample, WeightedChoice, Weighted, Sample, IndependentSample};
269+
use {Rand, Rng};
270+
use super::{IndependentSample, RandSample, Sample, Weighted, WeightedChoice};
271271

272272
#[derive(PartialEq, Debug)]
273273
struct ConstRand(usize);

src/librand/distributions/normal.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
#[cfg(not(test))] // only necessary for no_std
1414
use FloatMath;
1515

16-
use {Rng, Rand, Open01};
17-
use distributions::{ziggurat, ziggurat_tables, Sample, IndependentSample};
16+
use {Open01, Rand, Rng};
17+
use distributions::{IndependentSample, Sample, ziggurat, ziggurat_tables};
1818

1919
/// A wrapper around an `f64` to generate N(0, 1) random numbers
2020
/// (a.k.a. a standard normal, or Gaussian).
@@ -145,8 +145,8 @@ impl IndependentSample<f64> for LogNormal {
145145

146146
#[cfg(test)]
147147
mod tests {
148-
use distributions::{Sample, IndependentSample};
149-
use super::{Normal, LogNormal};
148+
use distributions::{IndependentSample, Sample};
149+
use super::{LogNormal, Normal};
150150

151151
#[test]
152152
fn test_normal() {

src/librand/distributions/range.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
use core::marker::Sized;
1616
use Rng;
17-
use distributions::{Sample, IndependentSample};
17+
use distributions::{IndependentSample, Sample};
1818

1919
/// Sample values uniformly between two bounds.
2020
///
@@ -148,7 +148,7 @@ float_impl! { f64 }
148148

149149
#[cfg(test)]
150150
mod tests {
151-
use distributions::{Sample, IndependentSample};
151+
use distributions::{IndependentSample, Sample};
152152
use super::Range;
153153

154154
#[should_panic]

src/librand/isaac.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use core::slice;
1616
use core::iter::repeat;
1717
use core::num::Wrapping as w;
1818

19-
use {Rng, SeedableRng, Rand};
19+
use {Rand, Rng, SeedableRng};
2020

2121
type w32 = w<u32>;
2222
type w64 = w<u64>;
@@ -591,22 +591,24 @@ mod tests {
591591
use std::prelude::v1::*;
592592

593593
use {Rng, SeedableRng};
594-
use super::{IsaacRng, Isaac64Rng};
594+
use super::{Isaac64Rng, IsaacRng};
595595

596596
#[test]
597597
fn test_rng_32_rand_seeded() {
598598
let s = ::test::rng().gen_iter::<u32>().take(256).collect::<Vec<u32>>();
599599
let mut ra: IsaacRng = SeedableRng::from_seed(&s[..]);
600600
let mut rb: IsaacRng = SeedableRng::from_seed(&s[..]);
601-
assert!(ra.gen_ascii_chars().take(100)
601+
assert!(ra.gen_ascii_chars()
602+
.take(100)
602603
.eq(rb.gen_ascii_chars().take(100)));
603604
}
604605
#[test]
605606
fn test_rng_64_rand_seeded() {
606607
let s = ::test::rng().gen_iter::<u64>().take(256).collect::<Vec<u64>>();
607608
let mut ra: Isaac64Rng = SeedableRng::from_seed(&s[..]);
608609
let mut rb: Isaac64Rng = SeedableRng::from_seed(&s[..]);
609-
assert!(ra.gen_ascii_chars().take(100)
610+
assert!(ra.gen_ascii_chars()
611+
.take(100)
610612
.eq(rb.gen_ascii_chars().take(100)));
611613
}
612614

@@ -615,15 +617,17 @@ mod tests {
615617
let seed: &[_] = &[1, 23, 456, 7890, 12345];
616618
let mut ra: IsaacRng = SeedableRng::from_seed(seed);
617619
let mut rb: IsaacRng = SeedableRng::from_seed(seed);
618-
assert!(ra.gen_ascii_chars().take(100)
620+
assert!(ra.gen_ascii_chars()
621+
.take(100)
619622
.eq(rb.gen_ascii_chars().take(100)));
620623
}
621624
#[test]
622625
fn test_rng_64_seeded() {
623626
let seed: &[_] = &[1, 23, 456, 7890, 12345];
624627
let mut ra: Isaac64Rng = SeedableRng::from_seed(seed);
625628
let mut rb: Isaac64Rng = SeedableRng::from_seed(seed);
626-
assert!(ra.gen_ascii_chars().take(100)
629+
assert!(ra.gen_ascii_chars()
630+
.take(100)
627631
.eq(rb.gen_ascii_chars().take(100)));
628632
}
629633

src/librand/lib.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ use core::f64;
4747
use core::intrinsics;
4848
use core::marker::PhantomData;
4949

50-
pub use isaac::{IsaacRng, Isaac64Rng};
50+
pub use isaac::{Isaac64Rng, IsaacRng};
5151
pub use chacha::ChaChaRng;
5252

53-
use distributions::{Range, IndependentSample};
53+
use distributions::{IndependentSample, Range};
5454
use distributions::range::SampleRange;
5555

5656
#[cfg(test)]
@@ -67,7 +67,7 @@ mod rand_impls;
6767
// depend on libstd. This will go away when librand is integrated
6868
// into libstd.
6969
#[doc(hidden)]
70-
trait FloatMath : Sized {
70+
trait FloatMath: Sized {
7171
fn exp(self) -> Self;
7272
fn ln(self) -> Self;
7373
fn sqrt(self) -> Self;
@@ -102,14 +102,14 @@ impl FloatMath for f64 {
102102

103103
/// A type that can be randomly generated using an `Rng`.
104104
#[doc(hidden)]
105-
pub trait Rand : Sized {
105+
pub trait Rand: Sized {
106106
/// Generates a random instance of this type using the specified source of
107107
/// randomness.
108108
fn rand<R: Rng>(rng: &mut R) -> Self;
109109
}
110110

111111
/// A random number generator.
112-
pub trait Rng : Sized {
112+
pub trait Rng: Sized {
113113
/// Return the next random u32.
114114
///
115115
/// This rarely needs to be called directly, prefer `r.gen()` to

0 commit comments

Comments
 (0)