Skip to content

Commit 2d1a551

Browse files
committed
Auto merge of #63380 - Centril:rollup-tzfhtnu, r=Centril
Rollup of 8 pull requests Successful merges: - #63261 (bump rand in libcore/liballoc test suites) - #63316 (Update rustfmt to 1.4.4) - #63332 (Add an overflow check in truncate implementation for Unix.) - #63342 (Don't use remap-path-prefix in dep-info files.) - #63366 (doc: Fix typo in float from bytes methods) - #63370 (Fix ICE #63364) - #63377 (Improved documentation for compile_error!()) - #63379 (Add test for issue 53096) Failed merges: r? @ghost
2 parents 2628f57 + 3de450b commit 2d1a551

File tree

17 files changed

+84
-36
lines changed

17 files changed

+84
-36
lines changed

Cargo.lock

+18-9
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ version = "0.0.0"
1919
dependencies = [
2020
"compiler_builtins 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
2121
"core 0.0.0",
22-
"rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
23-
"rand_xorshift 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
22+
"rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
23+
"rand_xorshift 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
2424
]
2525

2626
[[package]]
@@ -514,7 +514,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
514514
name = "core"
515515
version = "0.0.0"
516516
dependencies = [
517-
"rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
517+
"rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
518518
]
519519

520520
[[package]]
@@ -1050,7 +1050,7 @@ dependencies = [
10501050

10511051
[[package]]
10521052
name = "getrandom"
1053-
version = "0.1.7"
1053+
version = "0.1.8"
10541054
source = "registry+https://github.com/rust-lang/crates.io-index"
10551055
dependencies = [
10561056
"cfg-if 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2246,7 +2246,7 @@ name = "rand"
22462246
version = "0.7.0"
22472247
source = "registry+https://github.com/rust-lang/crates.io-index"
22482248
dependencies = [
2249-
"getrandom 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
2249+
"getrandom 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
22502250
"libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
22512251
"rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
22522252
"rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2286,7 +2286,7 @@ name = "rand_core"
22862286
version = "0.5.0"
22872287
source = "registry+https://github.com/rust-lang/crates.io-index"
22882288
dependencies = [
2289-
"getrandom 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
2289+
"getrandom 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
22902290
]
22912291

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

2346+
[[package]]
2347+
name = "rand_xorshift"
2348+
version = "0.2.0"
2349+
source = "registry+https://github.com/rust-lang/crates.io-index"
2350+
dependencies = [
2351+
"rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
2352+
]
2353+
23462354
[[package]]
23472355
name = "rayon"
23482356
version = "1.1.0"
@@ -2501,7 +2509,7 @@ dependencies = [
25012509
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
25022510
"rustc-workspace-hack 1.0.0",
25032511
"rustc_tools_util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
2504-
"rustfmt-nightly 1.4.3",
2512+
"rustfmt-nightly 1.4.4",
25052513
"serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)",
25062514
"serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)",
25072515
"serde_ignored 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3284,7 +3292,7 @@ dependencies = [
32843292

32853293
[[package]]
32863294
name = "rustfmt-nightly"
3287-
version = "1.4.3"
3295+
version = "1.4.4"
32883296
dependencies = [
32893297
"annotate-snippets 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
32903298
"atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -4436,7 +4444,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
44364444
"checksum fwdansi 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "34dd4c507af68d37ffef962063dfa1944ce0dd4d5b82043dbab1dabe088610c3"
44374445
"checksum generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef25c5683767570c2bbd7deba372926a55eaae9982d7726ee2a1050239d45b9d"
44384446
"checksum getopts 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)" = "72327b15c228bfe31f1390f93dd5e9279587f0463836393c9df719ce62a3e450"
4439-
"checksum getrandom 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "cd8e190892c840661957ba9f32dacfb3eb405e657f9f9f60485605f0bb37d6f8"
4447+
"checksum getrandom 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "34f33de6f0ae7c9cb5e574502a562e2b512799e32abb801cd1e79ad952b62b49"
44404448
"checksum git2 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8cb400360e8a4d61b10e648285bbfa919bbf9519d0d5d5720354456f44349226"
44414449
"checksum git2-curl 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2293de73491c3dc4174c5949ef53d2cc037b27613f88d72032e3f5237247a7dd"
44424450
"checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
@@ -4567,6 +4575,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
45674575
"checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071"
45684576
"checksum rand_pcg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "086bd09a33c7044e56bb44d5bdde5a60e7f119a9e95b0775f545de759a32fe05"
45694577
"checksum rand_xorshift 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "effa3fcaa47e18db002bdde6060944b6d2f9cfd8db471c30e873448ad9187be3"
4578+
"checksum rand_xorshift 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "77d416b86801d23dde1aa643023b775c3a462efc0ed96443add11546cdf1dca8"
45704579
"checksum rayon 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a4b0186e22767d5b9738a05eab7c6ac90b15db17e5b5f9bd87976dd7d89a10a4"
45714580
"checksum rayon-core 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ebbe0df8435ac0c397d467b6cad6d25543d06e8a019ef3f6af3c384597515bd2"
45724581
"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"

src/liballoc/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ core = { path = "../libcore" }
1515
compiler_builtins = { version = "0.1.10", features = ['rustc-dep-of-std'] }
1616

1717
[dev-dependencies]
18-
rand = "0.6"
19-
rand_xorshift = "0.1"
18+
rand = "0.7"
19+
rand_xorshift = "0.2"
2020

2121
[[test]]
2222
name = "collectionstests"

src/liballoc/benches/slice.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,12 @@ const SEED: [u8; 16] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15];
186186

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

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

197197
fn gen_mostly_ascending(len: usize) -> Vec<u64> {
@@ -221,14 +221,14 @@ fn gen_strings(len: usize) -> Vec<String> {
221221
let mut v = vec![];
222222
for _ in 0..len {
223223
let n = rng.gen::<usize>() % 20 + 1;
224-
v.push(rng.sample_iter(&Alphanumeric).take(n).collect());
224+
v.push((&mut rng).sample_iter(&Alphanumeric).take(n).collect());
225225
}
226226
v
227227
}
228228

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

234234
macro_rules! sort {

src/libcore/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ name = "corebenches"
2121
path = "../libcore/benches/lib.rs"
2222

2323
[dev-dependencies]
24-
rand = "0.6"
24+
rand = "0.7"
2525

2626
[features]
2727
# Make panics and failed asserts immediately abort without formatting any message

src/libcore/macros.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ pub(crate) mod builtin {
680680
///
681681
/// This macro should be used when a crate uses a conditional compilation strategy to provide
682682
/// better error messages for erroneous conditions. It's the compiler-level form of [`panic!`],
683-
/// which emits an error at *runtime*, rather than during compilation.
683+
/// but emits an error during *compilation* rather than at *runtime*.
684684
///
685685
/// # Examples
686686
///

src/libcore/num/f32.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ impl f32 {
536536
Self::from_bits(u32::from_be_bytes(bytes))
537537
}
538538

539-
/// Create a floating point value from its representation as a byte array in big endian.
539+
/// Create a floating point value from its representation as a byte array in little endian.
540540
///
541541
/// # Examples
542542
///
@@ -551,7 +551,7 @@ impl f32 {
551551
Self::from_bits(u32::from_le_bytes(bytes))
552552
}
553553

554-
/// Create a floating point value from its representation as a byte array in big endian.
554+
/// Create a floating point value from its representation as a byte array in native endian.
555555
///
556556
/// As the target platform's native endianness is used, portable code
557557
/// likely wants to use [`from_be_bytes`] or [`from_le_bytes`], as

src/libcore/num/f64.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ impl f64 {
549549
Self::from_bits(u64::from_be_bytes(bytes))
550550
}
551551

552-
/// Create a floating point value from its representation as a byte array in big endian.
552+
/// Create a floating point value from its representation as a byte array in little endian.
553553
///
554554
/// # Examples
555555
///
@@ -564,7 +564,7 @@ impl f64 {
564564
Self::from_bits(u64::from_le_bytes(bytes))
565565
}
566566

567-
/// Create a floating point value from its representation as a byte array in big endian.
567+
/// Create a floating point value from its representation as a byte array in native endian.
568568
///
569569
/// As the target platform's native endianness is used, portable code
570570
/// likely wants to use [`from_be_bytes`] or [`from_le_bytes`], as

src/libcore/tests/num/flt2dec/random.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use core::num::flt2dec::strategy::grisu::format_exact_opt;
88
use core::num::flt2dec::strategy::grisu::format_shortest_opt;
99
use core::num::flt2dec::{decode, DecodableFloat, FullDecoded, Decoded};
1010

11-
use rand::FromEntropy;
12-
use rand::rngs::SmallRng;
11+
use rand::SeedableRng;
12+
use rand::rngs::StdRng;
1313
use rand::distributions::{Distribution, Uniform};
1414

1515
pub fn decode_finite<T: DecodableFloat>(v: T) -> Decoded {
@@ -65,7 +65,7 @@ pub fn f32_random_equivalence_test<F, G>(f: F, g: G, k: usize, n: usize)
6565
if cfg!(target_os = "emscripten") {
6666
return // using rng pulls in i128 support, which doesn't work
6767
}
68-
let mut rng = SmallRng::from_entropy();
68+
let mut rng = StdRng::from_entropy();
6969
let f32_range = Uniform::new(0x0000_0001u32, 0x7f80_0000);
7070
iterate("f32_random_equivalence_test", k, n, f, g, |_| {
7171
let x = f32::from_bits(f32_range.sample(&mut rng));
@@ -79,7 +79,7 @@ pub fn f64_random_equivalence_test<F, G>(f: F, g: G, k: usize, n: usize)
7979
if cfg!(target_os = "emscripten") {
8080
return // using rng pulls in i128 support, which doesn't work
8181
}
82-
let mut rng = SmallRng::from_entropy();
82+
let mut rng = StdRng::from_entropy();
8383
let f64_range = Uniform::new(0x0000_0000_0000_0001u64, 0x7ff0_0000_0000_0000);
8484
iterate("f64_random_equivalence_test", k, n, f, g, |_| {
8585
let x = f64::from_bits(f64_range.sample(&mut rng));

src/libcore/tests/slice.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,7 @@ fn test_rotate_right() {
11571157
fn sort_unstable() {
11581158
use core::cmp::Ordering::{Equal, Greater, Less};
11591159
use core::slice::heapsort;
1160-
use rand::{FromEntropy, Rng, rngs::SmallRng, seq::SliceRandom};
1160+
use rand::{SeedableRng, Rng, rngs::StdRng, seq::SliceRandom};
11611161

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

11721172
let mut v = [0; 600];
11731173
let mut tmp = [0; 600];
1174-
let mut rng = SmallRng::from_entropy();
1174+
let mut rng = StdRng::from_entropy();
11751175

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

1244-
let mut rng = SmallRng::from_entropy();
1244+
let mut rng = StdRng::from_entropy();
12451245

12461246
for len in (2..21).chain(500..501) {
12471247
let mut orig = vec![0; len];

src/librustc_interface/passes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ fn write_out_deps(compiler: &Compiler, outputs: &OutputFilenames, out_filenames:
661661
.iter()
662662
.filter(|fmap| fmap.is_real_file())
663663
.filter(|fmap| !fmap.is_imported())
664-
.map(|fmap| escape_dep_filename(&fmap.name))
664+
.map(|fmap| escape_dep_filename(&fmap.unmapped_path.as_ref().unwrap_or(&fmap.name)))
665665
.collect();
666666

667667
if sess.binary_dep_depinfo() {

src/librustc_lint/types.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ fn lint_overflowing_range_endpoint<'a, 'tcx>(
7373
// We only want to handle exclusive (`..`) ranges,
7474
// which are represented as `ExprKind::Struct`.
7575
if let ExprKind::Struct(_, eps, _) = &parent_expr.node {
76-
debug_assert_eq!(eps.len(), 2);
76+
if eps.len() != 2 {
77+
return false;
78+
}
7779
// We can suggest using an inclusive range
7880
// (`..=`) instead only if it is the `end` that is
7981
// overflowing and only by 1.

src/libstd/fs.rs

+2
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,8 @@ impl File {
468468
/// # Errors
469469
///
470470
/// This function will return an error if the file is not opened for writing.
471+
/// Also, std::io::ErrorKind::InvalidInput will be returned if the desired
472+
/// length would cause an overflow due to the implementation specifics.
471473
///
472474
/// # Examples
473475
///

src/libstd/sys/unix/fs.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -557,9 +557,15 @@ impl File {
557557
return crate::sys::android::ftruncate64(self.0.raw(), size);
558558

559559
#[cfg(not(target_os = "android"))]
560-
return cvt_r(|| unsafe {
561-
ftruncate64(self.0.raw(), size as off64_t)
562-
}).map(|_| ());
560+
{
561+
use crate::convert::TryInto;
562+
let size: off64_t = size
563+
.try_into()
564+
.map_err(|e| io::Error::new(io::ErrorKind::InvalidInput, e))?;
565+
cvt_r(|| unsafe {
566+
ftruncate64(self.0.raw(), size)
567+
}).map(|_| ())
568+
}
563569
}
564570

565571
pub fn read(&self, buf: &mut [u8]) -> io::Result<usize> {

src/test/ui/issues/issue-63364.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
fn part(_: u16) -> u32 {
2+
1
3+
}
4+
5+
fn main() {
6+
for n in 100_000.. {
7+
//~^ ERROR: literal out of range for `u16`
8+
let _ = part(n);
9+
}
10+
}

src/test/ui/issues/issue-63364.stderr

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: literal out of range for `u16`
2+
--> $DIR/issue-63364.rs:6:14
3+
|
4+
LL | for n in 100_000.. {
5+
| ^^^^^^^
6+
|
7+
= note: `#[deny(overflowing_literals)]` on by default
8+
9+
error: aborting due to previous error
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// check-pass
2+
#![feature(const_fn)]
3+
#![feature(type_alias_impl_trait)]
4+
5+
type Foo = impl Fn() -> usize;
6+
const fn bar() -> Foo { || 0usize }
7+
const BAZR: Foo = bar();
8+
9+
fn main() {}

src/tools/rustfmt

0 commit comments

Comments
 (0)