diff options
| author | bors <bors@rust-lang.org> | 2019-04-18 17:48:21 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-04-18 17:48:21 +0000 |
| commit | 5d20ff4d2718c820632b38c1e49d4de648a9810b (patch) | |
| tree | a9aa3fcb675be47650c5dd9d35a76f65784e8850 /src/libcore/num | |
| parent | d6f513ec7d1e83c8689f94fb48686dd11f1d1c80 (diff) | |
| parent | e28bce7a518824a90a23f1e1e79ba62507d9dc44 (diff) | |
Auto merge of #58702 - taiki-e:libcore-2018, r=Centril
libcore => 2018 Transitions `libcore` to Rust 2018; cc #58099 r? @Centril
Diffstat (limited to 'src/libcore/num')
| -rw-r--r-- | src/libcore/num/bignum.rs | 60 | ||||
| -rw-r--r-- | src/libcore/num/dec2flt/algorithm.rs | 14 | ||||
| -rw-r--r-- | src/libcore/num/dec2flt/mod.rs | 4 | ||||
| -rw-r--r-- | src/libcore/num/dec2flt/num.rs | 4 | ||||
| -rw-r--r-- | src/libcore/num/dec2flt/rawfp.rs | 18 | ||||
| -rw-r--r-- | src/libcore/num/f32.rs | 4 | ||||
| -rw-r--r-- | src/libcore/num/f64.rs | 4 | ||||
| -rw-r--r-- | src/libcore/num/flt2dec/decoder.rs | 6 | ||||
| -rw-r--r-- | src/libcore/num/flt2dec/mod.rs | 2 | ||||
| -rw-r--r-- | src/libcore/num/flt2dec/strategy/dragon.rs | 10 | ||||
| -rw-r--r-- | src/libcore/num/flt2dec/strategy/grisu.rs | 8 | ||||
| -rw-r--r-- | src/libcore/num/mod.rs | 38 | ||||
| -rw-r--r-- | src/libcore/num/wrapping.rs | 2 |
13 files changed, 87 insertions, 87 deletions
diff --git a/src/libcore/num/bignum.rs b/src/libcore/num/bignum.rs index c3a42a0fc04..64699e85d0c 100644 --- a/src/libcore/num/bignum.rs +++ b/src/libcore/num/bignum.rs @@ -17,8 +17,8 @@ issue = "0")] #![macro_use] -use mem; -use intrinsics; +use crate::mem; +use crate::intrinsics; /// Arithmetic operations required by bignums. pub trait FullOps: Sized { @@ -128,7 +128,7 @@ macro_rules! define_bignum { /// Makes a bignum from `u64` value. pub fn from_u64(mut v: u64) -> $name { - use mem; + use crate::mem; let mut base = [0; $n]; let mut sz = 0; @@ -150,7 +150,7 @@ macro_rules! define_bignum { /// Returns the `i`-th bit where bit 0 is the least significant one. /// In other words, the bit with weight `2^i`. pub fn get_bit(&self, i: usize) -> u8 { - use mem; + use crate::mem; let digitbits = mem::size_of::<$ty>() * 8; let d = i / digitbits; @@ -166,7 +166,7 @@ macro_rules! define_bignum { /// Returns the number of bits necessary to represent this value. Note that zero /// is considered to need 0 bits. pub fn bit_length(&self) -> usize { - use mem; + use crate::mem; // Skip over the most significant digits which are zero. let digits = self.digits(); @@ -190,8 +190,8 @@ macro_rules! define_bignum { /// Adds `other` to itself and returns its own mutable reference. pub fn add<'a>(&'a mut self, other: &$name) -> &'a mut $name { - use cmp; - use num::bignum::FullOps; + use crate::cmp; + use crate::num::bignum::FullOps; let mut sz = cmp::max(self.size, other.size); let mut carry = false; @@ -209,7 +209,7 @@ macro_rules! define_bignum { } pub fn add_small(&mut self, other: $ty) -> &mut $name { - use num::bignum::FullOps; + use crate::num::bignum::FullOps; let (mut carry, v) = self.base[0].full_add(other, false); self.base[0] = v; @@ -228,8 +228,8 @@ macro_rules! define_bignum { /// Subtracts `other` from itself and returns its own mutable reference. pub fn sub<'a>(&'a mut self, other: &$name) -> &'a mut $name { - use cmp; - use num::bignum::FullOps; + use crate::cmp; + use crate::num::bignum::FullOps; let sz = cmp::max(self.size, other.size); let mut noborrow = true; @@ -246,7 +246,7 @@ macro_rules! define_bignum { /// Multiplies itself by a digit-sized `other` and returns its own /// mutable reference. pub fn mul_small(&mut self, other: $ty) -> &mut $name { - use num::bignum::FullOps; + use crate::num::bignum::FullOps; let mut sz = self.size; let mut carry = 0; @@ -265,7 +265,7 @@ macro_rules! define_bignum { /// Multiplies itself by `2^bits` and returns its own mutable reference. pub fn mul_pow2(&mut self, bits: usize) -> &mut $name { - use mem; + use crate::mem; let digitbits = mem::size_of::<$ty>() * 8; let digits = bits / digitbits; @@ -306,8 +306,8 @@ macro_rules! define_bignum { /// Multiplies itself by `5^e` and returns its own mutable reference. pub fn mul_pow5(&mut self, mut e: usize) -> &mut $name { - use mem; - use num::bignum::SMALL_POW5; + use crate::mem; + use crate::num::bignum::SMALL_POW5; // There are exactly n trailing zeros on 2^n, and the only relevant digit sizes // are consecutive powers of two, so this is well suited index for the table. @@ -338,7 +338,7 @@ macro_rules! define_bignum { pub fn mul_digits<'a>(&'a mut self, other: &[$ty]) -> &'a mut $name { // the internal routine. works best when aa.len() <= bb.len(). fn mul_inner(ret: &mut [$ty; $n], aa: &[$ty], bb: &[$ty]) -> usize { - use num::bignum::FullOps; + use crate::num::bignum::FullOps; let mut retsz = 0; for (i, &a) in aa.iter().enumerate() { @@ -375,7 +375,7 @@ macro_rules! define_bignum { /// Divides itself by a digit-sized `other` and returns its own /// mutable reference *and* the remainder. pub fn div_rem_small(&mut self, other: $ty) -> (&mut $name, $ty) { - use num::bignum::FullOps; + use crate::num::bignum::FullOps; assert!(other > 0); @@ -392,7 +392,7 @@ macro_rules! define_bignum { /// Divide self by another bignum, overwriting `q` with the quotient and `r` with the /// remainder. pub fn div_rem(&self, d: &$name, q: &mut $name, r: &mut $name) { - use mem; + use crate::mem; // Stupid slow base-2 long division taken from // https://en.wikipedia.org/wiki/Division_algorithm @@ -429,22 +429,22 @@ macro_rules! define_bignum { } } - impl ::cmp::PartialEq for $name { + impl crate::cmp::PartialEq for $name { fn eq(&self, other: &$name) -> bool { self.base[..] == other.base[..] } } - impl ::cmp::Eq for $name { + impl crate::cmp::Eq for $name { } - impl ::cmp::PartialOrd for $name { - fn partial_cmp(&self, other: &$name) -> ::option::Option<::cmp::Ordering> { - ::option::Option::Some(self.cmp(other)) + impl crate::cmp::PartialOrd for $name { + fn partial_cmp(&self, other: &$name) -> crate::option::Option<crate::cmp::Ordering> { + crate::option::Option::Some(self.cmp(other)) } } - impl ::cmp::Ord for $name { - fn cmp(&self, other: &$name) -> ::cmp::Ordering { - use cmp::max; + impl crate::cmp::Ord for $name { + fn cmp(&self, other: &$name) -> crate::cmp::Ordering { + use crate::cmp::max; let sz = max(self.size, other.size); let lhs = self.base[..sz].iter().cloned().rev(); let rhs = other.base[..sz].iter().cloned().rev(); @@ -452,15 +452,15 @@ macro_rules! define_bignum { } } - impl ::clone::Clone for $name { + impl crate::clone::Clone for $name { fn clone(&self) -> $name { $name { size: self.size, base: self.base } } } - impl ::fmt::Debug for $name { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { - use mem; + impl crate::fmt::Debug for $name { + fn fmt(&self, f: &mut crate::fmt::Formatter) -> crate::fmt::Result { + use crate::mem; let sz = if self.size < 1 {1} else {self.size}; let digitlen = mem::size_of::<$ty>() * 2; @@ -469,7 +469,7 @@ macro_rules! define_bignum { for &v in self.base[..sz-1].iter().rev() { write!(f, "_{:01$x}", v, digitlen)?; } - ::result::Result::Ok(()) + crate::result::Result::Ok(()) } } ) diff --git a/src/libcore/num/dec2flt/algorithm.rs b/src/libcore/num/dec2flt/algorithm.rs index a83134a6b2c..fa3c8075378 100644 --- a/src/libcore/num/dec2flt/algorithm.rs +++ b/src/libcore/num/dec2flt/algorithm.rs @@ -1,11 +1,11 @@ //! The various algorithms from the paper. -use cmp::min; -use cmp::Ordering::{Less, Equal, Greater}; -use num::diy_float::Fp; -use num::dec2flt::table; -use num::dec2flt::rawfp::{self, Unpacked, RawFloat, fp_to_float, next_float, prev_float}; -use num::dec2flt::num::{self, Big}; +use crate::cmp::min; +use crate::cmp::Ordering::{Less, Equal, Greater}; +use crate::num::diy_float::Fp; +use crate::num::dec2flt::table; +use crate::num::dec2flt::rawfp::{self, Unpacked, RawFloat, fp_to_float, next_float, prev_float}; +use crate::num::dec2flt::num::{self, Big}; /// Number of significand bits in Fp const P: u32 = 64; @@ -35,7 +35,7 @@ mod fpu_precision { // computations are performed in the desired precision. #[cfg(all(target_arch="x86", not(target_feature="sse2")))] mod fpu_precision { - use mem::size_of; + use crate::mem::size_of; /// A structure used to preserve the original value of the FPU control word, so that it can be /// restored when the structure is dropped. diff --git a/src/libcore/num/dec2flt/mod.rs b/src/libcore/num/dec2flt/mod.rs index d62cdae0688..dcfa2d352a8 100644 --- a/src/libcore/num/dec2flt/mod.rs +++ b/src/libcore/num/dec2flt/mod.rs @@ -82,8 +82,8 @@ reason = "internal routines only exposed for testing", issue = "0")] -use fmt; -use str::FromStr; +use crate::fmt; +use crate::str::FromStr; use self::parse::{parse_decimal, Decimal, Sign, ParseResult}; use self::num::digits_to_big; diff --git a/src/libcore/num/dec2flt/num.rs b/src/libcore/num/dec2flt/num.rs index 12671318571..4d50516ce54 100644 --- a/src/libcore/num/dec2flt/num.rs +++ b/src/libcore/num/dec2flt/num.rs @@ -2,9 +2,9 @@ // FIXME This module's name is a bit unfortunate, since other modules also import `core::num`. -use cmp::Ordering::{self, Less, Equal, Greater}; +use crate::cmp::Ordering::{self, Less, Equal, Greater}; -pub use num::bignum::Big32x40 as Big; +pub use crate::num::bignum::Big32x40 as Big; /// Test whether truncating all bits less significant than `ones_place` introduces /// a relative error less, equal, or greater than 0.5 ULP. diff --git a/src/libcore/num/dec2flt/rawfp.rs b/src/libcore/num/dec2flt/rawfp.rs index b65f539b29c..fdbdaa238e0 100644 --- a/src/libcore/num/dec2flt/rawfp.rs +++ b/src/libcore/num/dec2flt/rawfp.rs @@ -17,15 +17,15 @@ //! Many functions in this module only handle normal numbers. The dec2flt routines conservatively //! take the universally-correct slow path (Algorithm M) for very small and very large numbers. //! That algorithm needs only next_float() which does handle subnormals and zeros. -use cmp::Ordering::{Less, Equal, Greater}; -use convert::{TryFrom, TryInto}; -use ops::{Add, Mul, Div, Neg}; -use fmt::{Debug, LowerExp}; -use num::diy_float::Fp; -use num::FpCategory::{Infinite, Zero, Subnormal, Normal, Nan}; -use num::FpCategory; -use num::dec2flt::num::{self, Big}; -use num::dec2flt::table; +use crate::cmp::Ordering::{Less, Equal, Greater}; +use crate::convert::{TryFrom, TryInto}; +use crate::ops::{Add, Mul, Div, Neg}; +use crate::fmt::{Debug, LowerExp}; +use crate::num::diy_float::Fp; +use crate::num::FpCategory::{Infinite, Zero, Subnormal, Normal, Nan}; +use crate::num::FpCategory; +use crate::num::dec2flt::num::{self, Big}; +use crate::num::dec2flt::table; #[derive(Copy, Clone, Debug)] pub struct Unpacked { diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index dc0580764ac..3f8d142c845 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -7,8 +7,8 @@ #![stable(feature = "rust1", since = "1.0.0")] -use mem; -use num::FpCategory; +use crate::mem; +use crate::num::FpCategory; /// The radix or base of the internal representation of `f32`. #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index c3677f8c8fa..7f19101fe6e 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -7,8 +7,8 @@ #![stable(feature = "rust1", since = "1.0.0")] -use mem; -use num::FpCategory; +use crate::mem; +use crate::num::FpCategory; /// The radix or base of the internal representation of `f64`. #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcore/num/flt2dec/decoder.rs b/src/libcore/num/flt2dec/decoder.rs index a8da31d3e48..6c75d00f6b2 100644 --- a/src/libcore/num/flt2dec/decoder.rs +++ b/src/libcore/num/flt2dec/decoder.rs @@ -1,8 +1,8 @@ //! Decodes a floating-point value into individual parts and error ranges. -use {f32, f64}; -use num::FpCategory; -use num::dec2flt::rawfp::RawFloat; +use crate::{f32, f64}; +use crate::num::FpCategory; +use crate::num::dec2flt::rawfp::RawFloat; /// Decoded unsigned finite value, such that: /// diff --git a/src/libcore/num/flt2dec/mod.rs b/src/libcore/num/flt2dec/mod.rs index c9a9375ec59..6d42a777449 100644 --- a/src/libcore/num/flt2dec/mod.rs +++ b/src/libcore/num/flt2dec/mod.rs @@ -120,7 +120,7 @@ functions. reason = "internal routines only exposed for testing", issue = "0")] -use i16; +use crate::i16; pub use self::decoder::{decode, DecodableFloat, FullDecoded, Decoded}; pub mod estimator; diff --git a/src/libcore/num/flt2dec/strategy/dragon.rs b/src/libcore/num/flt2dec/strategy/dragon.rs index 582fe22f854..35fb4b92758 100644 --- a/src/libcore/num/flt2dec/strategy/dragon.rs +++ b/src/libcore/num/flt2dec/strategy/dragon.rs @@ -4,12 +4,12 @@ //! [^1]: Burger, R. G. and Dybvig, R. K. 1996. Printing floating-point numbers //! quickly and accurately. SIGPLAN Not. 31, 5 (May. 1996), 108-116. -use cmp::Ordering; +use crate::cmp::Ordering; -use num::flt2dec::{Decoded, MAX_SIG_DIGITS, round_up}; -use num::flt2dec::estimator::estimate_scaling_factor; -use num::bignum::Digit32 as Digit; -use num::bignum::Big32x40 as Big; +use crate::num::flt2dec::{Decoded, MAX_SIG_DIGITS, round_up}; +use crate::num::flt2dec::estimator::estimate_scaling_factor; +use crate::num::bignum::Digit32 as Digit; +use crate::num::bignum::Big32x40 as Big; static POW10: [Digit; 10] = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]; diff --git a/src/libcore/num/flt2dec/strategy/grisu.rs b/src/libcore/num/flt2dec/strategy/grisu.rs index aa21fcffa5c..61b50ec8ca5 100644 --- a/src/libcore/num/flt2dec/strategy/grisu.rs +++ b/src/libcore/num/flt2dec/strategy/grisu.rs @@ -5,8 +5,8 @@ //! [^1]: Florian Loitsch. 2010. Printing floating-point numbers quickly and //! accurately with integers. SIGPLAN Not. 45, 6 (June 2010), 233-243. -use num::diy_float::Fp; -use num::flt2dec::{Decoded, MAX_SIG_DIGITS, round_up}; +use crate::num::diy_float::Fp; +use crate::num::flt2dec::{Decoded, MAX_SIG_DIGITS, round_up}; // see the comments in `format_shortest_opt` for the rationale. @@ -418,7 +418,7 @@ pub fn format_shortest_opt(d: &Decoded, /// /// This should be used for most cases. pub fn format_shortest(d: &Decoded, buf: &mut [u8]) -> (/*#digits*/ usize, /*exp*/ i16) { - use num::flt2dec::strategy::dragon::format_shortest as fallback; + use crate::num::flt2dec::strategy::dragon::format_shortest as fallback; match format_shortest_opt(d, buf) { Some(ret) => ret, None => fallback(d, buf), @@ -675,7 +675,7 @@ pub fn format_exact_opt(d: &Decoded, buf: &mut [u8], limit: i16) /// /// This should be used for most cases. pub fn format_exact(d: &Decoded, buf: &mut [u8], limit: i16) -> (/*#digits*/ usize, /*exp*/ i16) { - use num::flt2dec::strategy::dragon::format_exact as fallback; + use crate::num::flt2dec::strategy::dragon::format_exact as fallback; match format_exact_opt(d, buf, limit) { Some(ret) => ret, None => fallback(d, buf, limit), diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index b372bd3cb07..24afc945e93 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -2,12 +2,12 @@ #![stable(feature = "rust1", since = "1.0.0")] -use convert::{TryFrom, Infallible}; -use fmt; -use intrinsics; -use mem; -use ops; -use str::FromStr; +use crate::convert::{TryFrom, Infallible}; +use crate::fmt; +use crate::intrinsics; +use crate::mem; +use crate::ops; +use crate::str::FromStr; macro_rules! impl_nonzero_fmt { ( #[$stability: meta] ( $( $Trait: ident ),+ ) for $Ty: ident ) => { @@ -3939,7 +3939,7 @@ impl u8 { #[inline] pub fn is_ascii_alphabetic(&self) -> bool { match *self { - b'A'...b'Z' | b'a'...b'z' => true, + b'A'..=b'Z' | b'a'..=b'z' => true, _ => false } } @@ -3974,7 +3974,7 @@ impl u8 { #[inline] pub fn is_ascii_uppercase(&self) -> bool { match *self { - b'A'...b'Z' => true, + b'A'..=b'Z' => true, _ => false } } @@ -4009,7 +4009,7 @@ impl u8 { #[inline] pub fn is_ascii_lowercase(&self) -> bool { match *self { - b'a'...b'z' => true, + b'a'..=b'z' => true, _ => false } } @@ -4047,7 +4047,7 @@ impl u8 { #[inline] pub fn is_ascii_alphanumeric(&self) -> bool { match *self { - b'0'...b'9' | b'A'...b'Z' | b'a'...b'z' => true, + b'0'..=b'9' | b'A'..=b'Z' | b'a'..=b'z' => true, _ => false } } @@ -4082,7 +4082,7 @@ impl u8 { #[inline] pub fn is_ascii_digit(&self) -> bool { match *self { - b'0'...b'9' => true, + b'0'..=b'9' => true, _ => false } } @@ -4120,7 +4120,7 @@ impl u8 { #[inline] pub fn is_ascii_hexdigit(&self) -> bool { match *self { - b'0'...b'9' | b'A'...b'F' | b'a'...b'f' => true, + b'0'..=b'9' | b'A'..=b'F' | b'a'..=b'f' => true, _ => false } } @@ -4159,7 +4159,7 @@ impl u8 { #[inline] pub fn is_ascii_punctuation(&self) -> bool { match *self { - b'!'...b'/' | b':'...b'@' | b'['...b'`' | b'{'...b'~' => true, + b'!'..=b'/' | b':'..=b'@' | b'['..=b'`' | b'{'..=b'~' => true, _ => false } } @@ -4194,7 +4194,7 @@ impl u8 { #[inline] pub fn is_ascii_graphic(&self) -> bool { match *self { - b'!'...b'~' => true, + b'!'..=b'~' => true, _ => false } } @@ -4283,7 +4283,7 @@ impl u8 { #[inline] pub fn is_ascii_control(&self) -> bool { match *self { - b'\0'...b'\x1F' | b'\x7F' => true, + b'\0'..=b'\x1F' | b'\x7F' => true, _ => false } } @@ -4573,7 +4573,7 @@ try_from_lower_bounded!(isize, usize); #[cfg(target_pointer_width = "16")] mod ptr_try_from_impls { use super::TryFromIntError; - use convert::TryFrom; + use crate::convert::TryFrom; try_from_upper_bounded!(usize, u8); try_from_unbounded!(usize, u16, u32, u64, u128); @@ -4596,7 +4596,7 @@ mod ptr_try_from_impls { #[cfg(target_pointer_width = "32")] mod ptr_try_from_impls { use super::TryFromIntError; - use convert::TryFrom; + use crate::convert::TryFrom; try_from_upper_bounded!(usize, u8, u16); try_from_unbounded!(usize, u32, u64, u128); @@ -4622,7 +4622,7 @@ mod ptr_try_from_impls { #[cfg(target_pointer_width = "64")] mod ptr_try_from_impls { use super::TryFromIntError; - use convert::TryFrom; + use crate::convert::TryFrom; try_from_upper_bounded!(usize, u8, u16, u32); try_from_unbounded!(usize, u64, u128); @@ -4826,7 +4826,7 @@ impl fmt::Display for ParseIntError { } #[stable(feature = "rust1", since = "1.0.0")] -pub use num::dec2flt::ParseFloatError; +pub use crate::num::dec2flt::ParseFloatError; // Conversion traits for primitive integer and float types // Conversions T -> T are covered by a blanket impl and therefore excluded diff --git a/src/libcore/num/wrapping.rs b/src/libcore/num/wrapping.rs index 9cd5108ade4..a3491bc3dc6 100644 --- a/src/libcore/num/wrapping.rs +++ b/src/libcore/num/wrapping.rs @@ -1,6 +1,6 @@ use super::Wrapping; -use ops::*; +use crate::ops::*; #[allow(unused_macros)] macro_rules! sh_impl_signed { |
