Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use assoc int consts3 #71366

Merged
merged 4 commits into from
Apr 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/libcore/iter/adapters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::cmp;
use crate::fmt;
use crate::intrinsics;
use crate::ops::{Add, AddAssign, Try};
use crate::usize;

use super::{from_fn, LoopState};
use super::{DoubleEndedIterator, ExactSizeIterator, FusedIterator, Iterator, TrustedLen};
Expand Down
1 change: 0 additions & 1 deletion src/libcore/iter/range.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::convert::TryFrom;
use crate::mem;
use crate::ops::{self, Add, Sub, Try};
use crate::usize;

use super::{FusedIterator, TrustedLen};

Expand Down
1 change: 0 additions & 1 deletion src/libcore/iter/sources.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::fmt;
use crate::marker;
use crate::usize;

use super::{FusedIterator, TrustedLen};

Expand Down
4 changes: 2 additions & 2 deletions src/libcore/num/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ impl f32 {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn is_infinite(self) -> bool {
self.abs_private() == INFINITY
self.abs_private() == Self::INFINITY
}

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

/// Returns `true` if the number is neither zero, infinite,
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/num/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ impl f64 {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn is_infinite(self) -> bool {
self.abs_private() == INFINITY
self.abs_private() == Self::INFINITY
}

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

/// Returns `true` if the number is neither zero, infinite,
Expand Down
1 change: 0 additions & 1 deletion src/libcore/num/flt2dec/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use crate::num::dec2flt::rawfp::RawFloat;
use crate::num::FpCategory;
use crate::{f32, f64};

/// Decoded unsigned finite value, such that:
///
Expand Down
1 change: 0 additions & 1 deletion src/libcore/num/flt2dec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ functions.
)]

pub use self::decoder::{decode, DecodableFloat, Decoded, FullDecoded};
use crate::i16;

pub mod decoder;
pub mod estimator;
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/num/int_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ macro_rules! int_module {
concat!("The smallest value that can be represented by this integer type.
Use [`", stringify!($T), "::MIN", "`](../../std/primitive.", stringify!($T), ".html#associatedconstant.MIN) instead."),
#[$attr]
pub const MIN: $T = $T::min_value();
pub const MIN: $T = $T::MIN;
}

doc_comment! {
concat!("The largest value that can be represented by this integer type.
Use [`", stringify!($T), "::MAX", "`](../../std/primitive.", stringify!($T), ".html#associatedconstant.MAX) instead."),
#[$attr]
pub const MAX: $T = $T::max_value();
pub const MAX: $T = $T::MAX;
}
)
}
2 changes: 1 addition & 1 deletion src/libcore/slice/memchr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn repeat_byte(b: u8) -> usize {
#[cfg(not(target_pointer_width = "16"))]
#[inline]
fn repeat_byte(b: u8) -> usize {
(b as usize) * (crate::usize::MAX / 255)
(b as usize) * (usize::MAX / 255)
}

/// Returns the first index matching the byte `x` in `text`.
Expand Down
1 change: 0 additions & 1 deletion src/libcore/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ use crate::cmp;
use crate::cmp::Ordering::{self, Equal, Greater, Less};
use crate::fmt;
use crate::intrinsics::{assume, exact_div, is_aligned_and_not_null, unchecked_sub};
use crate::isize;
use crate::iter::*;
use crate::marker::{self, Copy, Send, Sized, Sync};
use crate::mem;
Expand Down
1 change: 0 additions & 1 deletion src/libcore/str/pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use crate::cmp;
use crate::fmt;
use crate::slice::memchr;
use crate::usize;

// Pattern

Expand Down
2 changes: 1 addition & 1 deletion src/libcore/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
//! assert_eq!(Duration::new(5, 0), Duration::from_secs(5));
//! ```

use crate::fmt;
use crate::iter::Sum;
use crate::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign};
use crate::{fmt, u64};

const NANOS_PER_SEC: u32 = 1_000_000_000;
const NANOS_PER_MILLI: u32 = 1_000_000;
Expand Down
8 changes: 4 additions & 4 deletions src/libstd/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl f32 {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn signum(self) -> f32 {
if self.is_nan() { NAN } else { 1.0_f32.copysign(self) }
if self.is_nan() { Self::NAN } else { 1.0_f32.copysign(self) }
}

/// Returns a number composed of the magnitude of `self` and the sign of
Expand Down Expand Up @@ -832,8 +832,8 @@ impl f32 {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn asinh(self) -> f32 {
if self == NEG_INFINITY {
NEG_INFINITY
if self == Self::NEG_INFINITY {
Self::NEG_INFINITY
} else {
(self + ((self * self) + 1.0).sqrt()).ln().copysign(self)
}
Expand All @@ -855,7 +855,7 @@ impl f32 {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn acosh(self) -> f32 {
if self < 1.0 { crate::f32::NAN } else { (self + ((self * self) - 1.0).sqrt()).ln() }
if self < 1.0 { Self::NAN } else { (self + ((self * self) - 1.0).sqrt()).ln() }
}

/// Inverse hyperbolic tangent function.
Expand Down
14 changes: 7 additions & 7 deletions src/libstd/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl f64 {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn signum(self) -> f64 {
if self.is_nan() { NAN } else { 1.0_f64.copysign(self) }
if self.is_nan() { Self::NAN } else { 1.0_f64.copysign(self) }
}

/// Returns a number composed of the magnitude of `self` and the sign of
Expand Down Expand Up @@ -834,8 +834,8 @@ impl f64 {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn asinh(self) -> f64 {
if self == NEG_INFINITY {
NEG_INFINITY
if self == Self::NEG_INFINITY {
Self::NEG_INFINITY
} else {
(self + ((self * self) + 1.0).sqrt()).ln().copysign(self)
}
Expand All @@ -857,7 +857,7 @@ impl f64 {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn acosh(self) -> f64 {
if self < 1.0 { NAN } else { (self + ((self * self) - 1.0).sqrt()).ln() }
if self < 1.0 { Self::NAN } else { (self + ((self * self) - 1.0).sqrt()).ln() }
}

/// Inverse hyperbolic tangent function.
Expand Down Expand Up @@ -926,16 +926,16 @@ impl f64 {
if self > 0.0 {
log_fn(self)
} else if self == 0.0 {
NEG_INFINITY // log(0) = -Inf
Self::NEG_INFINITY // log(0) = -Inf
} else {
NAN // log(-n) = NaN
Self::NAN // log(-n) = NaN
}
} else if self.is_nan() {
self // log(NaN) = NaN
} else if self > 0.0 {
self // log(Inf) = Inf
} else {
NAN // log(-Inf) = NaN
Self::NAN // log(-Inf) = NaN
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/thread/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,7 @@ impl ThreadId {

// If we somehow use up all our bits, panic so that we're not
// covering up subtle bugs of IDs being reused.
if COUNTER == crate::u64::MAX {
if COUNTER == u64::MAX {
panic!("failed to generate unique thread ID: bitspace exhausted");
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc/show-const-contents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub const MY_TYPE_WITH_STR: MyTypeWithStr = MyTypeWithStr("show this");
// @has show_const_contents/constant.PI.html '; // 3.14159274f32'
pub use std::f32::consts::PI;

// @has show_const_contents/constant.MAX.html '= i32::max_value(); // 2_147_483_647i32'
// @has show_const_contents/constant.MAX.html '= i32::MAX; // 2_147_483_647i32'
pub use std::i32::MAX;

macro_rules! int_module {
Expand Down