Skip to content

Commit f28e387

Browse files
authored
Rollup merge of #71366 - faern:use-assoc-int-consts3, r=dtolnay
Use assoc int consts3 Define module level int consts with associated constants instead of `min_value()` and `max_value()`. So the code become consistent with what the docs recommend etc. Seems natural. Also remove the last usages of the int module constants from this repo (except src/test/ directory which I have still not really done anything in). Some places were missed in the previous PRs because the code uses `crate::<IntTy>` to reach the constants. This is a continuation of #70857 r? @dtolnay
2 parents 567e54f + 9af047f commit f28e387

File tree

16 files changed

+21
-28
lines changed

16 files changed

+21
-28
lines changed

src/libcore/iter/adapters/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use crate::cmp;
22
use crate::fmt;
33
use crate::intrinsics;
44
use crate::ops::{Add, AddAssign, Try};
5-
use crate::usize;
65

76
use super::{from_fn, LoopState};
87
use super::{DoubleEndedIterator, ExactSizeIterator, FusedIterator, Iterator, TrustedLen};

src/libcore/iter/range.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use crate::convert::TryFrom;
22
use crate::mem;
33
use crate::ops::{self, Add, Sub, Try};
4-
use crate::usize;
54

65
use super::{FusedIterator, TrustedLen};
76

src/libcore/iter/sources.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::fmt;
22
use crate::marker;
3-
use crate::usize;
43

54
use super::{FusedIterator, TrustedLen};
65

src/libcore/num/f32.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ impl f32 {
265265
#[stable(feature = "rust1", since = "1.0.0")]
266266
#[inline]
267267
pub fn is_infinite(self) -> bool {
268-
self.abs_private() == INFINITY
268+
self.abs_private() == Self::INFINITY
269269
}
270270

271271
/// Returns `true` if this number is neither infinite nor `NaN`.
@@ -287,7 +287,7 @@ impl f32 {
287287
pub fn is_finite(self) -> bool {
288288
// There's no need to handle NaN separately: if self is NaN,
289289
// the comparison is not true, exactly as desired.
290-
self.abs_private() < INFINITY
290+
self.abs_private() < Self::INFINITY
291291
}
292292

293293
/// Returns `true` if the number is neither zero, infinite,

src/libcore/num/f64.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ impl f64 {
264264
#[stable(feature = "rust1", since = "1.0.0")]
265265
#[inline]
266266
pub fn is_infinite(self) -> bool {
267-
self.abs_private() == INFINITY
267+
self.abs_private() == Self::INFINITY
268268
}
269269

270270
/// Returns `true` if this number is neither infinite nor `NaN`.
@@ -286,7 +286,7 @@ impl f64 {
286286
pub fn is_finite(self) -> bool {
287287
// There's no need to handle NaN separately: if self is NaN,
288288
// the comparison is not true, exactly as desired.
289-
self.abs_private() < INFINITY
289+
self.abs_private() < Self::INFINITY
290290
}
291291

292292
/// Returns `true` if the number is neither zero, infinite,

src/libcore/num/flt2dec/decoder.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
33
use crate::num::dec2flt::rawfp::RawFloat;
44
use crate::num::FpCategory;
5-
use crate::{f32, f64};
65

76
/// Decoded unsigned finite value, such that:
87
///

src/libcore/num/flt2dec/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ functions.
123123
)]
124124

125125
pub use self::decoder::{decode, DecodableFloat, Decoded, FullDecoded};
126-
use crate::i16;
127126

128127
pub mod decoder;
129128
pub mod estimator;

src/libcore/num/int_macros.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ macro_rules! int_module {
1414
concat!("The smallest value that can be represented by this integer type.
1515
Use [`", stringify!($T), "::MIN", "`](../../std/primitive.", stringify!($T), ".html#associatedconstant.MIN) instead."),
1616
#[$attr]
17-
pub const MIN: $T = $T::min_value();
17+
pub const MIN: $T = $T::MIN;
1818
}
1919

2020
doc_comment! {
2121
concat!("The largest value that can be represented by this integer type.
2222
Use [`", stringify!($T), "::MAX", "`](../../std/primitive.", stringify!($T), ".html#associatedconstant.MAX) instead."),
2323
#[$attr]
24-
pub const MAX: $T = $T::max_value();
24+
pub const MAX: $T = $T::MAX;
2525
}
2626
)
2727
}

src/libcore/slice/memchr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fn repeat_byte(b: u8) -> usize {
3434
#[cfg(not(target_pointer_width = "16"))]
3535
#[inline]
3636
fn repeat_byte(b: u8) -> usize {
37-
(b as usize) * (crate::usize::MAX / 255)
37+
(b as usize) * (usize::MAX / 255)
3838
}
3939

4040
/// Returns the first index matching the byte `x` in `text`.

src/libcore/slice/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ use crate::cmp;
2828
use crate::cmp::Ordering::{self, Equal, Greater, Less};
2929
use crate::fmt;
3030
use crate::intrinsics::{assume, exact_div, is_aligned_and_not_null, unchecked_sub};
31-
use crate::isize;
3231
use crate::iter::*;
3332
use crate::marker::{self, Copy, Send, Sized, Sync};
3433
use crate::mem;

0 commit comments

Comments
 (0)