Skip to content

Rollup of 10 pull requests #33948

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 21 commits into from
Closed
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
abe9961
* Fix compile_fail tag (in some cases, it compiled whereas it wasn't …
GuillaumeGomez May 22, 2016
a850d40
Improve E0132 error explanation
GuillaumeGomez May 27, 2016
a1e240c
Improve E0137 error explanatIon
GuillaumeGomez May 27, 2016
360d723
Improve E0138 error explanation
GuillaumeGomez May 27, 2016
c848ca1
Improve E0133 error explanation
GuillaumeGomez May 27, 2016
4fa8483
improve E0152 error explanation
GuillaumeGomez May 27, 2016
3fd0e4c
rustfmt liballoc folder
srinivasreddy May 27, 2016
feb0b27
Added examples/docs to split in str.rs
Ophirr33 May 26, 2016
68641d8
run rustfmt on librustc_lint folder
srinivasreddy May 28, 2016
72baa41
run rustfmt on librand folder
srinivasreddy May 29, 2016
5ed45ef
run rustfmt on libunwind
srinivasreddy May 29, 2016
31b9060
Improve E0161 error explanation
GuillaumeGomez May 27, 2016
cae6c75
Rollup merge of #33793 - GuillaumeGomez:compile_fail, r=GuillaumeGomez
GuillaumeGomez May 29, 2016
48245ae
Rollup merge of #33893 - Ophirr33:docs_string_split_fix, r=GuillaumeG…
GuillaumeGomez May 29, 2016
075ea13
Rollup merge of #33912 - GuillaumeGomez:improve_E0132, r=steveklabnik
GuillaumeGomez May 29, 2016
7475236
Rollup merge of #33913 - GuillaumeGomez:improve_e0133, r=GuillaumeGomez
GuillaumeGomez May 29, 2016
deb6bc6
Rollup merge of #33914 - GuillaumeGomez:improve_err_expl, r=Guillaume…
GuillaumeGomez May 29, 2016
df9dd98
Rollup merge of #33917 - srinivasreddy:rustfmt_liballoc, r=GuillaumeG…
GuillaumeGomez May 29, 2016
1bbbd5d
Rollup merge of #33931 - srinivasreddy:lint_folder, r=GuillaumeGomez
GuillaumeGomez May 29, 2016
fce2b41
Rollup merge of #33937 - srinivasreddy:rustfmt_librand, r=GuillaumeGomez
GuillaumeGomez May 29, 2016
59aef48
Rollup merge of #33938 - srinivasreddy:rustfmt_libunwind, r=Manishearth
GuillaumeGomez May 29, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions src/liballoc/arc.rs
Original file line number Diff line number Diff line change
@@ -72,7 +72,7 @@
use boxed::Box;

use core::sync::atomic;
use core::sync::atomic::Ordering::{Relaxed, Release, Acquire, SeqCst};
use core::sync::atomic::Ordering::{Acquire, Relaxed, Release, SeqCst};
use core::borrow;
use core::fmt;
use core::cmp::Ordering;
@@ -85,7 +85,7 @@ use core::ops::CoerceUnsized;
use core::ptr::{self, Shared};
use core::marker::Unsize;
use core::hash::{Hash, Hasher};
use core::{usize, isize};
use core::{isize, usize};
use core::convert::From;
use heap::deallocate;

@@ -608,11 +608,13 @@ impl<T> Weak<T> {
#[stable(feature = "downgraded_weak", since = "1.10.0")]
pub fn new() -> Weak<T> {
unsafe {
Weak { ptr: Shared::new(Box::into_raw(box ArcInner {
strong: atomic::AtomicUsize::new(0),
weak: atomic::AtomicUsize::new(1),
data: uninitialized(),
}))}
Weak {
ptr: Shared::new(Box::into_raw(box ArcInner {
strong: atomic::AtomicUsize::new(0),
weak: atomic::AtomicUsize::new(1),
data: uninitialized(),
})),
}
}
}
}
@@ -655,7 +657,9 @@ impl<T: ?Sized> Weak<T> {

// See comments in `Arc::clone` for why we do this (for `mem::forget`).
if n > MAX_REFCOUNT {
unsafe { abort(); }
unsafe {
abort();
}
}

// Relaxed is valid for the same reason it is on Arc's Clone impl
@@ -946,7 +950,7 @@ mod tests {
use std::mem::drop;
use std::ops::Drop;
use std::option::Option;
use std::option::Option::{Some, None};
use std::option::Option::{None, Some};
use std::sync::atomic;
use std::sync::atomic::Ordering::{Acquire, SeqCst};
use std::thread;
5 changes: 3 additions & 2 deletions src/liballoc/boxed.rs
Original file line number Diff line number Diff line change
@@ -64,7 +64,7 @@ use core::hash::{self, Hash};
use core::marker::{self, Unsize};
use core::mem;
use core::ops::{CoerceUnsized, Deref, DerefMut};
use core::ops::{Placer, Boxed, Place, InPlace, BoxPlace};
use core::ops::{BoxPlace, Boxed, InPlace, Place, Placer};
use core::ptr::{self, Unique};
use core::raw::TraitObject;
use core::convert::From;
@@ -535,7 +535,8 @@ pub trait FnBox<A> {

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

2 changes: 1 addition & 1 deletion src/liballoc/boxed_test.rs
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@

use core::any::Any;
use core::ops::Deref;
use core::result::Result::{Ok, Err};
use core::result::Result::{Err, Ok};
use core::clone::Clone;

use std::boxed::Box;
2 changes: 1 addition & 1 deletion src/liballoc/heap.rs
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@

use core::{isize, usize};
#[cfg(not(test))]
use core::intrinsics::{size_of, min_align_of};
use core::intrinsics::{min_align_of, size_of};

#[allow(improper_ctypes)]
extern "C" {
8 changes: 4 additions & 4 deletions src/liballoc/rc.rs
Original file line number Diff line number Diff line change
@@ -159,11 +159,11 @@ use core::borrow;
use core::cell::Cell;
use core::cmp::Ordering;
use core::fmt;
use core::hash::{Hasher, Hash};
use core::intrinsics::{assume, abort};
use core::hash::{Hash, Hasher};
use core::intrinsics::{abort, assume};
use core::marker;
use core::marker::Unsize;
use core::mem::{self, align_of_val, size_of_val, forget, uninitialized};
use core::mem::{self, align_of_val, forget, size_of_val, uninitialized};
use core::ops::Deref;
use core::ops::CoerceUnsized;
use core::ptr::{self, Shared};
@@ -935,7 +935,7 @@ mod tests {
use std::boxed::Box;
use std::cell::RefCell;
use std::option::Option;
use std::option::Option::{Some, None};
use std::option::Option::{None, Some};
use std::result::Result::{Err, Ok};
use std::mem::drop;
use std::clone::Clone;
30 changes: 28 additions & 2 deletions src/libcollections/str.rs
Original file line number Diff line number Diff line change
@@ -1097,8 +1097,34 @@ impl str {
/// assert_eq!(d, &["", "", "", "", "a", "", "b", "c"]);
/// ```
///
/// This can lead to possibly surprising behavior when whitespace is used
/// as the separator. This code is correct:
/// Contiguous separators are separated by the empty string.
///
/// ```
/// let x = "(///)".to_string();
/// let d: Vec<_> = x.split('/').collect();;
///
/// assert_eq!(d, &["(", "", "", ")"]);
/// ```
///
/// Separators at the start or end of a string are neighbored
/// by empty strings.
///
/// ```
/// let d: Vec<_> = "010".split("0").collect();
/// assert_eq!(d, &["", "1", ""]);
/// ```
///
/// When the empty string is used as a separator, it separates
/// every character in the string, along with the beginning
/// and end of the string.
///
/// ```
/// let f: Vec<_> = "rust".split("").collect();
/// assert_eq!(f, &["", "r", "u", "s", "t", ""]);
/// ```
///
/// Contiguous separators can lead to possibly surprising behavior
/// when whitespace is used as the separator. This code is correct:
///
/// ```
/// let x = " a b c".to_string();
8 changes: 5 additions & 3 deletions src/librand/chacha.rs
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@

//! The ChaCha random number generator.

use {Rng, SeedableRng, Rand};
use {Rand, Rng, SeedableRng};

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

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

6 changes: 3 additions & 3 deletions src/librand/distributions/exponential.rs
Original file line number Diff line number Diff line change
@@ -13,8 +13,8 @@
#[cfg(not(test))] // only necessary for no_std
use FloatMath;

use {Rng, Rand};
use distributions::{ziggurat, ziggurat_tables, Sample, IndependentSample};
use {Rand, Rng};
use distributions::{IndependentSample, Sample, ziggurat, ziggurat_tables};

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

#[cfg(test)]
mod tests {
use distributions::{Sample, IndependentSample};
use distributions::{IndependentSample, Sample};
use super::Exp;

#[test]
8 changes: 4 additions & 4 deletions src/librand/distributions/gamma.rs
Original file line number Diff line number Diff line change
@@ -16,9 +16,9 @@ use self::ChiSquaredRepr::*;
#[cfg(not(test))] // only necessary for no_std
use FloatMath;

use {Rng, Open01};
use {Open01, Rng};
use super::normal::StandardNormal;
use super::{IndependentSample, Sample, Exp};
use super::{Exp, IndependentSample, Sample};

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

#[cfg(test)]
mod tests {
use distributions::{Sample, IndependentSample};
use super::{ChiSquared, StudentT, FisherF};
use distributions::{IndependentSample, Sample};
use super::{ChiSquared, FisherF, StudentT};

#[test]
fn test_chi_squared_one() {
10 changes: 5 additions & 5 deletions src/librand/distributions/mod.rs
Original file line number Diff line number Diff line change
@@ -22,11 +22,11 @@ use core::num::Float;

use core::marker::PhantomData;

use {Rng, Rand};
use {Rand, Rng};

pub use self::range::Range;
pub use self::gamma::{Gamma, ChiSquared, FisherF, StudentT};
pub use self::normal::{Normal, LogNormal};
pub use self::gamma::{ChiSquared, FisherF, Gamma, StudentT};
pub use self::normal::{LogNormal, Normal};
pub use self::exponential::Exp;

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

#[cfg(test)]
mod tests {
use {Rng, Rand};
use super::{RandSample, WeightedChoice, Weighted, Sample, IndependentSample};
use {Rand, Rng};
use super::{IndependentSample, RandSample, Sample, Weighted, WeightedChoice};

#[derive(PartialEq, Debug)]
struct ConstRand(usize);
8 changes: 4 additions & 4 deletions src/librand/distributions/normal.rs
Original file line number Diff line number Diff line change
@@ -13,8 +13,8 @@
#[cfg(not(test))] // only necessary for no_std
use FloatMath;

use {Rng, Rand, Open01};
use distributions::{ziggurat, ziggurat_tables, Sample, IndependentSample};
use {Open01, Rand, Rng};
use distributions::{IndependentSample, Sample, ziggurat, ziggurat_tables};

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

#[cfg(test)]
mod tests {
use distributions::{Sample, IndependentSample};
use super::{Normal, LogNormal};
use distributions::{IndependentSample, Sample};
use super::{LogNormal, Normal};

#[test]
fn test_normal() {
4 changes: 2 additions & 2 deletions src/librand/distributions/range.rs
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@

use core::marker::Sized;
use Rng;
use distributions::{Sample, IndependentSample};
use distributions::{IndependentSample, Sample};

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

#[cfg(test)]
mod tests {
use distributions::{Sample, IndependentSample};
use distributions::{IndependentSample, Sample};
use super::Range;

#[should_panic]
16 changes: 10 additions & 6 deletions src/librand/isaac.rs
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ use core::slice;
use core::iter::repeat;
use core::num::Wrapping as w;

use {Rng, SeedableRng, Rand};
use {Rand, Rng, SeedableRng};

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

use {Rng, SeedableRng};
use super::{IsaacRng, Isaac64Rng};
use super::{Isaac64Rng, IsaacRng};

#[test]
fn test_rng_32_rand_seeded() {
let s = ::test::rng().gen_iter::<u32>().take(256).collect::<Vec<u32>>();
let mut ra: IsaacRng = SeedableRng::from_seed(&s[..]);
let mut rb: IsaacRng = SeedableRng::from_seed(&s[..]);
assert!(ra.gen_ascii_chars().take(100)
assert!(ra.gen_ascii_chars()
.take(100)
.eq(rb.gen_ascii_chars().take(100)));
}
#[test]
fn test_rng_64_rand_seeded() {
let s = ::test::rng().gen_iter::<u64>().take(256).collect::<Vec<u64>>();
let mut ra: Isaac64Rng = SeedableRng::from_seed(&s[..]);
let mut rb: Isaac64Rng = SeedableRng::from_seed(&s[..]);
assert!(ra.gen_ascii_chars().take(100)
assert!(ra.gen_ascii_chars()
.take(100)
.eq(rb.gen_ascii_chars().take(100)));
}

@@ -615,15 +617,17 @@ mod tests {
let seed: &[_] = &[1, 23, 456, 7890, 12345];
let mut ra: IsaacRng = SeedableRng::from_seed(seed);
let mut rb: IsaacRng = SeedableRng::from_seed(seed);
assert!(ra.gen_ascii_chars().take(100)
assert!(ra.gen_ascii_chars()
.take(100)
.eq(rb.gen_ascii_chars().take(100)));
}
#[test]
fn test_rng_64_seeded() {
let seed: &[_] = &[1, 23, 456, 7890, 12345];
let mut ra: Isaac64Rng = SeedableRng::from_seed(seed);
let mut rb: Isaac64Rng = SeedableRng::from_seed(seed);
assert!(ra.gen_ascii_chars().take(100)
assert!(ra.gen_ascii_chars()
.take(100)
.eq(rb.gen_ascii_chars().take(100)));
}

10 changes: 5 additions & 5 deletions src/librand/lib.rs
Original file line number Diff line number Diff line change
@@ -47,10 +47,10 @@ use core::f64;
use core::intrinsics;
use core::marker::PhantomData;

pub use isaac::{IsaacRng, Isaac64Rng};
pub use isaac::{Isaac64Rng, IsaacRng};
pub use chacha::ChaChaRng;

use distributions::{Range, IndependentSample};
use distributions::{IndependentSample, Range};
use distributions::range::SampleRange;

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

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

/// A random number generator.
pub trait Rng : Sized {
pub trait Rng: Sized {
/// Return the next random u32.
///
/// This rarely needs to be called directly, prefer `r.gen()` to
Loading