about summary refs log tree commit diff
path: root/src/libcore/num
AgeCommit message (Collapse)AuthorLines
2017-09-01impl From<Infallible> for TryFromIntError.Jimmy Cuadra-1/+8
2017-08-31Update bootstrap compilerAlex Crichton-2/+0
This commit updates the bootstrap compiler and clears out a number of #[cfg(stage0)] annotations and related business
2017-08-30Implement TryFrom explicitly for infallible numeric conversions.Jimmy Cuadra-6/+8
See https://github.com/rust-lang/rust/pull/44174#discussion_r135982787
2017-08-29Add blanket TryFrom impl when From is implemented.Jimmy Cuadra-27/+9
Adds `impl<T, U> TryFrom<T> for U where U: From<T>`. Removes `impl<'a, T> TryFrom<&'a str> for T where T: FromStr` due to overlapping impls caused by the new blanket impl. This removal is to be discussed further on the tracking issue for TryFrom. Refs #33417.
2017-08-17Rollup merge of #43891 - Fourchaux:master, r=steveklabnikCorey Farwell-3/+3
Fix typos & us spellings Fixing some typos and non en-US spellings. (Update of PR https://github.com/rust-lang/rust/pull/42812 )
2017-08-15use field init shorthand EVERYWHEREZack M. Davis-4/+4
Like #43008 (f668999), but _much more aggressive_.
2017-08-15Fix typos & us spellingsFourchaux-3/+3
2017-08-11Fix some typosBastien Orivel-1/+1
2017-07-30Document the `from_str_radix` panicTobias Bucher-0/+4
CC #42034
2017-07-26Rollup merge of #43471 - ollie27:try_from_ints, r=nagisaMark Simulacrum-11/+14
Add missing impl and tests for int to int TryFrom impls These were missing from #43248. r? @nagisa
2017-07-25Auto merge of #43320 - alexcrichton:new-bootstrap, r=Mark-Simulacrumbors-13/+8
Bump master to 1.21.0 This commit bumps the master branch's version to 1.21.0 and also updates the bootstrap compiler from the freshly minted beta release.
2017-07-25Bump master to 1.21.0Alex Crichton-13/+8
This commit bumps the master branch's version to 1.21.0 and also updates the bootstrap compiler from the freshly minted beta release.
2017-07-25Add missing impl and tests for int to int TryFrom implsOliver Middleton-11/+14
2017-07-25Auto merge of #43325 - ollie27:overflowing_literals, r=arielb1bors-5/+1
Fix overflowing_literals lint for large f32s Float literals need to be parsed as the correct type so they can be rounded correctly.
2017-07-25Auto merge of #43248 - llogiq:num-try-from, r=nagisabors-38/+177
improve the TryFrom implementations This removes the need for a 128 bit storage by making use of the fact that there can be either no over/underflow, either one or both, and each time the target type suffices to hold the limit for comparison. This also means that the implementation will work in targets without 128bit support (unless it's for 128bit types, of course). The downside is that the code looks a bit more complex.
2017-07-24improve the TryFrom implementationsAndre Bogus-38/+177
This removes the need for a 128 bit storage by making use of the fact that there can be either no over/underflow, either one or both, and each time the target type suffices to hold the limit for comparison. The downside is that the code looks a bit more complex. This test code included in this commit is from @oyvindln 's PR. They also greatly helped fixing a number of errors I made along the way. Thanks a lot!
2017-07-20std: Cut down #[inline] annotations where not necessaryAlex Crichton-37/+37
This PR cuts down on a large number of `#[inline(always)]` and `#[inline]` annotations in libcore for various core functions. The `#[inline(always)]` annotation is almost never needed and is detrimental to debug build times as it forces LLVM to perform inlining when it otherwise wouldn't need to in debug builds. Additionally `#[inline]` is an unnecessary annoation on almost all generic functions because the function will already be monomorphized into other codegen units and otherwise rarely needs the extra "help" from us to tell LLVM to inline something. Overall this PR cut the compile time of a [microbenchmark][1] by 30% from 1s to 0.7s. [1]: https://gist.github.com/alexcrichton/a7d70319a45aa60cf36a6a7bf540dd3a
2017-07-19Fix overflowing_literals lint for large f32sOliver Middleton-5/+1
Float literals need to be parsed as the correct type so they can be rounded correctly.
2017-06-28Auto merge of #42431 - nagisa:core-float-2, r=alexcrichtonbors-12/+24
Fix NaN handling in is_sign_negative/positive This would be my proposed fix for the #42425 provided we decide it is indeed a problem. Note this would technically be a breaking change to a stable API. We might want to consider deprecating these methods and adding new ones.
2017-06-22Fix NaN handling in is_sign_negative/positiveSimonas Kazlauskas-12/+24
See #42425
2017-06-16Auto merge of #42430 - nagisa:core-float, r=alexcrichtonbors-0/+63
Re-implement float min/max in rust This also adds the relevant implementations into libcore. See #42423
2017-06-14Re-implement float min/max in rustSimonas Kazlauskas-0/+63
See #42423
2017-06-08Use ctlz_nonzero to improve ASM from next_power_of_twoScott McMurray-1/+16
2017-06-08Auto merge of #40706 - irfanhudda:doc-next-power-of-two, r=alexcrichtonbors-11/+27
Improve documentation of next_power_of_two Clarify overflow behavior of `next_power_of_two`. Related Issue: #18604
2017-05-31Simplify helper functionsIrfan Hudda-15/+13
Based on @scottmcm 's suggestion
2017-05-23Add comments to explain helper functionsIrfan Hudda-5/+13
2017-05-20Auto merge of #42111 - ollie27:stab, r=Mark-Simulacrumbors-45/+45
Correct some stability versions These were found by running tidy on stable versions of rust and finding features stabilised with the wrong version numbers.
2017-05-20Correct some stability versionsOliver Middleton-45/+45
These were found by running tidy on stable versions of rust and finding features stabilised with the wrong version numbers.
2017-05-16Auto merge of #41907 - est31:macro_unused, r=jseyfriedbors-0/+1
Add lint for unused macros Addresses parts of #34938, to add a lint for unused macros. We now output warnings by default when we encounter a macro that we didn't use for expansion. Issues to be resolved before this PR is ready for merge: - [x] fix the NodeId issue described above - [x] remove all unused macros from rustc and the libraries or set `#[allow(unused_macros)]` next to them if they should be kept for some reason. This is needed for successful boostrap and bors to accept the PR. -> #41934 - [x] ~~implement the full extent of #34938, that means the macro match arm checking as well.~~ *let's not do this for now*
2017-05-15Auto merge of #41859 - froydnj:align-float-parts, r=sfacklerbors-8/+8
fix confusion about parts required for float formatting The documentation for flt2dec doesn't match up with the actual implementation, so fix the documentation to align with reality. Presumably due to the mismatch, the formatting code for floats in std::fmt can use correspondingly shorter arrays in some places, so fix those places up as well. Fixes #41304.
2017-05-13libcore: #[allow] some unused macrosest31-0/+1
2017-05-12Remove some unused macros from the rust codebaseest31-27/+0
Removes unused macros from: * libcore * libcollections The last use of these two macros was removed in commit b64c9d56700e2c41207166fe8709711ff02488ff when the char_range_at_reverse function was been removed. * librustc_errors Their last use was removed by commits 2f2c3e178325dc1837badcd7573c2c0905fab979 and 11dc974a38fd533aa692cea213305056cd3a6902. * libsyntax_ext * librustc_trans Also, put the otry macro in back/msvc/mod.rs under the same cfg argument as the places that use it.
2017-05-09fix confusion about parts required for float formattingNathan Froyd-8/+8
The documentation for flt2dec doesn't match up with the actual implementation, so fix the documentation to align with reality. Presumably due to the mismatch, the formatting code for floats in std::fmt can use correspondingly shorter arrays in some places, so fix those places up as well. Fixes #41304.
2017-04-29Update stage0 bootstrap compilerAlex Crichton-72/+0
We've got a freshly minted beta compiler, let's update to use that on nightly! This has a few other changes associated with it as well * A bump to the rustc version number (to 1.19.0) * Movement of the `cargo` and `rls` submodules to their "proper" location in `src/tools/{cargo,rls}`. Now that Cargo workspaces support the `exclude` option this can work. * Updates of the `cargo` and `rls` submodules to their master branches. * Tweak to the `src/stage0.txt` format to be more amenable for Cargo version numbers. On the beta channel Cargo will bootstrap from a different version than rustc (e.g. the version numbers are different), so we need different configuration for this. * Addition of `dev` as a readable key in the `src/stage0.txt` format. If present then stage0 compilers are downloaded from `dev-static.rust-lang.org` instead of `static.rust-lang.org`. This is added to accomodate our updated release process with Travis and AppVeyor.
2017-04-29Simplify `checked_next_power_of_two` functionIrfan Hudda-6/+1
2017-04-29Add comment about overflow behavior for next_power_of_twoIrfan Hudda-0/+3
2017-04-28Add helper functions for `next_power_of_two` and `checked_next_power_of_two`Irfan Hudda-10/+14
2017-04-20Remove float_extrasJosh Stone-150/+36
[unstable, deprecated since 1.11.0]
2017-04-20Remove num::{Zero,One}Josh Stone-72/+0
[unstable, deprecated since 1.11.0]
2017-04-20remove redundant wrapping_subIrfan Hudda-1/+1
2017-04-19next_power_of_two panic on overflowIrfan Hudda-2/+8
2017-04-18Improve documentation of next_power_of_twoIrfan Hudda-1/+3
Clarify overflow behavior of `next_power_of_two`. Related Issue: #18604
2017-04-14Use associated constants in core::num::dec2fltRobin Kruppe-152/+98
2017-04-05Rollup merge of #41037 - stjepang:move-libxtest, r=alexcrichtonCorey Farwell-4/+4
Move libXtest into libX/tests This change moves: 1. `libcoretest` into `libcore/tests` 2. `libcollectionstest` into `libcollections/tests` This is a follow-up to #39561. r? @alexcrichton
2017-04-03Replace ^ with <sup> html baliseGuillaume Gomez-6/+7
2017-04-03Move libXtest into libX/testsStjepan Glavina-4/+4
This change moves: 1. `libcoretest` into `libcore/tests` 2. `libcollectionstest` into `libcollections/tests` This is a follow-up to #39561.
2017-03-25Fix typo in dec2flt/algorithm.rsIrfan Hudda-2/+2
2017-03-22Various fixes to wording consistency in the docsStjepan Glavina-7/+7
2017-03-19Rollup merge of #40521 - TimNN:panic-free-shift, r=alexcrichtonCorey Farwell-18/+99
Implemente overflowing_sh* with new unchecked_sh* intrinsics Also update some 128 bit builtins to not rely on the constant evaluator to avoid checked operations. Fixes #40508. cc @nagisa, @alexcrichton Note: I still have a build running to see if the 128 bit changes worked (unoptimized builds take *forever* to compile), however at least the overflowing builtins no longer reference `core::panicking::panic`.
2017-03-19Rollup merge of #40281 - jimmycuadra:try-from-from-str, r=aturonCorey Farwell-3/+3
Rename TryFrom's associated type and implement str::parse using TryFrom. Per discussion on the tracking issue, naming `TryFrom`'s associated type `Error` is generally more consistent with similar traits in the Rust ecosystem, and what people seem to assume it should be called. It also helps disambiguate from `Result::Err`, the most common "Err". See https://github.com/rust-lang/rust/issues/33417#issuecomment-269108968. `TryFrom<&str>` and `FromStr` are equivalent, so have the latter provide the former to ensure that. Using `TryFrom` in the implementation of `str::parse` means types that implement either trait can use it. When we're ready to stabilize `TryFrom`, we should update `FromStr` to suggest implementing `TryFrom<&str>` instead for new code. See https://github.com/rust-lang/rust/issues/33417#issuecomment-277175994 and https://github.com/rust-lang/rust/issues/33417#issuecomment-277253827. Refs #33417.