about summary refs log tree commit diff
path: root/src/libcore/num
AgeCommit message (Collapse)AuthorLines
2018-11-15Rollup merge of #55901 - euclio:speling, r=petrochenkovPietro Albini-1/+1
fix various typos in doc comments
2018-11-13fix various typos in doc commentsAndy Russell-1/+1
2018-11-12Auto merge of #55278 - Centril:constification-1, r=alexcrichtonbors-17/+15
Minor standard library constification This PR makes some bits of the standard library into `const fn`s. I've tried to be as aggressive as I possibly could in the constification. The list is rather small due to how restrictive `const fn` is at the moment. r? @oli-obk cc @rust-lang/libs Stable public APIs affected: + [x] `Cell::as_ptr` + [x] `UnsafeCell::get` + [x] `char::is_ascii` + [x] `iter::empty` + [x] `ManuallyDrop::{new, into_inner}` + [x] `RangeInclusive::{start, end}` + [x] `NonNull::as_ptr` + [x] `{[T], str}::as_ptr` + [x] `Duration::{as_secs, subsec_millis, subsec_micros, subsec_nanos}` + [x] `CStr::as_ptr` + [x] `Ipv4Addr::is_unspecified` + [x] `Ipv6Addr::new` + [x] `Ipv6Addr::octets` Unstable public APIs affected: + [x] `Duration::{as_millis, as_micros, as_nanos, as_float_secs}` + [x] `Wrapping::{count_ones, count_zeros, trailing_zeros, rotate_left, rotate_right, swap_bytes, reverse_bits, from_be, from_le, to_be, to_le, leading_zeros, is_positive, is_negative, leading_zeros}` + [x] `core::convert::identity` -------------------------- ## Removed from list in first pass: Stable public APIs affected: + [ ] `BTree{Map, Set}::{len, is_empty}` + [ ] `VecDeque::is_empty` + [ ] `String::{is_empty, len}` + [ ] `FromUtf8Error::utf8_error` + [ ] `Vec<T>::{is_empty, len}` + [ ] `Layout::size` + [ ] `DecodeUtf16Error::unpaired_surrogate` + [ ] `core::fmt::{fill, width, precision, sign_plus, sign_minus, alternate, sign_aware_zero_pad}` + [ ] `panic::Location::{file, line, column}` + [ ] `{ChunksExact, RChunksExact}::remainder` + [ ] `Utf8Error::valid_up_to` + [ ] `VacantEntry::key` + [ ] `NulError::nul_position` + [ ] `IntoStringError::utf8_error` + [ ] `IntoInnerError::error` + [ ] `io::Chain::get_ref` + [ ] `io::Take::{limit, get_ref}` + [ ] `SocketAddrV6::{flowinfo, scope_id}` + [ ] `PrefixComponent::{kind, as_os_str}` + [ ] `Path::{ancestors, display}` + [ ] `WaitTimeoutResult::timed_out` + [ ] `Receiver::{iter, try_iter}` + [ ] `thread::JoinHandle::thread` + [ ] `SystemTimeError::duration` Unstable public APIs affected: + [ ] `core::fmt::Arguments::new_v1` + [ ] `core::fmt::Arguments::new_v1_formatted` + [ ] `Pin::{get_ref, into_ref}` + [ ] `Utf8Lossy::chunks` + [ ] `LocalWaker::as_waker` + [ ] `panic::PanicInfo::{internal_constructor, message, location}` + [ ] `panic::Location::{internal_constructor }` ## Removed from list in 2nd pass: Stable public APIs affected: + [ ] `LinkedList::{new, iter, is_empty, len}` + [ ] `mem::forget` + [ ] `Cursor::{new, get_ref, position}` + [ ] `io::{empty, repeat, sink}` + [ ] `PoisonError::new` + [ ] `thread::Builder::new` + [ ] `process::Stdio::{piped, inherit, null}` Unstable public APIs affected: + [ ] `io::Initializer::{zeroing, should_initialize}`
2018-11-11Rollup merge of #55828 - oli-obk:promotion_strikes_again, r=eddybPietro Albini-0/+2
Add missing `rustc_promotable` attribute to unsigned `min_value` and `max_value` cc @pnkfelix fixes #55806
2018-11-10revert making internal APIs const fn.Mazdak Farrokhzad-5/+5
2018-11-10constify parts of libcore.Mazdak Farrokhzad-22/+20
2018-11-09Add missing `rustc_promotable` attribute to unsigned `min_value` and `max_value`Oliver Scherer-0/+2
2018-11-03Implement rotate using funnel shift on LLVM >= 7Nikita Popov-2/+12
Implement the rotate_left and rotate_right operations using llvm.fshl and llvm.fshr if they are available (LLVM >= 7). Originally I wanted to expose the funnel_shift_left and funnel_shift_right intrinsics and implement rotate_left and rotate_right on top of them. However, emulation of funnel shifts requires emitting a conditional to check for zero shift amount, which is not necessary for rotates. I was uncomfortable doing that here, as I don't want to rely on LLVM to optimize away that conditional (and for variable rotates, I'm not sure it can). We should revisit that question when we raise our minimum version requirement to LLVM 7 and don't need emulation code anymore.
2018-10-31Bump nightly to 1.32.0Alex Crichton-2/+2
* Also update the bootstrap compiler * Update cargo to 1.32.0 * Clean out stage0 annotations
2018-10-03Only promote calls to `#[rustc_promotable]` const fnsOliver Schneider-0/+2
2018-09-30Auto merge of #54601 - cuviper:prep-1.31, r=Mark-Simulacrumbors-405/+1
Bump to 1.31.0 and bootstrap from 1.30 beta Closes #54594.
2018-09-27Bump to 1.31.0 and bootstrap from 1.30 betaJosh Stone-405/+1
2018-09-17introduce from_nonzero featurecsmoe-1/+1
2018-09-15implement From<NonZero<Int>> for Intcsmoe-0/+7
2018-09-08Document .0 to unpack the value from WrappingMartin Pool-0/+3
2018-09-05Individual docs for {from,to}_*_bytesAndre Bogus-251/+314
2018-09-03Add const_unstable flag to `overflowing_shr`Tim Diekmann-0/+1
2018-09-01rebaseTim-56/+496
2018-08-30Rollup merge of #53476 - GuillaumeGomez:try-from-int-error-partial-eq, r=KodrAusPietro Albini-1/+1
Add partialeq implementation for TryFromIntError type Fixes #53458.
2018-08-28Add partialeq implementation for TryFromIntError typeGuillaume Gomez-1/+1
2018-08-21Rollup merge of #53363 - llogiq:num-individual-nonzero-docs, r=steveklabnikkennytm-20/+23
add individual docs to `core::num::NonZero*`
2018-08-17Gratuitous at byte boundaries in hex i32 literals in some doc-testsSimon Sapin-4/+4
2018-08-14add individual docs to `core::num::NonZero*`Andre Bogus-20/+23
2018-08-14`{to,from}_{ne,le,be}_bytes` for unsigned integer typesSimon Sapin-16/+88
Same as https://github.com/rust-lang/rust/pull/51919 did for signed integers. Tracking issue: https://github.com/rust-lang/rust/issues/52963
2018-08-10Add individual documentation for <integer>`.swap_bytes`/.`reverse_bits`Andre Bogus-113/+112
2018-08-10Rollup merge of #53207 - llogiq:num-rotate-docs, r=QuietMisdreavuskennytm-113/+115
Add individual docs for rotate_{left, right}
2018-08-09Add individual docs for rotate_{left, right}Andre Bogus-113/+115
2018-08-05Correct invalid feature attributesvarkor-20/+0
2018-08-04Rollup merge of #53062 - ljedrz:redundant_field_names, r=Mark-Simulacrumkennytm-27/+27
Remove redundant field names in structs
2018-08-04Remove redundant field names in structsljedrz-27/+27
2018-08-04Change tracking issue from #49792 to #51919Tobias Bucher-8/+8
The old issue has already been in FCP, a new issue was opened for the new API.
2018-08-03Provide `{to,from}_{ne,le,be}_bytes` functions on integersTobias Bucher-14/+86
If one doesn't view integers as containers of bytes, converting them to bytes necessarily needs the specfication of encoding. I think Rust is a language that wants to be explicit. The `to_bytes` function is basically the opposite of that – it converts an integer into the native byte representation, but there's no mention (in the function name) of it being very much platform dependent. Therefore, I think it would be better to replace that method by three methods, the explicit `to_ne_bytes` ("native endian") which does the same thing and `to_{le,be}_bytes` which return the little- resp. big-endian encoding.
2018-07-30Revert "Stabilize to_bytes and from_bytes for integers."Simon Sapin-4/+12
This reverts commit c8f9b84b393915a48253e3edc862c15a9b7152a7.
2018-07-11use proper footnote syntax for referencesAndy Russell-13/+11
The previous syntax was causing rustdoc to interpret them as links.
2018-07-08Fix some linksGuillaume Gomez-4/+4
2018-07-04Auto merge of #51395 - SimonSapin:repr-transparent, r=SimonSapinbors-0/+2
Add #[repr(transparent)] to some libcore types * `UnsafeCell` * `Cell` * `NonZero*` * `NonNull` * `Unique` CC https://github.com/rust-lang/rust/issues/43036
2018-07-03Auto merge of #51564 - SimonSapin:try-int, r=alexcrichtonbors-10/+60
Implement always-fallible TryFrom for usize/isize conversions that are infallible on some platforms This reverts commit 837d6c70233715a0ae8e15c703d40e3046a2f36a "Remove TryFrom impls that might become conditionally-infallible with a portability lint". This fixes #49415 by adding (restoring) missing `TryFrom` impls for integer conversions to or from `usize` or `isize`, by making them always fallible at the type system level (that is, with `Error=TryFromIntError`) even though they happen to be infallible on some platforms (for some values of `size_of::<usize>()`). They had been removed to allow the possibility to conditionally having some of them be infallible `From` impls instead, depending on the platforms, and have the [portability lint](https://github.com/rust-lang/rfcs/pull/1868) warn when they are used in code that is not already opting into non-portability. For example `#[allow(some_lint)] usize::from(x: u64)` would be valid on code that only targets 64-bit platforms. This PR gives up on this possiblity for two reasons: * Based on discussion with @aturon, it seems that the portability lint is not happening any time soon. It’s better to have the conversions be available *at all* than keep blocking them for so long. Portability-lint-gated platform-specific APIs can always be added separately later. * For code that is fine with fallibility, the alternative would force it to opt into "non-portability" even though there would be no real portability issue.
2018-06-30Bootstrap from 1.28.0-beta.3Mark Simulacrum-193/+0
2018-06-26Stabilize to_bytes and from_bytes for integers.Thayne McCombs-12/+4
Fixes #49792
2018-06-16Add #[repr(transparent)] to some libcore typesSimon Sapin-0/+2
* `UnsafeCell` * `Cell` * `NonZero*` * `NonNull` * `Unique`
2018-06-10add some docs to conversionsAndre Bogus-13/+39
2018-06-06Make the size of Option<NonZero*> a documented guarantee.Simon Sapin-2/+2
Closes #49137, the tracking issue for `NonZero*`, as this was the last remaining open question. Note that `ptr::NonNull<T>` already documents a similar guarantee.
2018-06-06Revert "Remove TryFrom impls that might become conditionally-infallible with ↵Simon Sapin-10/+60
a portability lint" This reverts commit 837d6c70233715a0ae8e15c703d40e3046a2f36a. Fixes https://github.com/rust-lang/rust/issues/49415
2018-06-03Rollup merge of #51299 - faern:const-int-ops, r=oli-obkMark Simulacrum-14/+280
const fn integer operations A follow up to #51171 Fixes #51267 Makes a lot of the integer methods (`swap_bytes`, `count_ones` etc) `const fn`s. See #51267 for a discussion about why this is wanted and the solution used.
2018-06-02Rollup merge of #50919 - frewsxcv:frewsxcv-epsilon, r=steveklabnikMark Simulacrum-2/+10
Provide more context for what the {f32,f64}::EPSILON values represent. Introduce the 'machine epsilon' term because if one googles 'epsilon', they might stumble upon https://en.wikipedia.org/wiki/Epsilon_numbers_(mathematics) instead of https://en.wikipedia.org/wiki/Machine_epsilon
2018-06-02Make integer methods non-const in stage0Linus Färnstrand-0/+192
2018-06-02Make most integer operations const fnsLinus Färnstrand-40/+114
2018-06-02Auto merge of #50554 - clarcharr:from_bool, r=TimNNbors-0/+14
Add From<bool> for int types Fixes #46109.
2018-06-01Add From<bool> for int typesClar Charr-0/+14
2018-06-01Add missing whitespace in num exampleGuillaume Gomez-1/+1