Skip to content
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

Rollup of 8 pull requests #63354

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
416caa1
Add test for issue-29265
JohnTitor Aug 4, 2019
620567d
Add test for issue-49544
JohnTitor Aug 4, 2019
92e4e8e
Add test for issue-37433
JohnTitor Aug 4, 2019
5b78e98
bump rand to fix Miri failures
RalfJung Apr 19, 2019
0cb16f7
bump libcore tests to rand 0.7
RalfJung Aug 4, 2019
ebc3600
Add test for #43398
iluuu1994 Jul 25, 2019
39185dd
update getrandom
RalfJung Aug 5, 2019
418bf96
Ignore no support targets
JohnTitor Aug 6, 2019
031cc32
doc: Reword deprecation message of MetadataExt::as_raw_stat
tesuji Aug 6, 2019
3cd9f3f
Add an overflow check in truncate implementation for Unix.
marmistrz Aug 6, 2019
70374c9
update to rustc-guide that passes toolstate
mark-i-m Aug 6, 2019
a411eaf
passify tidy
mark-i-m Aug 6, 2019
811c304
Test conditional initialization validation in async fns
gorup Aug 6, 2019
7568fbd
Update books
ehuss Aug 7, 2019
4c11f62
Rollup merge of #62994 - iluuu1994:test-for-43398, r=nikomatsakis
pietroalbini Aug 7, 2019
d19ac3b
Rollup merge of #63259 - JohnTitor:add-tests-for-some-issues, r=Centril
pietroalbini Aug 7, 2019
7ee81bc
Rollup merge of #63261 - RalfJung:rand, r=nikomatsakis
pietroalbini Aug 7, 2019
4eb7ec6
Rollup merge of #63327 - lzutao:fix-as_raw_stat-dep-msg, r=Mark-Simul…
pietroalbini Aug 7, 2019
5e53619
Rollup merge of #63331 - gorup:conditionalinit, r=cramertj
pietroalbini Aug 7, 2019
c659b1b
Rollup merge of #63332 - marmistrz:truncate, r=alexcrichton
pietroalbini Aug 7, 2019
fd3d756
Rollup merge of #63334 - mark-i-m:fix-guide, r=ehuss
pietroalbini Aug 7, 2019
c33b89d
Rollup merge of #63353 - ehuss:update-books, r=ehuss
pietroalbini Aug 7, 2019
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
23 changes: 16 additions & 7 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ version = "0.0.0"
dependencies = [
"compiler_builtins 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
"core 0.0.0",
"rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_xorshift 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_xorshift 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
Expand Down Expand Up @@ -514,7 +514,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
name = "core"
version = "0.0.0"
dependencies = [
"rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
Expand Down Expand Up @@ -1050,7 +1050,7 @@ dependencies = [

[[package]]
name = "getrandom"
version = "0.1.7"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
Expand Down Expand Up @@ -2246,7 +2246,7 @@ name = "rand"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"getrandom 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"getrandom 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
Expand Down Expand Up @@ -2286,7 +2286,7 @@ name = "rand_core"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"getrandom 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"getrandom 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
Expand Down Expand Up @@ -2343,6 +2343,14 @@ dependencies = [
"rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "rand_xorshift"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "rayon"
version = "1.1.0"
Expand Down Expand Up @@ -4437,7 +4445,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum fwdansi 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "34dd4c507af68d37ffef962063dfa1944ce0dd4d5b82043dbab1dabe088610c3"
"checksum generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef25c5683767570c2bbd7deba372926a55eaae9982d7726ee2a1050239d45b9d"
"checksum getopts 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)" = "72327b15c228bfe31f1390f93dd5e9279587f0463836393c9df719ce62a3e450"
"checksum getrandom 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "cd8e190892c840661957ba9f32dacfb3eb405e657f9f9f60485605f0bb37d6f8"
"checksum getrandom 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "34f33de6f0ae7c9cb5e574502a562e2b512799e32abb801cd1e79ad952b62b49"
"checksum git2 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8cb400360e8a4d61b10e648285bbfa919bbf9519d0d5d5720354456f44349226"
"checksum git2-curl 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2293de73491c3dc4174c5949ef53d2cc037b27613f88d72032e3f5237247a7dd"
"checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
Expand Down Expand Up @@ -4568,6 +4576,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071"
"checksum rand_pcg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "086bd09a33c7044e56bb44d5bdde5a60e7f119a9e95b0775f545de759a32fe05"
"checksum rand_xorshift 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "effa3fcaa47e18db002bdde6060944b6d2f9cfd8db471c30e873448ad9187be3"
"checksum rand_xorshift 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "77d416b86801d23dde1aa643023b775c3a462efc0ed96443add11546cdf1dca8"
"checksum rayon 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a4b0186e22767d5b9738a05eab7c6ac90b15db17e5b5f9bd87976dd7d89a10a4"
"checksum rayon-core 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ebbe0df8435ac0c397d467b6cad6d25543d06e8a019ef3f6af3c384597515bd2"
"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
Expand Down
2 changes: 1 addition & 1 deletion src/doc/edition-guide
2 changes: 1 addition & 1 deletion src/doc/embedded-book
2 changes: 1 addition & 1 deletion src/doc/nomicon
2 changes: 1 addition & 1 deletion src/doc/reference
2 changes: 1 addition & 1 deletion src/doc/rustc-guide
4 changes: 2 additions & 2 deletions src/liballoc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ core = { path = "../libcore" }
compiler_builtins = { version = "0.1.10", features = ['rustc-dep-of-std'] }

[dev-dependencies]
rand = "0.6"
rand_xorshift = "0.1"
rand = "0.7"
rand_xorshift = "0.2"

[[test]]
name = "collectionstests"
Expand Down
8 changes: 4 additions & 4 deletions src/liballoc/benches/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,12 @@ const SEED: [u8; 16] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15];

fn gen_random(len: usize) -> Vec<u64> {
let mut rng = XorShiftRng::from_seed(SEED);
rng.sample_iter(&Standard).take(len).collect()
(&mut rng).sample_iter(&Standard).take(len).collect()
}

fn gen_random_bytes(len: usize) -> Vec<u8> {
let mut rng = XorShiftRng::from_seed(SEED);
rng.sample_iter(&Standard).take(len).collect()
(&mut rng).sample_iter(&Standard).take(len).collect()
}

fn gen_mostly_ascending(len: usize) -> Vec<u64> {
Expand Down Expand Up @@ -221,14 +221,14 @@ fn gen_strings(len: usize) -> Vec<String> {
let mut v = vec![];
for _ in 0..len {
let n = rng.gen::<usize>() % 20 + 1;
v.push(rng.sample_iter(&Alphanumeric).take(n).collect());
v.push((&mut rng).sample_iter(&Alphanumeric).take(n).collect());
}
v
}

fn gen_big_random(len: usize) -> Vec<[u64; 16]> {
let mut rng = XorShiftRng::from_seed(SEED);
rng.sample_iter(&Standard).map(|x| [x; 16]).take(len).collect()
(&mut rng).sample_iter(&Standard).map(|x| [x; 16]).take(len).collect()
}

macro_rules! sort {
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ name = "corebenches"
path = "../libcore/benches/lib.rs"

[dev-dependencies]
rand = "0.6"
rand = "0.7"

[features]
# Make panics and failed asserts immediately abort without formatting any message
Expand Down
8 changes: 4 additions & 4 deletions src/libcore/tests/num/flt2dec/random.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use core::num::flt2dec::strategy::grisu::format_exact_opt;
use core::num::flt2dec::strategy::grisu::format_shortest_opt;
use core::num::flt2dec::{decode, DecodableFloat, FullDecoded, Decoded};

use rand::FromEntropy;
use rand::rngs::SmallRng;
use rand::SeedableRng;
use rand::rngs::StdRng;
use rand::distributions::{Distribution, Uniform};

pub fn decode_finite<T: DecodableFloat>(v: T) -> Decoded {
Expand Down Expand Up @@ -65,7 +65,7 @@ pub fn f32_random_equivalence_test<F, G>(f: F, g: G, k: usize, n: usize)
if cfg!(target_os = "emscripten") {
return // using rng pulls in i128 support, which doesn't work
}
let mut rng = SmallRng::from_entropy();
let mut rng = StdRng::from_entropy();
let f32_range = Uniform::new(0x0000_0001u32, 0x7f80_0000);
iterate("f32_random_equivalence_test", k, n, f, g, |_| {
let x = f32::from_bits(f32_range.sample(&mut rng));
Expand All @@ -79,7 +79,7 @@ pub fn f64_random_equivalence_test<F, G>(f: F, g: G, k: usize, n: usize)
if cfg!(target_os = "emscripten") {
return // using rng pulls in i128 support, which doesn't work
}
let mut rng = SmallRng::from_entropy();
let mut rng = StdRng::from_entropy();
let f64_range = Uniform::new(0x0000_0000_0000_0001u64, 0x7ff0_0000_0000_0000);
iterate("f64_random_equivalence_test", k, n, f, g, |_| {
let x = f64::from_bits(f64_range.sample(&mut rng));
Expand Down
10 changes: 5 additions & 5 deletions src/libcore/tests/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,7 @@ fn test_rotate_right() {
fn sort_unstable() {
use core::cmp::Ordering::{Equal, Greater, Less};
use core::slice::heapsort;
use rand::{FromEntropy, Rng, rngs::SmallRng, seq::SliceRandom};
use rand::{SeedableRng, Rng, rngs::StdRng, seq::SliceRandom};

#[cfg(not(miri))] // Miri is too slow
let large_range = 500..510;
Expand All @@ -1171,7 +1171,7 @@ fn sort_unstable() {

let mut v = [0; 600];
let mut tmp = [0; 600];
let mut rng = SmallRng::from_entropy();
let mut rng = StdRng::from_entropy();

for len in (2..25).chain(large_range) {
let v = &mut v[0..len];
Expand Down Expand Up @@ -1237,11 +1237,11 @@ fn sort_unstable() {
#[cfg(not(miri))] // Miri is too slow
fn partition_at_index() {
use core::cmp::Ordering::{Equal, Greater, Less};
use rand::rngs::SmallRng;
use rand::rngs::StdRng;
use rand::seq::SliceRandom;
use rand::{FromEntropy, Rng};
use rand::{SeedableRng, Rng};

let mut rng = SmallRng::from_entropy();
let mut rng = StdRng::from_entropy();

for len in (2..21).chain(500..501) {
let mut orig = vec![0; len];
Expand Down
2 changes: 2 additions & 0 deletions src/libstd/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,8 @@ impl File {
/// # Errors
///
/// This function will return an error if the file is not opened for writing.
/// Also, std::io::ErrorKind::InvalidInput will be returned if the desired
/// length would cause an overflow due to the implementation specifics.
///
/// # Examples
///
Expand Down
7 changes: 4 additions & 3 deletions src/libstd/os/linux/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ pub trait MetadataExt {
/// }
/// ```
#[stable(feature = "metadata_ext", since = "1.1.0")]
#[rustc_deprecated(since = "1.8.0",
reason = "deprecated in favor of the accessor \
methods of this trait")]
#[rustc_deprecated(
since = "1.8.0",
reason = "other methods of this trait are now prefered"
)]
#[allow(deprecated)]
fn as_raw_stat(&self) -> &raw::stat;

Expand Down
12 changes: 9 additions & 3 deletions src/libstd/sys/unix/fs.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::os::unix::prelude::*;

use crate::convert::TryInto;
use crate::ffi::{CString, CStr, OsString, OsStr};
use crate::fmt;
use crate::io::{self, Error, ErrorKind, SeekFrom, IoSlice, IoSliceMut};
Expand Down Expand Up @@ -554,9 +555,14 @@ impl File {
return crate::sys::android::ftruncate64(self.0.raw(), size);

#[cfg(not(target_os = "android"))]
return cvt_r(|| unsafe {
ftruncate64(self.0.raw(), size as off64_t)
}).map(|_| ());
{
let size: off64_t = size
.try_into()
.map_err(|e| io::Error::new(io::ErrorKind::InvalidInput, e))?;
cvt_r(|| unsafe {
ftruncate64(self.0.raw(), size)
}).map(|_| ())
}
}

pub fn read(&self, buf: &mut [u8]) -> io::Result<usize> {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// check-pass
// edition:2018
// compile-flags: --crate-type lib

#![feature(async_await)]

async fn conditional_and_guaranteed_initialization(x: usize) -> usize {
let y;
if x > 5 {
y = echo(10).await;
} else {
y = get_something().await;
}
y
}

async fn echo(x: usize) -> usize { x }
async fn get_something() -> usize { 10 }
16 changes: 16 additions & 0 deletions src/test/ui/async-await/no-non-guaranteed-initialization.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// compile-fail
// edition:2018
// compile-flags: --crate-type lib

#![feature(async_await)]

async fn no_non_guaranteed_initialization(x: usize) -> usize {
let y;
if x > 5 {
y = echo(10).await;
}
y
//~^ use of possibly uninitialized variable: `y`
}

async fn echo(x: usize) -> usize { x + 1 }
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0381]: use of possibly uninitialized variable: `y`
--> $DIR/no-non-guaranteed-initialization.rs:12:5
|
LL | y
| ^ use of possibly uninitialized `y`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0381`.
9 changes: 9 additions & 0 deletions src/test/ui/issues/auxiliary/issue-29265.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#![crate_type = "lib"]

pub struct SomeType {
pub some_member: usize,
}

pub static SOME_VALUE: SomeType = SomeType {
some_member: 1,
};
7 changes: 7 additions & 0 deletions src/test/ui/issues/auxiliary/issue-49544.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#![crate_type = "lib"]

pub fn foo() -> Vec<String> {
std::env::args()
.skip(1)
.collect()
}
10 changes: 10 additions & 0 deletions src/test/ui/issues/issue-29265.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// aux-build:issue-29265.rs
// check-pass

extern crate issue_29265 as lib;

static _UNUSED: &'static lib::SomeType = &lib::SOME_VALUE;

fn main() {
vec![0u8; lib::SOME_VALUE.some_member];
}
10 changes: 10 additions & 0 deletions src/test/ui/issues/issue-37433.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// ignore-emscripten no asm! support

#![feature(asm)]

fn main() {
unsafe {
asm!("" :: "r"(""));
//~^ ERROR: invalid value for constraint in inline assembly
}
}
8 changes: 8 additions & 0 deletions src/test/ui/issues/issue-37433.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error[E0669]: invalid value for constraint in inline assembly
--> $DIR/issue-37433.rs:7:24
|
LL | asm!("" :: "r"(""));
| ^^

error: aborting due to previous error

15 changes: 15 additions & 0 deletions src/test/ui/issues/issue-43398.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// run-pass

#![feature(core_intrinsics)]
#![feature(repr128)]

#[repr(i128)]
enum Big { A, B }

fn main() {
unsafe {
println!("{} {:?}",
std::intrinsics::discriminant_value(&Big::A),
std::mem::discriminant(&Big::B));
}
}
9 changes: 9 additions & 0 deletions src/test/ui/issues/issue-49544.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// aux-build:issue-49544.rs
// check-pass

extern crate issue_49544;
use issue_49544::foo;

fn main() {
let _ = foo();
}