summary refs log tree commit diff
path: root/src/libcore
AgeCommit message (Collapse)AuthorLines
2015-06-09std: Fix missing stability on iter::ClonedAlex Crichton-1/+1
The method was stabilized but the structure was forgotten to be stabilized. Closes #25480
2015-06-09std: Make abs() panic on overflow in debug modeAlex Crichton-3/+12
Debug overflow checks for arithmetic negation landed in #24500, at which time the `abs` method on signed integers was changed to using `wrapping_neg` to ensure that the function never panicked. This implied that `abs` of `INT_MIN` would return `INT_MIN`, another negative value. When this change was back-ported to beta, however, in #24708, the `wrapping_neg` function had not yet been backported, so the implementation was changed in #24785 to `!self + 1`. This change had the unintended side effect of enabling debug overflow checks for the `abs` function. Consequently, the current state of affairs is that the beta branch checks for overflow in debug mode for `abs` and the nightly branch does not. This commit alters the behavior of nightly to have `abs` always check for overflow in debug mode. This change is more consistent with the way the standard library treats overflow as well, and it is also not a breaking change as it's what the beta branch currently does (albeit if by accident). cc #25378
2015-05-15Fix major compile time regressionBjörn Steinbrink-16/+16
The assume intrinsic has a strong, negative impact on compile times, so we're currently only using it in places where LLVM can simplify it to nonnull metadata on a load intruction. Unfortunately a recent change that fixed invalid assume calls introduce new assume calls for which this simplification can not happen, leading to a massive regression in compile times in certain cases. Moving the assumptions from the middle of the function to the beginning allows the simplification to happen again, bringing compile times back to their old levels. Fixes #25393
2015-05-13Writer -> Write in macro docsSteve Klabnik-1/+1
Fixes #25355
2015-05-13Remove SNAP commentsNick Cameron-18/+18
2015-05-13RebasingNick Cameron-1/+9
2015-05-13eddyb's changes for DST coercionsNick Cameron-0/+88
+ lots of rebasing
2015-05-12Rollup merge of #24996 - steveklabnik:gh24163, r=aturonManish Goregaokar-0/+5
These two traits are commonly confused. As such, explain the difference. Fixes #24163 r? @aturon
2015-05-12TRPL: Borrow and AsRefSteve Klabnik-0/+5
These two traits are commonly confused. As such, explain the difference. Fixes #24163
2015-05-12Auto merge of #25300 - kballard:core-slice-overflow, r=Gankrobors-64/+45
core::slice was originally written to tolerate overflow (notably, with slices of zero-sized elements), but it was never updated to use wrapping arithmetic when overflow traps were added. Also correctly handle the case of calling .nth() on an Iter with a zero-sized element type. The iterator was assuming that the pointer value of the returned reference was meaningful, but that's not true for zero-sized elements. Fixes #25016.
2015-05-11Avoid returning a slice with a null pointer from Iter.as_slice()Kevin Ballard-19/+19
core::slice::Iter.ptr can be null when iterating a slice of zero-sized elements, but the pointer value used for the slice itself cannot. Handle this case by always returning a dummy pointer for slices of zero-sized elements.
2015-05-11Reintroduce non-null assumptions in core::slice iteratorsKevin Ballard-8/+16
The previous assumptions were not valid for slices of zero-sized elements.
2015-05-11Rollup merge of #25290 - bluss:docfixes, r=steveklabnikManish Goregaokar-2/+5
Several Minor API / Reference Documentation Fixes - Fix a few small errors in the reference. - Fix paper cuts in the API docs. Fixes #24882 Fixes #25233 Fixes #25250
2015-05-11Auto merge of #25271 - tshepang:doc-deunwrap, r=steveklabnikbors-34/+34
2015-05-11Handle overflow properly in core::sliceKevin Ballard-39/+12
core::slice was originally written to tolerate overflow (notably, with slices of zero-sized elements), but it was never updated to use wrapping arithmetic when overflow traps were added. Also correctly handle the case of calling .nth() on an Iter with a zero-sized element type. The iterator was assuming that the pointer value of the returned reference was meaningful, but that's not true for zero-sized elements. Fixes #25016.
2015-05-11docs: Update FromStr documentationUlrik Sverdrup-2/+5
Fixes #25250
2015-05-10doc: unwrap is discouraged, so use SomeTshepang Lekhonkhobe-34/+34
2015-05-10Rollup merge of #25158 - koute:master, r=alexcrichtonSteve Klabnik-0/+1
I was profiling my code again and this time AsRef<str> for String was eating up a considerable chunk of my runtime; adding the inline annotation made the program run almost twice as fast! While I was at it I also added the annotation to other implementations of AsRef as well as AsMut.
2015-05-10Add #[inline] to AsRef<str>::as_ref for String and str.Jan Bujak-0/+1
2015-05-09Convert #[lang="..."] to #[lang = "..."]Nick Hamann-38/+38
In my opinion this looks nicer, but also it matches the whitespace generally used for stability markers more closely.
2015-05-09Auto merge of #24612 - lifthrasiir:flt2dec, r=pnkfelixbors-332/+2356
This is a direct port of my prior work on the float formatting. The detailed description is available [here](https://github.com/lifthrasiir/rust-strconv#flt2dec). In brief, * This adds a new hidden module `core::num::flt2dec` for testing from `libcoretest`. Why is it in `core::num` instead of `core::fmt`? Because I envision that the table used by `flt2dec` is directly applicable to `dec2flt` (cf. #24557) as well, which exceeds the realm of "formatting". * This contains both Dragon4 algorithm (exact, complete but slow) and Grisu3 algorithm (exact, fast but incomplete). * The code is accompanied with a large amount of self-tests and some exhaustive tests. In particular, `libcoretest` gets a new dependency on `librand`. For the external interface it relies on the existing test suite. * It is known that, in the best case, the entire formatting code has about 30 KBs of binary overhead (judged from strconv experiments). Not too bad but there might be a potential room for improvements. This is rather large code. I did my best to comment and annotate the code, but you have been warned. For the maximal availability the original code was licensed in CC0, but I've also dual-licensed it in MIT/Apache as well so there should be no licensing concern. This is [breaking-change] as it changes the float output slightly (and it also affects the casing of `inf` and `nan`). I hope this is not a big deal though :) Fixes #7030, #18038 and #24556. Also related to #6220 and #20870. ## Known Issues - [x] I've yet to finish `make check-stage1`. It does pass main test suites including `run-pass` but there might be some unknown edges on the doctests. - [ ] Figure out how this PR affects rustc. - [ ] Determine which internal routine is mapped to the formatting specifier. Depending on the decision, some internal routine can be safely removed (for instance, currently `to_shortest_str` is unused).
2015-05-09Rollup merge of #25216 - barosl:no-more-task, r=ManishearthManish Goregaokar-8/+9
I've found that there are still huge amounts of occurrences of `task`s in the documentation. This PR tries to eliminate all of them in favor of `thread`.
2015-05-09Auto merge of #25159 - inrustwetrust:wrapping_inline, r=alexcrichtonbors-0/+1
This was causing function calls to be emitted for bitwise complements, even with optimizations on. Steps to reproduce: ``` $ cat wrapping.rs fn main() { let a = std::num::Wrapping(std::env::args().len() as u32); let b = !a; println!("{}", b.0); } $ rustc -O wrapping.rs --emit=asm,link $ grep Not wrapping.s callq _ZN3num8wrapping23Wrapping$LT$u32$GT$.Not3not20hba4b266232e02b1dHkbE ```
2015-05-09Auto merge of #25162 - seanmonstar:asref-bytes, r=alexcrichtonbors-0/+9
r? @aturon
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