about summary refs log tree commit diff
path: root/src/libcore
AgeCommit message (Collapse)AuthorLines
2016-01-19Auto merge of #30820 - oli-obk:docs/wrapping_ops, r=alexcrichtonbors-50/+43
r? @steveklabnik
2016-01-19Auto merge of #30696 - steveklabnik:gh30655, r=brsonbors-0/+10
Fixes #30655
2016-01-19fix the docs and simplify the implementation of unsigned wrapping opsOliver Schneider-50/+43
2016-01-19Rollup merge of #30988 - bluss:doc-space-t-bound, r=apasel422Manish Goregaokar-5/+5
Fix spacing style of `T: Bound` in docs The space between `T` and `Bound` is the typical style used in code and produced by rustdoc's rendering. Fixed first in Reflect's docs and then I fixed all occurrences in docs I could find.
2016-01-18core: Restore indexed formulation of clone_from_sliceUlrik Sverdrup-2/+7
For good codegen here, we need a lock step iteration where the loop bound is only checked once per iteration; .zip() unfortunately does not optimize this way. If we use a counted loop, and make sure that llvm sees that the bounds check condition is the same as the loop bound condition, the bounds checks are optimized out. For this reason we need to slice `from` (apparently) redundantly. This commit restores the old formulation of clone_from_slice. In this shape, clone_from_slice will again optimize into calling memcpy where possible (for example for &[u8] or &[i32]).
2016-01-17Fix spacing style of `T: Bound` in docsUlrik Sverdrup-5/+5
The space between `T` and `Bound` is the typical style used in code and produced by rustdoc's rendering. Fixed first in Reflect's docs and then I fixed all occurrences in docs I could find.
2016-01-17Rollup merge of #30943 - alexcrichton:stabilize-1.7, r=aturonManish Goregaokar-104/+96
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_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-17Auto merge of #30928 - sfackler:any-unsized, r=aturonbors-1/+1
This is a bit weird since unsized types can't be used in trait objects, but Any is *also* used as pure marker trait since Reflect isn't stable. There are many cases (e.g. TypeMap) where all you need is a TypeId. r? @aturon
2016-01-16Auto merge of #30624 - Ticki:specialization, r=alexcrichtonbors-0/+45
Part of #30520. Completes #24214
2016-01-16std: Stabilize APIs for the 1.7 releaseAlex Crichton-104/+96
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-16Auto merge of #30935 - ollie27:pad_int, r=alexcrichtonbors-9/+9
The function expects a value of true for zero but zero is not positive.
2016-01-16Make style more uniform, add tests for specialization of .last(), move tests ↵Ticki-73/+28
to libcoretest Remove unused import Fold nth() method into the match expr
2016-01-16Overide methods in iterator implementation for EscapeDefault, see #24214Ticki-0/+90
Complete the tests
2016-01-16Auto merge of #30740 - bluss:ascii-is-the-best, r=brsonbors-27/+60
Add fast path for ASCII in UTF-8 validation This speeds up the ASCII case (and long stretches of ASCII in otherwise mixed UTF-8 data) when checking UTF-8 validity. Benchmark results suggest that on purely ASCII input, we can improve throughput (megabytes verified / second) by a factor of 13 to 14 (smallish input). On XML and mostly English language input (en.wikipedia XML dump), throughput improves by a factor 7 (large input). On mostly non-ASCII input, performance increases slightly or is the same. The UTF-8 validation is rewritten to use indexed access; since all access is preceded by a (mandatory for validation) length check, bounds checks are statically elided by LLVM and this formulation is in fact the best for performance. A previous version had losses due to slice to iterator conversions. A large credit to Björn Steinbrink who improved this patch immensely, writing this second version. Benchmark results on x86-64 (Sandy Bridge) compiled with -C opt-level=3. Old code is `regular`, this PR is called `fast`. Datasets: - `ascii` is just ASCII (2.5 kB) - `cyr` is cyrillic script with ascii spaces (5 kB) - `dewik10` is 10MB of a de.wikipedia XML dump - `enwik8` is 100MB of an en.wikipedia XML dump - `jawik10` is 10MB of a ja.wikipedia XML dump ``` test from_utf8_ascii_fast ... bench: 140 ns/iter (+/- 4) = 18221 MB/s test from_utf8_ascii_regular ... bench: 1,932 ns/iter (+/- 19) = 1320 MB/s test from_utf8_cyr_fast ... bench: 10,025 ns/iter (+/- 245) = 511 MB/s test from_utf8_cyr_regular ... bench: 10,944 ns/iter (+/- 795) = 468 MB/s test from_utf8_dewik10_fast ... bench: 6,017,909 ns/iter (+/- 105,755) = 1740 MB/s test from_utf8_dewik10_regular ... bench: 11,669,493 ns/iter (+/- 264,045) = 891 MB/s test from_utf8_enwik8_fast ... bench: 14,085,692 ns/iter (+/- 1,643,316) = 7000 MB/s test from_utf8_enwik8_regular ... bench: 93,657,410 ns/iter (+/- 5,353,353) = 1000 MB/s test from_utf8_jawik10_fast ... bench: 29,154,073 ns/iter (+/- 4,659,534) = 340 MB/s test from_utf8_jawik10_regular ... bench: 29,112,917 ns/iter (+/- 2,475,123) = 340 MB/s ``` Co-authored-by: Björn Steinbrink <bsteinbr@gmail.com>
2016-01-15Auto merge of #30898 - petrochenkov:tvarfstab, r=alexcrichtonbors-3/+3
This wasn't done in https://github.com/rust-lang/rust/pull/29083 because attributes weren't parsed on fields of tuple variant back then. r? @alexcrichton
2016-01-15Rename is_positive argument in fmt::Formatter::pad_integralOliver Middleton-9/+9
The function expects a value of true for zero but zero is not positive.
2016-01-14Implement Any for unsized typesSteven Fackler-1/+1
This is a bit weird since unsized types can't be used in trait objects, but Any is *also* used as pure marker trait since Reflect isn't stable. There are many cases (e.g. TypeMap) where all you need is a TypeId.
2016-01-15Doc:std::convert: be more specific + typoThomas Wickham-21/+19
2016-01-14doc: this is more easy to read, and less prone mis-interpretationTshepang Lekhonkhobe-1/+1
This function returns the size on the stack, not that of the value that may be allocated on the heap.
2016-01-14Doc:std::convert explicitely list generic implsThomas Wickham-0/+59
Also add a note about the necessary simplicity of the conversion. Related issue: #29349
2016-01-14Require stability annotations on fields of tuple variantsVadim Petrochenkov-3/+3
2016-01-14UTF-8 validation: Add missing if conditional for short inputUlrik Sverdrup-13/+16
We need to guard that `len` is large enough for the fast skip loop.
2016-01-14Rollup merge of #30886 - ollie27:docs_links, r=steveklabnikManish Goregaokar-1/+1
r? @steveklabnik
2016-01-14Rollup merge of #30839 - tomaka:debug-phantomdata, r=nikomatsakisManish Goregaokar-1/+1
All the trait implementations of `PhantomData` use `impl<T: ?Sized>` except for `Debug` https://doc.rust-lang.org/nightly/std/marker/struct.PhantomData.html#implementations This PR fixes this.
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-13Fix some broken and missing links in the docsOliver Middleton-1/+1
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-12Add fast path for ASCII in UTF-8 validationUlrik Sverdrup-27/+57
This speeds up the ascii case (and long stretches of ascii in otherwise mixed UTF-8 data) when checking UTF-8 validity. Benchmark results suggest that on purely ASCII input, we can improve throughput (megabytes verified / second) by a factor of 13 to 14! On xml and mostly english language input (en.wikipedia xml dump), throughput increases by a factor 7. On mostly non-ASCII input, performance increases slightly or is the same. The UTF-8 validation is rewritten to use indexed access; since all access is preceded by a (mandatory for validation) length check, they are statically elided by llvm and this formulation is in fact the best for performance. A previous version had losses due to slice to iterator conversions. A large credit to Björn Steinbrink who improved this patch immensely, writing this second version. Benchmark results on x86-64 (Sandy Bridge) compiled with -C opt-level=3. Old code is `regular`, this PR is called `fast`. Datasets: - `ascii` is just ascii (2.5 kB) - `cyr` is cyrillic script with ascii spaces (5 kB) - `dewik10` is 10MB of a de.wikipedia xml dump - `enwik10` is 100MB of an en.wikipedia xml dump - `jawik10` is 10MB of a ja.wikipedia xml dump ``` test from_utf8_ascii_fast ... bench: 140 ns/iter (+/- 4) = 18221 MB/s test from_utf8_ascii_regular ... bench: 1,932 ns/iter (+/- 19) = 1320 MB/s test from_utf8_cyr_fast ... bench: 10,025 ns/iter (+/- 245) = 511 MB/s test from_utf8_cyr_regular ... bench: 12,250 ns/iter (+/- 437) = 418 MB/s test from_utf8_dewik10_fast ... bench: 6,017,909 ns/iter (+/- 105,755) = 1740 MB/s test from_utf8_dewik10_regular ... bench: 11,669,493 ns/iter (+/- 264,045) = 891 MB/s test from_utf8_enwik8_fast ... bench: 14,085,692 ns/iter (+/- 1,643,316) = 7000 MB/s test from_utf8_enwik8_regular ... bench: 93,657,410 ns/iter (+/- 5,353,353) = 1000 MB/s test from_utf8_jawik10_fast ... bench: 29,154,073 ns/iter (+/- 4,659,534) = 340 MB/s test from_utf8_jawik10_regular ... bench: 29,112,917 ns/iter (+/- 2,475,123) = 340 MB/s ``` Co-authored-by: Björn Steinbrink <bsteinbr@gmail.com>
2016-01-12Fix the Debug impl of PhantomData requiring Sized on TPierre Krieger-1/+1
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-10Remove unneeded #[lang = "iterator"]Guillaume Gomez-1/+0
2016-01-07Link Nomicon in PhantomData's docsSteve Klabnik-0/+4
Fixes #30069
2016-01-07Auto merge of #30724 - nikomatsakis:feature-gate-defaulted-type-parameters, ↵bors-2/+2
r=pnkfelix It was recently realized that we accept defaulted type parameters everywhere, without feature gate, even though the only place that we really *intended* to accept them were on types. This PR adds a lint warning unless the "type-parameter-defaults" feature is enabled. This should eventually become a hard error. This is a [breaking-change] in that new feature gates are required (or simply removing the defaults, which is probably a better choice as they have little effect at this time). Results of a [crater run][crater] suggest that approximately 5-15 crates are affected. I didn't do the measurement quite right so that run cannot distinguish "true" regressions from "non-root" regressions, but even the upper bound of 15 affected crates seems relatively minimal. [crater]: https://gist.github.com/nikomatsakis/760c6a67698bd24253bf cc @rust-lang/lang r? @pnkfelix
2016-01-06Rollup merge of #30716 - kraai:fix-hexicdecimal, r=apasel422Steve Klabnik-1/+1
2016-01-06Rollup merge of #30700 - steveklabnik:gh28581, r=brsonSteve Klabnik-0/+4
Fixes #28581
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-05Fix the spelling of "hexadecimal"Matt Kraai-1/+1
2016-01-05Auto merge of #30702 - tshepang:derives-not-needed, r=steveklabnikbors-23/+1
Also sneak in a missing trailing comma
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-04doc: these examples do not need Copy and Clone traitsTshepang Lekhonkhobe-23/+1
Also sneak in a missing trailing comma
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-04Mention that Sync/Send are automatically derivedSteve Klabnik-0/+4
Fixes #28581
2016-01-04Explain drop a bit moreSteve Klabnik-0/+10
Fixes #30655
2016-01-04Feature-gate defaulted type parameters outside of types.Niko Matsakis-2/+2
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
2015-12-30Rollup merge of #30373 - ChrisBuchholz:master, r=steveklabnikSteve Klabnik-7/+13
The current explanation for scan() is not very clear as to how it works, especially when it compares itself to fold(). I believe these changes makes it all a bit more clear for the reader, and makes it easier to understand the example code. r? @steveklabnik
2015-12-29Rollup merge of #30610 - steveklabnik:gh30600, r=sfacklerSteve Klabnik-3/+3
Also, make its panic description identical in wording to assert_eq. Fixes #30600
2015-12-29Rollup merge of #30549 - mitaa:doc_dstruct, r=brsonSteve Klabnik-1/+1
(reported in #30477)