Skip to content

Commit 8a82798

Browse files
committed
Migrate coretests to Rust 2024
1 parent ef34064 commit 8a82798

File tree

7 files changed

+19
-18
lines changed

7 files changed

+19
-18
lines changed

library/coretests/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ repository = "https://github.com/rust-lang/rust.git"
66
description = "Tests for the Rust Core Library"
77
autotests = false
88
autobenches = false
9-
edition = "2021"
9+
edition = "2024"
1010

1111
[lib]
1212
path = "lib.rs"

library/coretests/benches/num/int_log/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ macro_rules! int_log10_bench {
2121
/* Exponentially distributed random numbers from the whole range of the type. */
2222
let numbers: Vec<$t> = (0..256)
2323
.map(|_| {
24-
let x = rng.gen::<$t>() >> rng.gen_range(0..<$t>::BITS);
24+
let x = rng.r#gen::<$t>() >> rng.gen_range(0..<$t>::BITS);
2525
if x != 0 { x } else { 1 }
2626
})
2727
.collect();
@@ -38,7 +38,7 @@ macro_rules! int_log10_bench {
3838
/* Exponentially distributed random numbers from the range 0..256. */
3939
let numbers: Vec<$t> = (0..256)
4040
.map(|_| {
41-
let x = (rng.gen::<u8>() >> rng.gen_range(0..u8::BITS)) as $t;
41+
let x = (rng.r#gen::<u8>() >> rng.gen_range(0..u8::BITS)) as $t;
4242
if x != 0 { x } else { 1 }
4343
})
4444
.collect();
@@ -65,7 +65,7 @@ macro_rules! int_log_bench {
6565
/* Exponentially distributed random numbers from the whole range of the type. */
6666
let numbers: Vec<$t> = (0..256)
6767
.map(|_| {
68-
let x = rng.gen::<$t>() >> rng.gen_range(0..<$t>::BITS);
68+
let x = rng.r#gen::<$t>() >> rng.gen_range(0..<$t>::BITS);
6969
if x >= 2 { x } else { 2 }
7070
})
7171
.collect();
@@ -84,7 +84,7 @@ macro_rules! int_log_bench {
8484
/* Exponentially distributed random numbers from the range 0..256. */
8585
let numbers: Vec<$t> = (0..256)
8686
.map(|_| {
87-
let x = (rng.gen::<u8>() >> rng.gen_range(0..u8::BITS)) as $t;
87+
let x = (rng.r#gen::<u8>() >> rng.gen_range(0..u8::BITS)) as $t;
8888
if x >= 2 { x } else { 2 }
8989
})
9090
.collect();

library/coretests/benches/num/int_sqrt/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ macro_rules! int_sqrt_bench {
2020
let mut rng = crate::bench_rng();
2121
/* Exponentially distributed random numbers from the whole range of the type. */
2222
let numbers: Vec<$t> =
23-
(0..256).map(|_| rng.gen::<$t>() >> rng.gen_range(0..<$t>::BITS)).collect();
23+
(0..256).map(|_| rng.r#gen::<$t>() >> rng.gen_range(0..<$t>::BITS)).collect();
2424
bench.iter(|| {
2525
for x in &numbers {
2626
black_box(black_box(x).isqrt());
@@ -33,7 +33,7 @@ macro_rules! int_sqrt_bench {
3333
let mut rng = crate::bench_rng();
3434
/* Exponentially distributed random numbers from the range 0..256. */
3535
let numbers: Vec<$t> =
36-
(0..256).map(|_| (rng.gen::<u8>() >> rng.gen_range(0..u8::BITS)) as $t).collect();
36+
(0..256).map(|_| (rng.r#gen::<u8>() >> rng.gen_range(0..u8::BITS)) as $t).collect();
3737
bench.iter(|| {
3838
for x in &numbers {
3939
black_box(black_box(x).isqrt());
@@ -45,7 +45,7 @@ macro_rules! int_sqrt_bench {
4545
fn $random_uniform(bench: &mut Bencher) {
4646
let mut rng = crate::bench_rng();
4747
/* Exponentially distributed random numbers from the whole range of the type. */
48-
let numbers: Vec<$t> = (0..256).map(|_| rng.gen::<$t>()).collect();
48+
let numbers: Vec<$t> = (0..256).map(|_| rng.r#gen::<$t>()).collect();
4949
bench.iter(|| {
5050
for x in &numbers {
5151
black_box(black_box(x).isqrt());

library/coretests/benches/slice.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ fn binary_search_l3_worst_case(b: &mut Bencher) {
9494
struct Rgb(#[allow(dead_code)] u8, #[allow(dead_code)] u8, #[allow(dead_code)] u8);
9595

9696
impl Rgb {
97-
fn gen(i: usize) -> Self {
97+
fn r#gen(i: usize) -> Self {
9898
Rgb(i as u8, (i as u8).wrapping_add(7), (i as u8).wrapping_add(42))
9999
}
100100
}
@@ -115,7 +115,7 @@ macro_rules! rotate {
115115
}
116116

117117
rotate!(rotate_u8, 32, |i| i as u8);
118-
rotate!(rotate_rgb, 32, Rgb::gen);
118+
rotate!(rotate_rgb, 32, Rgb::r#gen);
119119
rotate!(rotate_usize, 32, |i| i);
120120
rotate!(rotate_16_usize_4, 16, |i| [i; 4]);
121121
rotate!(rotate_16_usize_5, 16, |i| [i; 5]);
@@ -142,8 +142,8 @@ macro_rules! swap_with_slice {
142142

143143
swap_with_slice!(swap_with_slice_u8_30, 30, |i| i as u8);
144144
swap_with_slice!(swap_with_slice_u8_3000, 3000, |i| i as u8);
145-
swap_with_slice!(swap_with_slice_rgb_30, 30, Rgb::gen);
146-
swap_with_slice!(swap_with_slice_rgb_3000, 3000, Rgb::gen);
145+
swap_with_slice!(swap_with_slice_rgb_30, 30, Rgb::r#gen);
146+
swap_with_slice!(swap_with_slice_rgb_3000, 3000, Rgb::r#gen);
147147
swap_with_slice!(swap_with_slice_usize_30, 30, |i| i);
148148
swap_with_slice!(swap_with_slice_usize_3000, 3000, |i| i);
149149
swap_with_slice!(swap_with_slice_4x_usize_30, 30, |i| [i; 4]);

library/coretests/tests/io/borrowed_buf.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ fn cursor_set_init() {
145145
assert_eq!(rbuf.unfilled().init_ref().len(), 8);
146146
assert_eq!(rbuf.unfilled().init_mut().len(), 8);
147147
assert_eq!(rbuf.unfilled().uninit_mut().len(), 8);
148-
assert_eq!(unsafe { rbuf.unfilled().as_mut() }.len(), 16);
148+
assert_eq!(unsafe { rbuf.unfilled().as_mut().len() }, 16);
149149

150150
rbuf.unfilled().advance(4);
151151

@@ -163,5 +163,5 @@ fn cursor_set_init() {
163163
assert_eq!(rbuf.unfilled().init_ref().len(), 8);
164164
assert_eq!(rbuf.unfilled().init_mut().len(), 8);
165165
assert_eq!(rbuf.unfilled().uninit_mut().len(), 4);
166-
assert_eq!(unsafe { rbuf.unfilled().as_mut() }.len(), 12);
166+
assert_eq!(unsafe { rbuf.unfilled().as_mut().len() }, 12);
167167
}

library/coretests/tests/pin.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ fn pin_const() {
2828
const fn pin_mut_const() {
2929
let _ = Pin::new(&mut 2).into_ref();
3030
let _ = Pin::new(&mut 2).get_mut();
31-
let _ = unsafe { Pin::new(&mut 2).get_unchecked_mut() };
31+
let r = &mut 2;
32+
let _ = unsafe { Pin::new(r).get_unchecked_mut() };
3233
}
3334

3435
pin_mut_const();

library/coretests/tests/slice.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,7 +1291,7 @@ fn test_iter_ref_consistency() {
12911291
fn test<T: Copy + Debug + PartialEq>(x: T) {
12921292
let v: &[T] = &[x, x, x];
12931293
let v_ptrs: [*const T; 3] = match v {
1294-
[ref v1, ref v2, ref v3] => [v1 as *const _, v2 as *const _, v3 as *const _],
1294+
[v1, v2, v3] => [v1 as *const _, v2 as *const _, v3 as *const _],
12951295
_ => unreachable!(),
12961296
};
12971297
let len = v.len();
@@ -1346,7 +1346,7 @@ fn test_iter_ref_consistency() {
13461346
fn test_mut<T: Copy + Debug + PartialEq>(x: T) {
13471347
let v: &mut [T] = &mut [x, x, x];
13481348
let v_ptrs: [*mut T; 3] = match v {
1349-
[ref v1, ref v2, ref v3] => {
1349+
&mut [ref v1, ref v2, ref v3] => {
13501350
[v1 as *const _ as *mut _, v2 as *const _ as *mut _, v3 as *const _ as *mut _]
13511351
}
13521352
_ => unreachable!(),
@@ -1818,7 +1818,7 @@ fn select_nth_unstable() {
18181818
for &modulus in &[5, 10, 1000] {
18191819
for _ in 0..10 {
18201820
for i in 0..len {
1821-
orig[i] = rng.gen::<i32>() % modulus;
1821+
orig[i] = rng.r#gen::<i32>() % modulus;
18221822
}
18231823

18241824
let v_sorted = {

0 commit comments

Comments
 (0)