Skip to content

Commit 3412c25

Browse files
authored
Unrolled build for rust-lang#136395
Rollup merge of rust-lang#136395 - ChrisDenton:rand-0-9, r=Mark-Simulacrum Update to rand 0.9.0 Changes include: - `thread_rng` has been renamed to `rng` - `Standard` has been renamed to `StandardUniform` - `gen`, `gen_range`, `gen_bool` have been renamed to `random`, `random_range` and `random_bool` respectively.
2 parents 9fb94b3 + aea9ddd commit 3412c25

File tree

9 files changed

+63
-35
lines changed

9 files changed

+63
-35
lines changed

Cargo.lock

+7-7
Original file line numberDiff line numberDiff line change
@@ -2881,11 +2881,11 @@ dependencies = [
28812881

28822882
[[package]]
28832883
name = "rand_xoshiro"
2884-
version = "0.6.0"
2884+
version = "0.7.0"
28852885
source = "registry+https://github.com/rust-lang/crates.io-index"
2886-
checksum = "6f97cdb2a36ed4183de61b2f824cc45c9f1037f28afe0a322e9fff4c108b5aaa"
2886+
checksum = "f703f4665700daf5512dcca5f43afa6af89f09db47fb56be587f80636bda2d41"
28872887
dependencies = [
2888-
"rand_core 0.6.4",
2888+
"rand_core 0.9.0",
28892889
]
28902890

28912891
[[package]]
@@ -3155,7 +3155,7 @@ name = "rustc_abi"
31553155
version = "0.0.0"
31563156
dependencies = [
31573157
"bitflags",
3158-
"rand 0.8.5",
3158+
"rand 0.9.0",
31593159
"rand_xoshiro",
31603160
"rustc_data_structures",
31613161
"rustc_hashes",
@@ -3789,7 +3789,7 @@ dependencies = [
37893789
name = "rustc_incremental"
37903790
version = "0.0.0"
37913791
dependencies = [
3792-
"rand 0.8.5",
3792+
"rand 0.9.0",
37933793
"rustc_ast",
37943794
"rustc_data_structures",
37953795
"rustc_errors",
@@ -5176,8 +5176,8 @@ version = "0.1.0"
51765176
dependencies = [
51775177
"indicatif",
51785178
"num",
5179-
"rand 0.8.5",
5180-
"rand_chacha 0.3.1",
5179+
"rand 0.9.0",
5180+
"rand_chacha 0.9.0",
51815181
"rayon",
51825182
]
51835183

compiler/rustc_abi/Cargo.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ edition = "2024"
66
[dependencies]
77
# tidy-alphabetical-start
88
bitflags = "2.4.1"
9-
rand = { version = "0.8.4", default-features = false, optional = true }
10-
rand_xoshiro = { version = "0.6.0", optional = true }
11-
rustc_data_structures = { path = "../rustc_data_structures", optional = true }
9+
rand = { version = "0.9.0", default-features = false, optional = true }
10+
rand_xoshiro = { version = "0.7.0", optional = true }
11+
rustc_data_structures = { path = "../rustc_data_structures", optional = true }
1212
rustc_hashes = { path = "../rustc_hashes" }
1313
rustc_index = { path = "../rustc_index", default-features = false }
1414
rustc_macros = { path = "../rustc_macros", optional = true }
15-
rustc_serialize = { path = "../rustc_serialize", optional = true }
15+
rustc_serialize = { path = "../rustc_serialize", optional = true }
1616
rustc_span = { path = "../rustc_span", optional = true }
1717
tracing = "0.1"
1818
# tidy-alphabetical-end

compiler/rustc_incremental/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ edition = "2024"
55

66
[dependencies]
77
# tidy-alphabetical-start
8-
rand = "0.8.4"
8+
rand = "0.9.0"
99
rustc_ast = { path = "../rustc_ast" }
1010
rustc_data_structures = { path = "../rustc_data_structures" }
1111
rustc_errors = { path = "../rustc_errors" }

compiler/rustc_incremental/src/persist/fs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ use std::io::{self, ErrorKind};
108108
use std::path::{Path, PathBuf};
109109
use std::time::{Duration, SystemTime, UNIX_EPOCH};
110110

111-
use rand::{RngCore, thread_rng};
111+
use rand::{RngCore, rng};
112112
use rustc_data_structures::base_n::{BaseNString, CASE_INSENSITIVE, ToBaseN};
113113
use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
114114
use rustc_data_structures::svh::Svh;
@@ -445,7 +445,7 @@ fn copy_files(sess: &Session, target_dir: &Path, source_dir: &Path) -> Result<bo
445445
fn generate_session_dir_path(crate_dir: &Path) -> PathBuf {
446446
let timestamp = timestamp_to_string(SystemTime::now());
447447
debug!("generate_session_dir_path: timestamp = {}", timestamp);
448-
let random_number = thread_rng().next_u32();
448+
let random_number = rng().next_u32();
449449
debug!("generate_session_dir_path: random_number = {}", random_number);
450450

451451
// Chop the first 3 characters off the timestamp. Those 3 bytes will be zero for a while.

src/etc/test-float-parse/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ publish = false
77
[dependencies]
88
indicatif = { version = "0.17.8", default-features = false }
99
num = "0.4.3"
10-
rand = "0.8.5"
11-
rand_chacha = "0.3"
10+
rand = "0.9.0"
11+
rand_chacha = "0.9.0"
1212
rayon = "1"
1313

1414
[lib]

src/etc/test-float-parse/src/gen/fuzz.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::ops::Range;
66
use std::sync::Mutex;
77

88
use rand::Rng;
9-
use rand::distributions::{Distribution, Standard};
9+
use rand::distr::{Distribution, StandardUniform};
1010
use rand_chacha::ChaCha8Rng;
1111
use rand_chacha::rand_core::SeedableRng;
1212

@@ -47,7 +47,7 @@ impl<F: Float> Fuzz<F> {
4747

4848
impl<F: Float> Generator<F> for Fuzz<F>
4949
where
50-
Standard: Distribution<<F as Float>::Int>,
50+
StandardUniform: Distribution<<F as Float>::Int>,
5151
{
5252
const SHORT_NAME: &'static str = "fuzz";
5353

@@ -74,13 +74,13 @@ where
7474

7575
impl<F: Float> Iterator for Fuzz<F>
7676
where
77-
Standard: Distribution<<F as Float>::Int>,
77+
StandardUniform: Distribution<<F as Float>::Int>,
7878
{
7979
type Item = <Self as Generator<F>>::WriteCtx;
8080

8181
fn next(&mut self) -> Option<Self::Item> {
8282
let _ = self.iter.next()?;
83-
let i: F::Int = self.rng.gen();
83+
let i: F::Int = self.rng.random();
8484

8585
Some(F::from_bits(i))
8686
}

src/etc/test-float-parse/src/gen/many_digits.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::fmt::Write;
33
use std::marker::PhantomData;
44
use std::ops::{Range, RangeInclusive};
55

6-
use rand::distributions::{Distribution, Uniform};
6+
use rand::distr::{Distribution, Uniform};
77
use rand::{Rng, SeedableRng};
88
use rand_chacha::ChaCha8Rng;
99

@@ -40,7 +40,7 @@ impl<F: Float> Generator<F> for RandDigits<F> {
4040

4141
fn new() -> Self {
4242
let rng = ChaCha8Rng::from_seed(SEED);
43-
let range = Uniform::from(0..10);
43+
let range = Uniform::try_from(0..10).unwrap();
4444

4545
Self { rng, iter: 0..ITERATIONS, uniform: range, marker: PhantomData }
4646
}
@@ -55,11 +55,11 @@ impl<F: Float> Iterator for RandDigits<F> {
5555

5656
fn next(&mut self) -> Option<Self::Item> {
5757
let _ = self.iter.next()?;
58-
let num_digits = self.rng.gen_range(POSSIBLE_NUM_DIGITS);
59-
let has_decimal = self.rng.gen_bool(0.2);
60-
let has_exp = self.rng.gen_bool(0.2);
58+
let num_digits = self.rng.random_range(POSSIBLE_NUM_DIGITS);
59+
let has_decimal = self.rng.random_bool(0.2);
60+
let has_exp = self.rng.random_bool(0.2);
6161

62-
let dec_pos = if has_decimal { Some(self.rng.gen_range(0..num_digits)) } else { None };
62+
let dec_pos = if has_decimal { Some(self.rng.random_range(0..num_digits)) } else { None };
6363

6464
let mut s = String::with_capacity(num_digits);
6565

@@ -75,7 +75,7 @@ impl<F: Float> Iterator for RandDigits<F> {
7575
}
7676

7777
if has_exp {
78-
let exp = self.rng.gen_range(EXP_RANGE);
78+
let exp = self.rng.random_range(EXP_RANGE);
7979
write!(s, "e{exp}").unwrap();
8080
}
8181

src/etc/test-float-parse/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::sync::OnceLock;
1010
use std::sync::atomic::{AtomicU64, Ordering};
1111
use std::{fmt, time};
1212

13-
use rand::distributions::{Distribution, Standard};
13+
use rand::distr::{Distribution, StandardUniform};
1414
use rayon::prelude::*;
1515
use time::{Duration, Instant};
1616
use traits::{Float, Generator, Int};
@@ -132,7 +132,7 @@ fn register_float<F: Float>(tests: &mut Vec<TestInfo>, cfg: &Config)
132132
where
133133
RangeInclusive<F::Int>: Iterator<Item = F::Int>,
134134
<F::Int as TryFrom<u128>>::Error: std::fmt::Debug,
135-
Standard: Distribution<<F as traits::Float>::Int>,
135+
StandardUniform: Distribution<<F as traits::Float>::Int>,
136136
{
137137
if F::BITS <= MAX_BITS_FOR_EXHAUUSTIVE {
138138
// Only run exhaustive tests if there is a chance of completion.

src/tools/tidy/src/deps.rs

+34-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
//! Checks the licenses of third-party dependencies.
22
3-
use std::collections::HashSet;
3+
use std::collections::{HashMap, HashSet};
44
use std::fs::{File, read_dir};
55
use std::io::Write;
66
use std::path::Path;
77

88
use build_helper::ci::CiEnv;
9+
use cargo_metadata::semver::Version;
910
use cargo_metadata::{Metadata, Package, PackageId};
1011

1112
#[path = "../../../bootstrap/src/utils/proc_macro_deps.rs"]
@@ -445,6 +446,7 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
445446
"windows_x86_64_gnu",
446447
"windows_x86_64_gnullvm",
447448
"windows_x86_64_msvc",
449+
"[email protected]", // via wasi
448450
"writeable",
449451
"yoke",
450452
"yoke-derive",
@@ -802,7 +804,17 @@ fn check_permitted_dependencies(
802804

803805
// Check that the PERMITTED_DEPENDENCIES does not have unused entries.
804806
for permitted in permitted_dependencies {
805-
if !deps.iter().any(|dep_id| &pkg_from_id(metadata, dep_id).name == permitted) {
807+
fn compare(pkg: &Package, permitted: &str) -> bool {
808+
if let Some((name, version)) = permitted.split_once("@") {
809+
let Ok(version) = Version::parse(version) else {
810+
return false;
811+
};
812+
pkg.name == name && pkg.version == version
813+
} else {
814+
pkg.name == permitted
815+
}
816+
}
817+
if !deps.iter().any(|dep_id| compare(pkg_from_id(metadata, dep_id), permitted)) {
806818
tidy_error!(
807819
bad,
808820
"could not find allowed package `{permitted}`\n\
@@ -813,14 +825,30 @@ fn check_permitted_dependencies(
813825
}
814826

815827
// Get in a convenient form.
816-
let permitted_dependencies: HashSet<_> = permitted_dependencies.iter().cloned().collect();
828+
let permitted_dependencies: HashMap<_, _> = permitted_dependencies
829+
.iter()
830+
.map(|s| {
831+
if let Some((name, version)) = s.split_once('@') {
832+
(name, Version::parse(version).ok())
833+
} else {
834+
(*s, None)
835+
}
836+
})
837+
.collect();
817838

818839
for dep in deps {
819840
let dep = pkg_from_id(metadata, dep);
820841
// If this path is in-tree, we don't require it to be explicitly permitted.
821-
if dep.source.is_some() && !permitted_dependencies.contains(dep.name.as_str()) {
822-
tidy_error!(bad, "Dependency for {descr} not explicitly permitted: {}", dep.id);
823-
has_permitted_dep_error = true;
842+
if dep.source.is_some() {
843+
let is_eq = if let Some(version) = permitted_dependencies.get(dep.name.as_str()) {
844+
if let Some(version) = version { version == &dep.version } else { true }
845+
} else {
846+
false
847+
};
848+
if !is_eq {
849+
tidy_error!(bad, "Dependency for {descr} not explicitly permitted: {}", dep.id);
850+
has_permitted_dep_error = true;
851+
}
824852
}
825853
}
826854

0 commit comments

Comments
 (0)