about summary refs log tree commit diff
path: root/src/libcore
AgeCommit message (Collapse)AuthorLines
2015-05-25Auto merge of #25756 - tshepang:needless-cloned, r=steveklabnikbors-1/+1
2015-05-25doc: add example for Iterator::cloned()Tshepang Lekhonkhobe-2/+13
2015-05-24doc: cloned() and mut not neededTshepang Lekhonkhobe-1/+1
2015-05-24Implement Eq for Cell and RefCell.Simon Sapin-2/+8
`core::cell::Cell<T>` and `core::cell::RefCell<T>` currently implement `PartialEq` when `T` does, and just defer to comparing `T` values. There is no reason the same shouldn’t apply to `Eq`. This enables `#[derive(Eq, PartialEq)]` on e.g. structs that have a `RefCell` field.
2015-05-23Rollup merge of #25687 - tamird:num-self-cleanup, r=GankroOliver Schneider-114/+114
Cleanup extracted from #25684. r? @alexcrichton
2015-05-23Auto merge of #24847 - sfackler:debug-builders-stability, r=aturonbors-23/+23
The `debug_builders` feature is up for 1.1 stabilization in #24028. This commit stabilizes the API as-is with no changes. Some nits that @alexcrichton mentioned that may be worth discussing now if anyone cares: * Should `debug_tuple_struct` and `DebugTupleStruct` be used instead of `debug_tuple` and `DebugTuple`? It's more typing but is a technically more correct name. * `DebugStruct` and `DebugTuple` have `field` methods while `DebugSet`, `DebugMap` and `DebugList` have `entry` methods. Should we switch those to something else for consistency? cc @alexcrichton @aturon
2015-05-22Simplify flat_map examplemdinger-10/+9
2015-05-22docs: Improve descriptions for some methods in core::cell.Nick Hamann-4/+4
2015-05-21Standardize on `$t:ty`Tamir Duberstein-5/+5
2015-05-21Use `Self` to simplifyTamir Duberstein-109/+109
2015-05-20doc: that did not render well, so make it fit in one lineTshepang Lekhonkhobe-3/+2
2015-05-19Stabilize debug builders for 1.2.0Steven Fackler-23/+23
2015-05-19Fix for https://github.com/rust-lang/rust/pull/25583Steve Klabnik-1/+1
2015-05-19Rollup merge of #25583 - steveklabnik:gh25517, r=alexcrichtonSteve Klabnik-8/+4
Fixes #25517
2015-05-19Rollup merge of #25591 - rick68:patch-2, r=alexcrichtonManish Goregaokar-1/+1
fixed a mistake.
2015-05-19Auto merge of #25548 - sfackler:debug-builders-by-ref, r=alexcrichtonbors-25/+50
Based on feedback from https://internals.rust-lang.org/t/final-comment-period-for-debug-builders-stabilization/2007/2
2015-05-19Update iter.rsWei-Ming Yang-1/+1
fixed a mistake.
2015-05-18Fix debug builder examples examplesSteven Fackler-2/+2
2015-05-19Auto merge of #25496 - alexcrichton:stabilize-cloned, r=aturonbors-1/+1
The method was stabilized but the structure was forgotten to be stabilized. Closes #25480
2015-05-19Auto merge of #25441 - alexcrichton:debug-panic-neg, r=aturonbors-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-18std: 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-18Add example for from_str_radixSteve Klabnik-8/+4
Fixes #25517
2015-05-17Fix finish docsSteven Fackler-10/+5
2015-05-17Make debug builders take &mut self, add entries methodSteven Fackler-15/+45
[breaking-change]
2015-05-16Auto merge of #25434 - dotdash:gep, r=alexcrichtonbors-45/+75
Using regular pointer arithmetic to iterate collections of zero-sized types doesn't work, because we'd get the same pointer all the time. Our current solution is to convert the pointer to an integer, add an offset and then convert back, but this inhibits certain optimizations. What we should do instead is to convert the pointer to one that points to an i8\*, and then use a LLVM GEP instructions without the inbounds flag to perform the pointer arithmetic. This allows to generate pointers that point outside allocated objects without causing UB (as long as you don't dereference them), and it wraps around using two's complement, i.e. it behaves exactly like the wrapping_* operations we're currently using, with the added benefit of LLVM being able to better optimize the resulting IR.
2015-05-16std: Fix missing stability on iter::ClonedAlex Crichton-1/+1
The method was stabilized but the structure was forgotten to be stabilized. Closes #25480
2015-05-15libs: Move favicon URLs to HTTPSAlex Crichton-1/+1
Helps prevent mixed content warnings if accessing docs over HTTPS. Closes #25459
2015-05-15Allow for better optimizations of iterators for zero-sized typesBjörn Steinbrink-45/+75
Using regular pointer arithmetic to iterate collections of zero-sized types doesn't work, because we'd get the same pointer all the time. Our current solution is to convert the pointer to an integer, add an offset and then convert back, but this inhibits certain optimizations. What we should do instead is to convert the pointer to one that points to an i8*, and then use a LLVM GEP instructions without the inbounds flag to perform the pointer arithmetic. This allows to generate pointers that point outside allocated objects without causing UB (as long as you don't dereference them), and it wraps around using two's complement, i.e. it behaves exactly like the wrapping_* operations we're currently using, with the added benefit of LLVM being able to better optimize the resulting IR.
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