about summary refs log tree commit diff
path: root/src/libcore
AgeCommit message (Collapse)AuthorLines
2015-05-08core: impl AsRef<[u8]> for strSean McArthur-0/+9
2015-05-08Auto merge of #25218 - Manishearth:rollup, r=Manishearthbors-16/+16
- Successful merges: #24864, #25140, #25179, #25181, #25190, #25194, #25195, #25198, #25203, #25210, #25211, #25215 - Failed merges: #25200
2015-05-09Rollup merge of #25210 - rick68:patch-1, r=alexcrichtonManish Goregaokar-1/+1
fixed a doc mistake in libcore/marker.mk
2015-05-08Auto merge of #25187 - alexcrichton:mem-forget-safe, r=brsonbors-10/+45
This commit is an implementation of [RFC 1066][rfc] where the conclusion was that leaking a value is a safe operation in Rust code, so updating the signature of this function follows suit. [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/1066-safe-mem-forget.md Closes #25186
2015-05-09Please the `make tidy`Barosl Lee-1/+2
2015-05-09Squeeze the last bits of `task`s in documentation in favor of `thread`Barosl Lee-8/+8
An automated script was run against the `.rs` and `.md` files, subsituting every occurrence of `task` with `thread`. In the `.rs` files, only the texts in the comment blocks were affected.
2015-05-08fixed a mistakeWei-Ming Yang-1/+1
2015-05-07std: Mark `mem::forget` as a safe functionAlex Crichton-10/+45
This commit is an implementation of [RFC 1066][rfc] where the conclusion was that leaking a value is a safe operation in Rust code, so updating the signature of this function follows suit. [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/1066-safe-mem-forget.md Closes #25186
2015-05-08doc: the prevailing convention is to use assert_eq! when 2 values are comparedTshepang Lekhonkhobe-15/+15
2015-05-07Auto merge of #25013 - pnkfelix:span_to_lines-oflo, r=huonwbors-6/+24
Guard against overflow in `codemap::span_to_lines`. (Revised/expanded version of PR #24976) Make `span_to_lines` to return a `Result`. In `diagnostic`, catch `Err` from `span_to_lines` and print `"(unprintable span)"` instead. ---- There a number of recent issues that report the bug here. See e.g. #24761 and #24954. This change *might* fix them. However, that is *not* its main goal. The main goals are: 1. Make it possible for callers to recover from an error here, and 2. Insert a more conservative check, in that we are also checking that the files match up. ---- As a drive-by, fix #24997 , which was causing my attempts to `make check-stage1` on an `--enable-debug` build to fail.
2015-05-07Rollup merge of #25144 - killercup:docs/iter-fold-reduce, r=steveklabnikSteve Klabnik-0/+2
Enhance Google-ability of `.fold()` by mentioning 'reduce' and 'inject' in the docs. Motivation: [This thread on users.rust-lang.org](https://users.rust-lang.org/t/find-the-shortest-string-in-a-vector/1247)
2015-05-06Add missing inline attribute to Not impl for Wrapping<T>inrustwetrust-0/+1
2015-05-06Make overflow behaviour more obvious in the iterator module of `libcore`Tobias Bucher-6/+58
Explicitely spell out behaviour on overflow for `usize`-returning iterator functions. Mention that panics are guaranteed if debug assertions are active, otherwise a wrong result might be returned.
2015-05-06Iter Docs: Mention 'reduce' and 'inject'Pascal Hertleif-0/+2
2015-05-06core: use banker's rounding for the exact mode in flt2dec.Kang Seonghoon-1/+5
For the shortest mode the IEEE 754 decoder already provides an exact rounding range accounting for banker's rounding, but it was not the case for the exact mode. This commit alters the exact mode algorithm for Dragon so that any number ending at `...x5000...` with even `x` and infinite zeroes will round to `...x` instead of `...(x+1)` as it was. Grisu is not affected by this change because this halfway case always results in the failure for Grisu.
2015-05-06core: updated for the master changes.Kang Seonghoon-0/+5
The master no longer has `std::num::Float`, so a generic `ldexp` is not readily available. `DecodableFloat::ldexpi` works around this.
2015-05-06core: fixed a slight bug.Kang Seonghoon-6/+6
The bug involves the incorrect logic for `core::num::flt2dec::decoder`. This makes some numbers in the form of 2^n missing one final digits, which breaks the bijectivity criterion. The regression tests have been added, and f32 exhaustive test is rerun to get the updated result.
2015-05-06core: fixed typos and revised comments in flt2dec.Kang Seonghoon-14/+17
2015-05-06core: tweaked flt2dec to match the casing of the older formatting code.Kang Seonghoon-18/+18
2015-05-06core: made the core formatter to use a new flt2dec.Kang Seonghoon-332/+125
As a side effect `core::fmt::float` is gone now. This also slightly changes the float output, so this is: [breaking-change]
2015-05-06core: added core::num::flt2dec for floating-point formatting.Kang Seonghoon-0/+2219
This is a fork of the flt2dec portion of rust-strconv [1] with a necessary relicensing (the original code was licensed CC0-1.0). Each module is accompanied with large unit tests, integrated in this commit as coretest::num::flt2dec. This module is added in order to replace the existing core::fmt::float method. The forked revision of rust-strconv is from 2015-04-20, with a commit ID 9adf6d3571c6764a6f240a740c823024f70dc1c7. [1] https://github.com/lifthrasiir/rust-strconv/
2015-05-05Optimize iterator adapters.Steven Allen-18/+145
Specifically, make count, nth, and last call the corresponding methods on the underlying iterator where possible. This way, if the underlying iterator has an optimized count, nth, or last implementations (e.g. slice::Iter), these methods will propagate these optimizations. Additionally, change Skip::next to take advantage of a potentially optimized nth method on the underlying iterator.
2015-05-05Rollup merge of #25100 - jbcrail:fix-spelling-errors, r=steveklabnikManish Goregaokar-1/+1
I corrected several spelling errors in the external documentation.
2015-05-04Fix spelling errors in documentation.Joseph Crail-1/+1
2015-05-04Fix incorrect link in Option documentation.Lee Jeffery-1/+1
2015-05-04Avoid latent (harmless) overflow in core::slice.Felix S. Klock II-6/+24
This overflow does not cause any problems; it just causes errors to be signalled when compiling with `-C debug-assertions`. Fix #24997
2015-05-04Auto merge of #25067 - koute:master, r=alexcrichtonbors-0/+1
Without the inline annotation this: str::from_utf8_unchecked( slice::from_raw_parts( ptr, len ) ) doesn't get inlined which can be pretty brutal performance-wise when used in an inner loop of a low level string manipulation method.
2015-05-03Auto merge of #25070 - dotdash:inline_hash, r=alexcrichtonbors-0/+3
Since the hashmap and its hasher are implemented in different crates, we currently can't benefit from inlining, which means that especially for small, fixed size keys, there is a huge overhead in hash calculations, because the compiler can't apply optimizations that only apply for these keys. Fixes the brainfuck benchmark in #24014.
2015-05-03Auto merge of #24737 - P1start:dst-cell, r=alexcrichtonbors-30/+35
This + DST coercions (#24619) would allow code like `Rc<RefCell<Box<Trait>>>` to be simplified to `Rc<RefCell<Trait>>`.
2015-05-03Restore HashMap performance by allowing some functions to be inlinedBjörn Steinbrink-0/+3
Since the hashmap and its hasher are implemented in different crates, we currently can't benefit from inlining, which means that especially for small, fixed size keys, there is a huge overhead in hash calculations, because the compiler can't apply optimizations that only apply for these keys. Fixes the brainfuck benchmark in #24014.
2015-05-03Add #[inline(always)] to str::from_utf8_uncheckedJan Bujak-0/+1
Without the inline annotation this: str::from_utf8_unchecked( slice::from_raw_parts( ptr, len ) ) doesn't get inlined which can be pretty brutal performance-wise when used in an inner loop of a low level string manipulation method.
2015-05-02Auto merge of #24792 - alexcrichton:issue-24748, r=alexcrichtonbors-12/+16
Ensures that the same error type is propagated throughout. Unnecessary leakage of the internals is prevented through the usage of stability attributes. Closes #24748
2015-05-01std: Don't use a wrapper for the float error typeAlex Crichton-12/+16
Ensures that the same error type is propagated throughout. Unnecessary leakage of the internals is prevented through the usage of stability attributes. Closes #24748
2015-05-01Auto merge of #25006 - alexcrichton:unstable-indexing, r=aturonbors-119/+4
These implementations were intended to be unstable, but currently the stability attributes cannot handle a stable trait with an unstable `impl` block. This commit also audits the rest of the standard library for explicitly-`#[unstable]` impl blocks. No others were removed but some annotations were changed to `#[stable]` as they're defacto stable anyway. One particularly interesting `impl` marked `#[stable]` as part of this commit is the `Add<&[T]>` impl for `Vec<T>`, which uses `push_all` and implicitly clones all elements of the vector provided. Closes #24791 [breaking-change]
2015-05-02Make `UnsafeCell`, `RefCell`, `Mutex`, and `RwLock` accept DSTsP1start-30/+35
This + DST coercions (#24619) would allow code like `Rc<RefCell<Box<Trait>>>` to be simplified to `Rc<RefCell<Trait>>`.
2015-05-01Auto merge of #24778 - nagisa:managed-removal, r=huonwbors-13/+0
Leftovers from @-pointer times, I guess.
2015-05-01std: Remove index notation on slice iteratorsAlex Crichton-119/+4
These implementations were intended to be unstable, but currently the stability attributes cannot handle a stable trait with an unstable `impl` block. This commit also audits the rest of the standard library for explicitly-`#[unstable]` impl blocks. No others were removed but some annotations were changed to `#[stable]` as they're defacto stable anyway. One particularly interesting `impl` marked `#[stable]` as part of this commit is the `Add<&[T]>` impl for `Vec<T>`, which uses `push_all` and implicitly clones all elements of the vector provided. Closes #24791
2015-05-01Auto merge of #24720 - critiqjo:stepby-sizehint, r=alexcrichtonbors-15/+41
`Iterator::size_hint` can be easily implemented for `StepBy`. #23708
2015-05-01Rollup merge of #25010 - huonw:inline-int-extremes, r=alexcrichtonManish Goregaokar-0/+2
These compile down to `mov $CONSTANT, register; ret`, but the lack of `#[inline]` meant they have a full `call ...` when used from external crates.
2015-05-01iterator: Add `StepBy::size_hint` methodcritiqjo-15/+41
Fixes `Step::steps_between` implementations by integer types to correctly handle `by != 1`.
2015-05-01Remove ManagedSimonas Kazlauskas-13/+0
Leftovers from @-pointer times.
2015-04-30Add downcasting to std::error::ErrorAaron Turon-4/+4
This commit brings the `Error` trait in line with the [Error interoperation RFC](https://github.com/rust-lang/rfcs/pull/201) by adding downcasting, which has long been intended. This change means that for any `Error` trait objects that are `'static`, you can downcast to concrete error types. To make this work, it is necessary for `Error` to inherit from `Reflect` (which is currently used to mark concrete types as "permitted for reflection, aka downcasting"). This is a breaking change: it means that impls like ```rust impl<T> Error for MyErrorType<T> { ... } ``` must change to something like ```rust impl<T: Reflect> Error for MyErrorType<T> { ... } ``` except that `Reflect` is currently unstable (and should remain so for the time being). For now, code can instead bound by `Any`: ```rust impl<T: Any> Error for MyErrorType<T> { ... } ``` which *is* stable and has `Reflect` as a super trait. The downside is that this imposes a `'static` constraint, but that only constrains *when* `Error` is implemented -- it does not actually constrain the types that can implement `Error`. [breaking-change]
2015-05-01Mark the {min,max}_value functions on integers #[inline].Huon Wilson-0/+2
These compile down to `mov $CONSTANT, register; ret`, but the lack of `#[inline]` meant they have a full `call ...` when used from external crates.
2015-04-29rollup merge of #24886: GBGamer/masterAlex Crichton-0/+17
These are useful when you want to catch the signals, like when you're making a kernel, or if you just don't want the overhead. (I don't know if there are any of the second kind of people, I don't think it's a good idea, but hey, choice is good).
2015-04-29rollup merge of #24846: dotdash/fast_cttz8Alex Crichton-1/+14
Currently, LLVM lowers a cttz8 on x86_64 to these instructions: ```asm movzbl %dil, %eax bsfl %eax, %eax movl $32, %ecx cmovnel %eax, %ecx cmpl $32, %ecx movl $8, %eax cmovnel %ecx, %eax ``` To improve the codegen, we can zero extend the 8 bit integer, then set bit 8 and perform a cttz operation on the extended value. That way there's no conditional operation involved at all. This was discovered by this benchmark: https://github.com/Kimundi/long_strings_without_repeats Timings on my box with the current nightly: ``` running 4 tests test bench_cpp_naive_big ... bench: 5479222 ns/iter (+/- 254222) test bench_noop_big ... bench: 571405 ns/iter (+/- 111950) test bench_rust_naive_big ... bench: 7798102 ns/iter (+/- 148841) test bench_rust_unsafe_big ... bench: 6606488 ns/iter (+/- 67529) ``` Timings with the patch applied: ``` running 4 tests test bench_cpp_naive_big ... bench: 5470944 ns/iter (+/- 7109) test bench_noop_big ... bench: 568944 ns/iter (+/- 6895) test bench_rust_naive_big ... bench: 6795901 ns/iter (+/- 43806) test bench_rust_unsafe_big ... bench: 5584879 ns/iter (+/- 5291) ```
2015-04-29rollup merge of #24833: tari/rfc888Alex Crichton-0/+15
Closes #24118, implementing RFC 888.
2015-04-29rollup merge of #24610: nagisa/offset-docsAlex Crichton-6/+12
2015-04-29Update SNAPs to latest snapshot.Peter Marheine-4/+4
2015-04-29Currently, LLVM lowers a cttz8 on x86_64 to these instructions:Björn Steinbrink-1/+14
```asm movzbl %dil, %eax bsfl %eax, %eax movl $32, %ecx cmovnel %eax, %ecx cmpl $32, %ecx movl $8, %eax cmovnel %ecx, %eax ``` which has some unnecessary overhead, having two conditional moves. To improve the codegen, we can zero extend the 8 bit integer, then set bit 8 and perform a cttz operation on the extended value. That way there's no conditional operation involved at all.
2015-04-29Auto merge of #24888 - tamird:snapshot, r=alexcrichtonbors-132/+8
r? @alexcrichton cc @brson