Skip to content

Commit 9e81b51

Browse files
committed
Replace deprecated items
1 parent 83b75db commit 9e81b51

File tree

107 files changed

+609
-703
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+609
-703
lines changed

src/liballoc/rc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2034,7 +2034,7 @@ trait RcBoxPtr<T: ?Sized> {
20342034
// The reference count will never be zero when this is called;
20352035
// nevertheless, we insert an abort here to hint LLVM at
20362036
// an otherwise missed optimization.
2037-
if strong == 0 || strong == usize::max_value() {
2037+
if strong == 0 || strong == usize::MAX {
20382038
// remove `unsafe` on bootstrap bump
20392039
#[cfg_attr(not(bootstrap), allow(unused_unsafe))]
20402040
unsafe {
@@ -2062,7 +2062,7 @@ trait RcBoxPtr<T: ?Sized> {
20622062
// The reference count will never be zero when this is called;
20632063
// nevertheless, we insert an abort here to hint LLVM at
20642064
// an otherwise missed optimization.
2065-
if weak == 0 || weak == usize::max_value() {
2065+
if weak == 0 || weak == usize::MAX {
20662066
// remove `unsafe` on bootstrap bump
20672067
#[cfg_attr(not(bootstrap), allow(unused_unsafe))]
20682068
unsafe {

src/liballoc/rc/tests.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -407,14 +407,14 @@ fn test_from_vec() {
407407
fn test_downcast() {
408408
use std::any::Any;
409409

410-
let r1: Rc<dyn Any> = Rc::new(i32::max_value());
410+
let r1: Rc<dyn Any> = Rc::new(i32::MAX);
411411
let r2: Rc<dyn Any> = Rc::new("abc");
412412

413413
assert!(r1.clone().downcast::<u32>().is_err());
414414

415415
let r1i32 = r1.downcast::<i32>();
416416
assert!(r1i32.is_ok());
417-
assert_eq!(r1i32.unwrap(), Rc::new(i32::max_value()));
417+
assert_eq!(r1i32.unwrap(), Rc::new(i32::MAX));
418418

419419
assert!(r2.clone().downcast::<i32>().is_err());
420420

src/liballoc/sync/tests.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -465,14 +465,14 @@ fn test_from_vec() {
465465
fn test_downcast() {
466466
use std::any::Any;
467467

468-
let r1: Arc<dyn Any + Send + Sync> = Arc::new(i32::max_value());
468+
let r1: Arc<dyn Any + Send + Sync> = Arc::new(i32::MAX);
469469
let r2: Arc<dyn Any + Send + Sync> = Arc::new("abc");
470470

471471
assert!(r1.clone().downcast::<u32>().is_err());
472472

473473
let r1i32 = r1.downcast::<i32>();
474474
assert!(r1i32.is_ok());
475-
assert_eq!(r1i32.unwrap(), Arc::new(i32::max_value()));
475+
assert_eq!(r1i32.unwrap(), Arc::new(i32::MAX));
476476

477477
assert!(r2.clone().downcast::<i32>().is_err());
478478

src/liballoc/tests/str.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -566,13 +566,13 @@ mod slice_index {
566566
data: "hello";
567567
// note: using 0 specifically ensures that the result of overflowing is 0..0,
568568
// so that `get` doesn't simply return None for the wrong reason.
569-
bad: data[0..=usize::max_value()];
569+
bad: data[0..=usize::MAX];
570570
message: "maximum usize";
571571
}
572572

573573
in mod rangetoinclusive {
574574
data: "hello";
575-
bad: data[..=usize::max_value()];
575+
bad: data[..=usize::MAX];
576576
message: "maximum usize";
577577
}
578578
}

src/liballoc/tests/vec.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ fn test_reserve() {
6868

6969
#[test]
7070
fn test_zst_capacity() {
71-
assert_eq!(Vec::<()>::new().capacity(), usize::max_value());
71+
assert_eq!(Vec::<()>::new().capacity(), usize::MAX);
7272
}
7373

7474
#[test]
@@ -563,19 +563,19 @@ fn test_drain_inclusive_range() {
563563

564564
#[test]
565565
fn test_drain_max_vec_size() {
566-
let mut v = Vec::<()>::with_capacity(usize::max_value());
566+
let mut v = Vec::<()>::with_capacity(usize::MAX);
567567
unsafe {
568-
v.set_len(usize::max_value());
568+
v.set_len(usize::MAX);
569569
}
570-
for _ in v.drain(usize::max_value() - 1..) {}
571-
assert_eq!(v.len(), usize::max_value() - 1);
570+
for _ in v.drain(usize::MAX - 1..) {}
571+
assert_eq!(v.len(), usize::MAX - 1);
572572

573-
let mut v = Vec::<()>::with_capacity(usize::max_value());
573+
let mut v = Vec::<()>::with_capacity(usize::MAX);
574574
unsafe {
575-
v.set_len(usize::max_value());
575+
v.set_len(usize::MAX);
576576
}
577-
for _ in v.drain(usize::max_value() - 1..=usize::max_value() - 1) {}
578-
assert_eq!(v.len(), usize::max_value() - 1);
577+
for _ in v.drain(usize::MAX - 1..=usize::MAX - 1) {}
578+
assert_eq!(v.len(), usize::MAX - 1);
579579
}
580580

581581
#[test]

src/libcore/cell.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1163,16 +1163,16 @@ impl<'b> BorrowRef<'b> {
11631163
// Incrementing borrow can result in a non-reading value (<= 0) in these cases:
11641164
// 1. It was < 0, i.e. there are writing borrows, so we can't allow a read borrow
11651165
// due to Rust's reference aliasing rules
1166-
// 2. It was isize::max_value() (the max amount of reading borrows) and it overflowed
1167-
// into isize::min_value() (the max amount of writing borrows) so we can't allow
1166+
// 2. It was isize::MAX (the max amount of reading borrows) and it overflowed
1167+
// into isize::MIN (the max amount of writing borrows) so we can't allow
11681168
// an additional read borrow because isize can't represent so many read borrows
11691169
// (this can only happen if you mem::forget more than a small constant amount of
11701170
// `Ref`s, which is not good practice)
11711171
None
11721172
} else {
11731173
// Incrementing borrow can result in a reading value (> 0) in these cases:
11741174
// 1. It was = 0, i.e. it wasn't borrowed, and we are taking the first read borrow
1175-
// 2. It was > 0 and < isize::max_value(), i.e. there were read borrows, and isize
1175+
// 2. It was > 0 and < isize::MAX, i.e. there were read borrows, and isize
11761176
// is large enough to represent having one more read borrow
11771177
borrow.set(b);
11781178
Some(BorrowRef { borrow })
@@ -1198,7 +1198,7 @@ impl Clone for BorrowRef<'_> {
11981198
debug_assert!(is_reading(borrow));
11991199
// Prevent the borrow counter from overflowing into
12001200
// a writing borrow.
1201-
assert!(borrow != isize::max_value());
1201+
assert!(borrow != isize::MAX);
12021202
self.borrow.set(borrow + 1);
12031203
BorrowRef { borrow: self.borrow }
12041204
}
@@ -1489,7 +1489,7 @@ impl<'b> BorrowRefMut<'b> {
14891489
let borrow = self.borrow.get();
14901490
debug_assert!(is_writing(borrow));
14911491
// Prevent the borrow counter from underflowing.
1492-
assert!(borrow != isize::min_value());
1492+
assert!(borrow != isize::MIN);
14931493
self.borrow.set(borrow - 1);
14941494
BorrowRefMut { borrow: self.borrow }
14951495
}

src/libcore/convert/num.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ macro_rules! try_from_upper_bounded {
217217
/// is outside of the range of the target type.
218218
#[inline]
219219
fn try_from(u: $source) -> Result<Self, Self::Error> {
220-
if u > (Self::max_value() as $source) {
220+
if u > (Self::MAX as $source) {
221221
Err(TryFromIntError(()))
222222
} else {
223223
Ok(u as Self)
@@ -239,8 +239,8 @@ macro_rules! try_from_both_bounded {
239239
/// is outside of the range of the target type.
240240
#[inline]
241241
fn try_from(u: $source) -> Result<Self, Self::Error> {
242-
let min = Self::min_value() as $source;
243-
let max = Self::max_value() as $source;
242+
let min = Self::MIN as $source;
243+
let max = Self::MAX as $source;
244244
if u < min || u > max {
245245
Err(TryFromIntError(()))
246246
} else {

src/libcore/num/f32.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ use crate::num::FpCategory;
1818
#[rustc_deprecated(
1919
since = "1.46.0",
2020
reason = "The associated constant `f32::RADIX` is now prefered",
21-
suggestion = "f32::RADIX",
21+
suggestion = "f32::RADIX"
2222
)]
2323
pub const RADIX: u32 = f32::RADIX;
2424

2525
/// Number of significant digits in base 2.
2626
#[rustc_deprecated(
2727
since = "1.46.0",
2828
reason = "The associated constant `f32::MANTISSA_DIGITS` is now prefered",
29-
suggestion = "f32::MANTISSA_DIGITS",
29+
suggestion = "f32::MANTISSA_DIGITS"
3030
)]
3131
#[stable(feature = "rust1", since = "1.0.0")]
3232
pub const MANTISSA_DIGITS: u32 = f32::MANTISSA_DIGITS;
@@ -36,7 +36,7 @@ pub const MANTISSA_DIGITS: u32 = f32::MANTISSA_DIGITS;
3636
#[rustc_deprecated(
3737
since = "1.46.0",
3838
reason = "The associated constant `f32::DIGITS` is now prefered",
39-
suggestion = "f32::DIGITS",
39+
suggestion = "f32::DIGITS"
4040
)]
4141
pub const DIGITS: u32 = f32::DIGITS;
4242

@@ -47,7 +47,7 @@ pub const DIGITS: u32 = f32::DIGITS;
4747
#[rustc_deprecated(
4848
since = "1.46.0",
4949
reason = "The associated constant `f32::EPSILON` is now prefered",
50-
suggestion = "f32::EPSILON",
50+
suggestion = "f32::EPSILON"
5151
)]
5252
pub const EPSILON: f32 = f32::EPSILON;
5353

@@ -56,7 +56,7 @@ pub const EPSILON: f32 = f32::EPSILON;
5656
#[rustc_deprecated(
5757
since = "1.46.0",
5858
reason = "The associated constant `f32::MIN` is now prefered",
59-
suggestion = "f32::MIN",
59+
suggestion = "f32::MIN"
6060
)]
6161
pub const MIN: f32 = f32::MIN;
6262

@@ -65,7 +65,7 @@ pub const MIN: f32 = f32::MIN;
6565
#[rustc_deprecated(
6666
since = "1.46.0",
6767
reason = "The associated constant `f32::MIN_POSITIVE` is now prefered",
68-
suggestion = "f32::MIN_POSITIVE",
68+
suggestion = "f32::MIN_POSITIVE"
6969
)]
7070
pub const MIN_POSITIVE: f32 = f32::MIN_POSITIVE;
7171

@@ -74,7 +74,7 @@ pub const MIN_POSITIVE: f32 = f32::MIN_POSITIVE;
7474
#[rustc_deprecated(
7575
since = "1.46.0",
7676
reason = "The associated constant `f32::MAX` is now prefered",
77-
suggestion = "f32::MAX",
77+
suggestion = "f32::MAX"
7878
)]
7979
pub const MAX: f32 = f32::MAX;
8080

@@ -83,7 +83,7 @@ pub const MAX: f32 = f32::MAX;
8383
#[rustc_deprecated(
8484
since = "1.46.0",
8585
reason = "The associated constant `f32::MIN_EXP` is now prefered",
86-
suggestion = "f32::MIN_EXP",
86+
suggestion = "f32::MIN_EXP"
8787
)]
8888
pub const MIN_EXP: i32 = f32::MIN_EXP;
8989

@@ -92,7 +92,7 @@ pub const MIN_EXP: i32 = f32::MIN_EXP;
9292
#[rustc_deprecated(
9393
since = "1.46.0",
9494
reason = "The associated constant `f32::MAX_EXP` is now prefered",
95-
suggestion = "f32::MAX_EXP",
95+
suggestion = "f32::MAX_EXP"
9696
)]
9797
pub const MAX_EXP: i32 = f32::MAX_EXP;
9898

@@ -101,7 +101,7 @@ pub const MAX_EXP: i32 = f32::MAX_EXP;
101101
#[rustc_deprecated(
102102
since = "1.46.0",
103103
reason = "The associated constant `f32::MIN_10_EXP` is now prefered",
104-
suggestion = "f32::MIN_10_EXP",
104+
suggestion = "f32::MIN_10_EXP"
105105
)]
106106
pub const MIN_10_EXP: i32 = f32::MIN_10_EXP;
107107

