Skip to content

Commit 15f6dca

Browse files
JakobDegenmeta-codesync[bot]
authored andcommitted
rand: Upgrade 0.8 to 0.9, batch 14/N
Summary: Batch of upgrades from rand 0.8 to rand 0.9. These upgrades are strictly mechanical, driven by the script at P2123045218. Crates which did not compile under these chages are left out. Reviewed By: dtolnay Differential Revision: D90697099 fbshipit-source-id: d5afb0ea4d2080c64a489ecbdedb0d5df5251569
1 parent 3789cd1 commit 15f6dca

14 files changed

Lines changed: 77 additions & 44 deletions

File tree

hphp/hack/src/Cargo.lock

Lines changed: 41 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hphp/hack/src/hackc/ir/passes/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ print = { version = "0.0.0", path = "../print" }
2020

2121
[dev-dependencies]
2222
hash = { version = "0.0.0", path = "../../../utils/hash" }
23-
rand = { version = "0.8", features = ["small_rng"] }
23+
rand = { version = "0.9", features = ["small_rng"] }
2424
testutils = { version = "0.0.0", path = "../testutils" }
2525
verify = { version = "0.0.0", path = "../verify" }

hphp/hack/src/hackc/ir/passes/rpo_sort.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ mod tests {
139139
use ir_core::Block;
140140
use ir_core::BlockId;
141141
use rand::Rng;
142+
use rand::rng;
142143
use rand::seq::SliceRandom;
143-
use rand::thread_rng;
144144

145145
use super::*;
146146

@@ -203,15 +203,15 @@ mod tests {
203203
fn permute_random() {
204204
let names = ["a", "b", "c", "d", "e", "f"];
205205
let blocks = make_dummy_blocks(&names);
206-
let mut rng = thread_rng();
206+
let mut rng = rng();
207207

208208
for _ in 0..100 {
209209
// Create a random selection, including usually dropping entries.
210210
let mut order = (0..names.len())
211211
.map(|n| BlockId(n as u32))
212212
.collect::<Vec<_>>();
213213
order.shuffle(&mut rng);
214-
order.truncate(rng.gen_range(0..order.len()));
214+
order.truncate(rng.random_range(0..order.len()));
215215

216216
let mut b1 = blocks.clone();
217217
permute_and_truncate(&mut b1, order_to_remap(&order, blocks.len()));
@@ -279,7 +279,7 @@ mod tests {
279279
testutils::Block::jmp("dead2", "dead"),
280280
];
281281

282-
let mut rng = thread_rng();
282+
let mut rng = rng();
283283

284284
for _ in 0..50 {
285285
// Shuffle block order, but leave the entry block first. We should always
@@ -305,19 +305,19 @@ mod tests {
305305
#[test]
306306
fn random_rpo() {
307307
let names = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"];
308-
let mut rng = thread_rng();
308+
let mut rng = rng();
309309

310310
for _ in 0..500 {
311311
// Build up a random function.
312-
let num_blocks = rng.gen_range(2..names.len());
312+
let num_blocks = rng.random_range(2..names.len());
313313
let mut blocks = Vec::new();
314314
let mut rblocks = Vec::new();
315315
for i in 0..num_blocks {
316316
// Choose 0, 1 or 2 successor, with only a small chance of 0.
317-
let num_successors = (rng.gen_range(0..7) + 2) / 3;
317+
let num_successors = (rng.random_range(0..7) + 2) / 3;
318318
let mut succ = || {
319319
// NOTE: You can't branch to the entry block.
320-
names[rng.gen_range(1..num_blocks)]
320+
names[rng.random_range(1..num_blocks)]
321321
};
322322
let (term, rterm) = match num_successors {
323323
0 => (testutils::Terminator::Ret, testutils::Terminator::Ret),

hphp/hack/src/naming/names_rust/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ anyhow = "1.0.98"
1515
crossbeam = "0.8"
1616
hh24_types = { version = "0.0.0", path = "../../utils/hh24_types" }
1717
oxidized = { version = "0.0.0", path = "../../oxidized" }
18-
rand = { version = "0.8", features = ["small_rng"] }
18+
rand = { version = "0.9", features = ["small_rng"] }
1919
relative_path = { version = "0.0.0", path = "../../utils/rust/relative_path" }
2020
rusqlite = { version = "0.37.0", features = ["backup", "blob", "bundled", "column_decltype", "functions", "limits", "modern_sqlite", "serde_json"] }
2121
serde = { version = "1.0.219", features = ["derive", "rc"] }

hphp/hack/src/naming/names_rust/naming_sqlite.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ impl Names {
166166
.expect("SystemTime::now() before UNIX_EPOCH")
167167
.as_secs(),
168168
{
169-
use rand::distributions::DistString;
170-
rand::distributions::Alphanumeric.sample_string(&mut rand::thread_rng(), 10)
169+
use rand::distr::SampleString;
170+
rand::distr::Alphanumeric.sample_string(&mut rand::rng(), 10)
171171
},
172172
)],
173173
)?;

hphp/hack/src/shmffi/cargo/ocaml_blob/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ ocamlrep = { version = "0.1.0", git = "https://github.com/facebook/ocamlrep/", b
1818
shmrs = { version = "0.0.0", path = "../../../shmrs" }
1919

2020
[dev-dependencies]
21-
rand = { version = "0.8", features = ["small_rng"] }
21+
rand = { version = "0.9", features = ["small_rng"] }

hphp/hack/src/shmffi/ocaml_blob.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -344,14 +344,14 @@ mod tests {
344344
let mut rng = StdRng::from_seed([0; 32]);
345345

346346
for _ in 0..NUM_TESTS {
347-
let buffer_size = (rng.r#gen::<u32>() & ((1 << 31) - 1)) as usize;
348-
let uncompressed_size = if rng.gen_bool(0.5) {
347+
let buffer_size = (rng.random::<u32>() & ((1 << 31) - 1)) as usize;
348+
let uncompressed_size = if rng.random_bool(0.5) {
349349
buffer_size
350350
} else {
351-
(rng.r#gen::<u32>() & ((1 << 31) - 1)) as usize
351+
(rng.random::<u32>() & ((1 << 31) - 1)) as usize
352352
};
353-
let is_serialized = rng.gen_bool(0.5);
354-
let is_evictable = rng.gen_bool(0.5);
353+
let is_serialized = rng.random_bool(0.5);
354+
let is_evictable = rng.random_bool(0.5);
355355

356356
let header = HeapValueHeaderFields {
357357
buffer_size,

hphp/hack/src/shmrs/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ static_assertions = "1.1.0"
2020

2121
[dev-dependencies]
2222
nix = { version = "0.30.1", features = ["dir", "event", "hostname", "inotify", "ioctl", "mman", "mount", "net", "poll", "ptrace", "reboot", "resource", "sched", "signal", "term", "time", "user", "zerocopy"] }
23-
rand = { version = "0.8", features = ["small_rng"] }
23+
rand = { version = "0.9", features = ["small_rng"] }

hphp/hack/src/shmrs/sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ mod integration_tests {
460460

461461
let mut num_incrs = 0;
462462
while num_incrs < NUM_INCRS_PER_PROC {
463-
if rng.gen_bool(0.5) {
463+
if rng.random_bool(0.5) {
464464
let mut guard = lock.write(None).unwrap();
465465
*guard += 1;
466466
std::thread::sleep(OP_SLEEP);

hphp/hack/src/utils/intern/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ smallvec = { version = "1.15", features = ["serde", "union"] }
2121

2222
[dev-dependencies]
2323
bincode = "1.3.3"
24-
rand = { version = "0.8", features = ["small_rng"] }
24+
rand = { version = "0.9", features = ["small_rng"] }
2525
serde_json = { version = "1.0.140", features = ["alloc", "float_roundtrip", "raw_value", "unbounded_depth"] }

0 commit comments

Comments
 (0)