Skip to content

Commit fbaafdc

Browse files
Rollup merge of rust-lang#153931 - cyrgani:old-consts, r=Mark-Simulacrum
remove usages of to-be-deprecated numeric constants Split out from rust-lang#146882.
2 parents b48d3c7 + a893257 commit fbaafdc

7 files changed

Lines changed: 13 additions & 14 deletions

File tree

compiler/rustc_middle/src/dep_graph/serialized.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use std::cell::RefCell;
4343
use std::cmp::max;
4444
use std::sync::Arc;
4545
use std::sync::atomic::Ordering;
46-
use std::{iter, mem, u64};
46+
use std::{iter, mem};
4747

4848
use rustc_data_structures::fingerprint::{Fingerprint, PackedFingerprint};
4949
use rustc_data_structures::fx::FxHashMap;

library/coretests/tests/array.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ fn array_mixed_equality_integers() {
646646

647647
#[test]
648648
fn array_mixed_equality_nans() {
649-
let array3: [f32; 3] = [1.0, std::f32::NAN, 3.0];
649+
let array3: [f32; 3] = [1.0, f32::NAN, 3.0];
650650

651651
let slice3: &[f32] = &{ array3 };
652652
assert!(!(array3 == slice3));

library/coretests/tests/num/int_macros.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ macro_rules! int_module {
22
($T:ident, $U:ident) => {
33
use core::num::ParseIntError;
44
use core::ops::{BitAnd, BitOr, BitXor, Not, Shl, Shr};
5-
use core::$T::*;
5+
const MAX: $T = $T::MAX;
6+
const MIN: $T = $T::MIN;
67

78
const UMAX: $U = $U::MAX;
89

library/coretests/tests/num/uint_macros.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@ macro_rules! uint_module {
22
($T:ident) => {
33
use core::num::ParseIntError;
44
use core::ops::{BitAnd, BitOr, BitXor, Not, Shl, Shr};
5-
use core::$T::*;
65

76
use crate::num;
87

98
#[test]
109
fn test_overflows() {
11-
assert!(MAX > 0);
12-
assert!(MIN <= 0);
13-
assert!((MIN + MAX).wrapping_add(1) == 0);
10+
assert!($T::MAX > 0);
11+
assert!($T::MIN <= 0);
12+
assert!(($T::MIN + $T::MAX).wrapping_add(1) == 0);
1413
}
1514

1615
#[test]
@@ -25,7 +24,7 @@ macro_rules! uint_module {
2524
assert!(0b0110 as $T == (0b1100 as $T).bitxor(0b1010 as $T));
2625
assert!(0b1110 as $T == (0b0111 as $T).shl(1));
2726
assert!(0b0111 as $T == (0b1110 as $T).shr(1));
28-
assert!(MAX - (0b1011 as $T) == (0b1011 as $T).not());
27+
assert!($T::MAX - (0b1011 as $T) == (0b1011 as $T).not());
2928
}
3029

3130
const A: $T = 0b0101100;
@@ -361,7 +360,7 @@ macro_rules! uint_module {
361360
assert_eq_const_safe!($T: R.wrapping_pow(2), 1 as $T);
362361
assert_eq_const_safe!(Option<$T>: R.checked_pow(2), None);
363362
assert_eq_const_safe!(($T, bool): R.overflowing_pow(2), (1 as $T, true));
364-
assert_eq_const_safe!($T: R.saturating_pow(2), MAX);
363+
assert_eq_const_safe!($T: R.saturating_pow(2), $T::MAX);
365364
}
366365
}
367366

@@ -468,14 +467,14 @@ macro_rules! uint_module {
468467
fn test_next_multiple_of() {
469468
assert_eq_const_safe!($T: (16 as $T).next_multiple_of(8), 16);
470469
assert_eq_const_safe!($T: (23 as $T).next_multiple_of(8), 24);
471-
assert_eq_const_safe!($T: MAX.next_multiple_of(1), MAX);
470+
assert_eq_const_safe!($T: $T::MAX.next_multiple_of(1), $T::MAX);
472471
}
473472

474473
fn test_checked_next_multiple_of() {
475474
assert_eq_const_safe!(Option<$T>: (16 as $T).checked_next_multiple_of(8), Some(16));
476475
assert_eq_const_safe!(Option<$T>: (23 as $T).checked_next_multiple_of(8), Some(24));
477476
assert_eq_const_safe!(Option<$T>: (1 as $T).checked_next_multiple_of(0), None);
478-
assert_eq_const_safe!(Option<$T>: MAX.checked_next_multiple_of(2), None);
477+
assert_eq_const_safe!(Option<$T>: $T::MAX.checked_next_multiple_of(2), None);
479478
}
480479

481480
fn test_is_next_multiple_of() {

library/stdarch/crates/core_arch/src/mips/msa.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9187,7 +9187,6 @@ mod tests {
91879187
core_arch::{mips::msa::*, simd::*},
91889188
mem,
91899189
};
9190-
use std::{f32, f64};
91919190
use stdarch_test::simd_test;
91929191

91939192
#[simd_test(enable = "msa")]

src/tools/rustfmt/src/vertical.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ fn struct_field_prefix_max_min_width<T: AlignedItem>(
198198
.rewrite_prefix(context, shape)
199199
.map(|field_str| trimmed_last_line_width(&field_str))
200200
})
201-
.fold_ok((0, ::std::usize::MAX), |(max_len, min_len), len| {
201+
.fold_ok((0, usize::MAX), |(max_len, min_len), len| {
202202
(cmp::max(max_len, len), cmp::min(min_len, len))
203203
})
204204
.unwrap_or((0, 0))

tests/ui/consts/issue-90762.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ fn main() {
2727
for (i, b) in FOO.iter().enumerate() {
2828
assert!(b.load(Ordering::Relaxed), "{} not set", i);
2929
}
30-
assert_eq!(BAR.fetch_add(1, Ordering::Relaxed), usize::max_value());
30+
assert_eq!(BAR.fetch_add(1, Ordering::Relaxed), usize::MAX);
3131
}

0 commit comments

Comments
 (0)