@@ -110,7 +110,7 @@ pub const MIN_10_EXP: i32 = f32::MIN_10_EXP;
110110
#[rustc_deprecated(
111111
since = "1.46.0",
112112
reason = "The associated constant `f32::MAX_10_EXP` is now prefered",
113-
suggestion = "f32::MAX_10_EXP",
113+
suggestion = "f32::MAX_10_EXP"
114114
)]
115115
pub const MAX_10_EXP: i32 = f32::MAX_10_EXP;
116116

@@ -119,7 +119,7 @@ pub const MAX_10_EXP: i32 = f32::MAX_10_EXP;
119119
#[rustc_deprecated(
120120
since = "1.46.0",
121121
reason = "The associated constant `f32::NAN` is now prefered",
122-
suggestion = "f32::NAN",
122+
suggestion = "f32::NAN"
123123
)]
124124
pub const NAN: f32 = f32::NAN;
125125

@@ -128,7 +128,7 @@ pub const NAN: f32 = f32::NAN;
128128
#[rustc_deprecated(
129129
since = "1.46.0",
130130
reason = "The associated constant `f32::INFINITY` is now prefered",
131-
suggestion = "f32::INFINITY",
131+
suggestion = "f32::INFINITY"
132132
)]
133133
pub const INFINITY: f32 = f32::INFINITY;
134134

@@ -137,7 +137,7 @@ pub const INFINITY: f32 = f32::INFINITY;
137137
#[rustc_deprecated(
138138
since = "1.46.0",
139139
reason = "The associated constant `f32::NEG_INFINITY` is now prefered",
140-
suggestion = "f32::NEG_INFINITY",
140+
suggestion = "f32::NEG_INFINITY"
141141
)]
142142
pub const NEG_INFINITY: f32 = f32::NEG_INFINITY;
143143

0 commit comments

Comments
 (0)