about summary refs log tree commit diff
path: root/src/libcore/num
AgeCommit message (Collapse)AuthorLines
2016-05-16Fix `asm!` blocksAndrea Canciani-2/+2
The `volatile` modifier was incorrectly written outside of the `asm!` blocks.
2016-05-16Cleanup documentationAndrea Canciani-31/+10
Remove irrelevant information (and instead provide pointer to reference documentation), replace ASCII-art table with the corresponding MarkDown one, and minor fixes.
2016-05-13Document the x87 control wordAndrea Canciani-5/+62
Explain the meaning of the fields of the control word and provide more details about how the relevant one (Precision Control) is updated in the fast path.
2016-05-13Fix fast path of float parsing on x87Andrea Canciani-7/+40
The fast path of the float parser relies on the rounding to happen exactly and directly to the correct number of bits. On x87, instead, double rounding would occour as the FPU stack defaults to 80 bits of precision. This can be fixed by setting the precision of the FPU stack before performing the int to float conversion. This can be achieved by changing the value of the x87 control word. This is a somewhat common operation that is in fact performed whenever a float needs to be truncated to an integer, but it is undesirable to add its overhead for code that does not rely on x87 for computations (i.e. on non-x86 architectures, or x86 architectures which perform FPU computations on using SSE). Fixes `num::dec2flt::fast_path_correct` (on x87).
2016-05-08Rollup merge of #33426 - sfackler:try-from, r=aturonManish Goregaokar-1/+94
Implement RFC 1542 cc #33417 r? @aturon
2016-05-07Rollup merge of #33428 - fiveop:wrapping_example, r=steveklabnikSteve Klabnik-0/+11
Add an example to Wrapping's documentation. Such an example would have helped me understand `Wrapping` quicker. r? @steveklabnik
2016-05-07Implement RFC 1542Steven Fackler-1/+94
cc #33417
2016-05-06Auto merge of #33138 - arielb1:sized-shortcut, r=nikomatsakisbors-1/+1
Short-cut `T: Sized` trait selection for ADTs Basically avoids all nested obligations when checking whether an ADT is sized - this speeds up typeck by ~15% The refactoring fixed #32963, but I also want to make `Copy` not object-safe (will commit that soon). Fixes #33201 r? @nikomatsakis
2016-05-05Auto merge of #33067 - notriddle:wrapping_neg, r=alexcrichtonbors-0/+9
Implement negation for wrapping numerals. Fixes #33037
2016-05-05Add an example to Wrapping's documentation.Philipp Matthias Schaefer-0/+11
2016-05-03require the non-last elements of a tuple to be SizedAriel Ben-Yehuda-1/+1
This requirement appears to be missing from RFC1214, but is clearly necessary for translation. The last field of a tuple/enum remains in a state of limbo, compiling but causing an ICE when it is used - we should eventually fix that somehow. this is a [breaking-change] - a soundness fix - and requires a crater run.
2016-04-30Impl int/uint::MIN/MAX in terms of min/max_valueSimonas Kazlauskas-0/+26
2016-04-20Implement negation for wrapping numerals.Michael Howell-0/+9
Fixes #33037
2016-04-17Rollup merge of #33023 - tbu-:pr_wrapping_traits, r=alexcrichtonManish Goregaokar-1/+15
Implement `Display` and `Hash` for `std::num::Wrapping` Also, change the `Debug` implementation to only show the inner value. Fixes #33006.
2016-04-16Implement `Display` and `Hash` for `std::num::Wrapping`Tobias Bucher-1/+15
Also, change the `Debug` implementation to only show the inner value. Fixes #33006.
2016-04-12Remove unused trait importsSeo Sanghyeon-1/+1
2016-04-10Match signed/unsigned integer type docsjethrogb-41/+53
* Copy documentation from signed implementation to unsigned implementation, where necessary. * Use signed integers in signed documentation, where possible.
2016-04-01Fix a couple of dead links on core::num::ParseFloatError docsOliver Middleton-2/+2
2016-03-22try! -> ?Jorge Aparicio-1/+1
Automated conversion using the untry tool [1] and the following command: ``` $ find -name '*.rs' -type f | xargs untry ``` at the root of the Rust repo. [1]: https://github.com/japaric/untry
2016-03-21Auto merge of #32054 - seanmonstar:impl-debug-core, r=alexcrichtonbors-0/+1
libcore: add Debug implementations to most missing types Also adds `#![deny(missing_debug_implementations)]` to the core crate. cc #31869
2016-03-20Update snapshots to 2016-03-18 (235d774).Eduard Burtescu-3/+3
2016-03-20libcore: add Debug implementations to most missing typesSean McArthur-0/+1
2016-03-17Add #[rustc_no_mir] to make tests pass with -Z orbit.Eduard Burtescu-0/+3
2016-03-12std: Clean out deprecated APIsAlex Crichton-176/+1
Removes all unstable and deprecated APIs prior to the 1.8 release. All APIs that are deprecated in the 1.8 release are sticking around for the rest of this cycle. Some notable changes are: * The `dynamic_lib` module was moved into `rustc_back` as the compiler still relies on a few bits and pieces. * The `DebugTuple` formatter now special-cases an empty struct name with only one field to append a trailing comma.
2016-03-11core: Make a new tracking issue for prelude traitsAlex Crichton-3/+3
The referenced issues here were both closed, so hook up a new issue which tracks specifically the prelude traits being unstable.
2016-03-11core: Mark Wrapping impls as stableAlex Crichton-5/+5
These are all insta-stable anyway, so just properly tag them.
2016-03-08doc: Fix a bunch of broken linksAlex Crichton-3/+3
A few categories: * Links into compiler docs were just all removed as we're not generating compiler docs. * Move up one more level to forcibly go to std docs to fix inlined documentation across the facade crates.
2016-03-01Rollup merge of #31965 - miqid:doc, r=steveklabnikSteve Klabnik-10/+10
Hello. Quite a few of the links in the `core` module concerning redirection to additional primitive type documentation are broken. I noticed in #30214 that there seemed to be a consensus with linking across to `std` module documentation from the `core` module. This is what I've done with the `core` modules for primitive types. If the changes here are good to go forward with, I'll happily tend to adding more documentation links for the extension traits in the aforementioned issue if need be. r? @steveklabnik
2016-03-01Fix broken links for core primitivesMichael Huynh-10/+10
Redirects existing links for more details on primitive types in the `core` module to the ones that exist in the `std` module.
2016-02-29std: Stabilize APIs for the 1.8 releaseAlex Crichton-8/+8
This commit is the result of the FCPs ending for the 1.8 release cycle for both the libs and the lang suteams. The full list of changes are: Stabilized * `braced_empty_structs` * `augmented_assignments` * `str::encode_utf16` - renamed from `utf16_units` * `str::EncodeUtf16` - renamed from `Utf16Units` * `Ref::map` * `RefMut::map` * `ptr::drop_in_place` * `time::Instant` * `time::SystemTime` * `{Instant,SystemTime}::now` * `{Instant,SystemTime}::duration_since` - renamed from `duration_from_earlier` * `{Instant,SystemTime}::elapsed` * Various `Add`/`Sub` impls for `Time` and `SystemTime` * `SystemTimeError` * `SystemTimeError::duration` * Various impls for `SystemTimeError` * `UNIX_EPOCH` * `ops::{Add,Sub,Mul,Div,Rem,BitAnd,BitOr,BitXor,Shl,Shr}Assign` Deprecated * Scoped TLS (the `scoped_thread_local!` macro) * `Ref::filter_map` * `RefMut::filter_map` * `RwLockReadGuard::map` * `RwLockWriteGuard::map` * `Condvar::wait_timeout_with` Closes #27714 Closes #27715 Closes #27746 Closes #27748 Closes #27908 Closes #29866
2016-02-26Use .copy_from_slice() where applicableUlrik Sverdrup-2/+2
.copy_from_slice() does the same job of .clone_from_slice(), but the former is explicitly for Copy elements and calls `memcpy` directly, and thus is it efficient without optimization too.
2016-02-15Auto merge of #31663 - nodakai:cleanup-uint_module, r=alexcrichtonbors-7/+7
2016-02-15libcore/num: Remove unused macro argument.NODA, Kai-7/+7
It is no longer necessary after dd0d495f50e2d8ba501e6b003cb4c1ef52d95ed5 Signed-off-by: NODA, Kai <nodakai@gmail.com>
2016-02-14Fix signed int checked_neg docsOliver Middleton-1/+1
2016-02-10Note rotate_{left,right} in wrapping_sh{lr} docsThomas Winwood-0/+14
2016-02-09Some docs for std::numSteve Klabnik-1/+19
This commit does two things: * Re-works the module-level documentation. * Cleaning up wording and adding links to where error types are used. Part of #29364
2016-02-04drive-by doc fixesRobin Kruppe-1/+1
2016-02-04Prevent the immediate panic uncovered by #31109 and add a test.Robin Kruppe-8/+28
The code there still triggers an ICE, but for different reasons (const eval unwraps the parse result).
2016-02-04Use the right target ratio in Algorithm M quickstart.Robin Kruppe-1/+1
Using f64's bit size probably wasn't actually *wrong*, but it would overshoot for no reason. This might have slowed down f32 parsing significantly.
2016-01-19fix the docs and simplify the implementation of unsigned wrapping opsOliver Schneider-50/+43
2016-01-16std: Stabilize APIs for the 1.7 releaseAlex Crichton-82/+66
This commit stabilizes and deprecates the FCP (final comment period) APIs for the upcoming 1.7 beta release. The specific APIs which changed were: Stabilized * `Path::strip_prefix` (renamed from `relative_from`) * `path::StripPrefixError` (new error type returned from `strip_prefix`) * `Ipv4Addr::is_loopback` * `Ipv4Addr::is_private` * `Ipv4Addr::is_link_local` * `Ipv4Addr::is_multicast` * `Ipv4Addr::is_broadcast` * `Ipv4Addr::is_documentation` * `Ipv6Addr::is_unspecified` * `Ipv6Addr::is_loopback` * `Ipv6Addr::is_unique_local` * `Ipv6Addr::is_multicast` * `Vec::as_slice` * `Vec::as_mut_slice` * `String::as_str` * `String::as_mut_str` * `<[T]>::clone_from_slice` - the `usize` return value is removed * `<[T]>::sort_by_key` * `i32::checked_rem` (and other signed types) * `i32::checked_neg` (and other signed types) * `i32::checked_shl` (and other signed types) * `i32::checked_shr` (and other signed types) * `i32::saturating_mul` (and other signed types) * `i32::overflowing_add` (and other signed types) * `i32::overflowing_sub` (and other signed types) * `i32::overflowing_mul` (and other signed types) * `i32::overflowing_div` (and other signed types) * `i32::overflowing_rem` (and other signed types) * `i32::overflowing_neg` (and other signed types) * `i32::overflowing_shl` (and other signed types) * `i32::overflowing_shr` (and other signed types) * `u32::checked_rem` (and other unsigned types) * `u32::checked_neg` (and other unsigned types) * `u32::checked_shl` (and other unsigned types) * `u32::saturating_mul` (and other unsigned types) * `u32::overflowing_add` (and other unsigned types) * `u32::overflowing_sub` (and other unsigned types) * `u32::overflowing_mul` (and other unsigned types) * `u32::overflowing_div` (and other unsigned types) * `u32::overflowing_rem` (and other unsigned types) * `u32::overflowing_neg` (and other unsigned types) * `u32::overflowing_shl` (and other unsigned types) * `u32::overflowing_shr` (and other unsigned types) * `ffi::IntoStringError` * `CString::into_string` * `CString::into_bytes` * `CString::into_bytes_with_nul` * `From<CString> for Vec<u8>` * `From<CString> for Vec<u8>` * `IntoStringError::into_cstring` * `IntoStringError::utf8_error` * `Error for IntoStringError` Deprecated * `Path::relative_from` - renamed to `strip_prefix` * `Path::prefix` - use `components().next()` instead * `os::unix::fs` constants - moved to the `libc` crate * `fmt::{radix, Radix, RadixFmt}` - not used enough to stabilize * `IntoCow` - conflicts with `Into` and may come back later * `i32::{BITS, BYTES}` (and other integers) - not pulling their weight * `DebugTuple::formatter` - will be removed * `sync::Semaphore` - not used enough and confused with system semaphores Closes #23284 cc #27709 (still lots more methods though) Closes #27712 Closes #27722 Closes #27728 Closes #27735 Closes #27729 Closes #27755 Closes #27782 Closes #27798
2016-01-14Auto merge of #30466 - alexcrichton:move-wrapping-and-fill-out, r=aturonbors-14/+658
This commit migrates all of the methods on `num::wrapping::OverflowingOps` onto inherent methods of the integer types. This also fills out some missing gaps in the saturating and checked departments such as: * `saturating_mul` * `checked_{neg,rem,shl,shr}` This is done in preparation for stabilization, cc #27755
2016-01-13Auto merge of #30639 - rkruppe:dec2flt-fastpath-tables, r=alexcrichtonbors-9/+59
Add tables of small powers of ten used in the fast path. The tables are redundant: We could also use the big, more accurate table and round the value to the correct type (in fact we did just that before this commit). However, the rounding is extra work and slows down the fast path. Because only very small exponents enter the fast path, the table and thus the space overhead is negligible. Speed-wise, this is a clear win on a [benchmark] comparing the fast path to a naive, hand-optimized, inaccurate algorithm. Specifically, this change narrows the gap from a roughly 5x difference to a roughly 3.4x difference. [benchmark]: https://gist.github.com/Veedrac/dbb0c07994bc7882098e
2016-01-12Speed up dec2flt fast path with additional tables.Robin Kruppe-9/+59
Add tables of small powers of ten used in the fast path. The tables are redundant: We could also use the big, more accurate table and round the value to the correct type (in fact we did just that before this commit). However, the rounding is extra work and slows down the fast path. Because only very small exponents enter the fast path, the table and thus the space overhead is negligible. Speed-wise, this is a clear win on a [benchmark] comparing the fast path to a naive, hand-optimized, inaccurate algorithm. Specifically, this change narrows the gap from a roughly 5x difference to a roughly 3.4x difference. [benchmark]: https://gist.github.com/Veedrac/dbb0c07994bc7882098e
2016-01-11std: Move overflowing ops to inherent methodsAlex Crichton-14/+658
This commit migrates all of the methods on `num::wrapping::OverflowingOps` onto inherent methods of the integer types. This also fills out some missing gaps in the saturating and checked departments such as: * `saturating_mul` * `checked_{neg,rem,shl,shr}` This is done in preparation for stabilization, cc #27755
2016-01-05Fix a breaking change in #30523Nicholas Mazzuca-15/+15
While this does fix a breaking change, it is also, technically, a [breaking-change] to go back to our original way
2016-01-04Auto merge of #30681 - Toby-S:master, r=blussbors-8/+9
Make `".".parse::<f32>()` and `".".parse::<f64>()` return Err This fixes #30344. This is a [breaking-change], which the libs team have classified as a bug fix.
2016-01-04Make float parsing "." return ErrToby Scrace-8/+9
This makes both of the following return Err: ".".parse::<f32>() ".".parse::<f64>() This is a [breaking-change], which the libs team have classified as a bug fix.
2016-01-02Take out Op<T>/OpAssign<T> for Wrapping<T>Nicholas Mazzuca-144/+1
2016-01-01In the middle of the implementationNicholas Mazzuca-208/+316