about summary refs log tree commit diff
path: root/src/libcore
AgeCommit message (Collapse)AuthorLines
2016-05-13Fix fast path of float parsing on x87Andrea Canciani-7/+42
The fast path of the float parser relies on the rounding to happen exactly and directly to the correct number of bits. On x87, instead, double rounding would occour as the FPU stack defaults to 80 bits of precision. This can be fixed by setting the precision of the FPU stack before performing the int to float conversion. This can be achieved by changing the value of the x87 control word. This is a somewhat common operation that is in fact performed whenever a float needs to be truncated to an integer, but it is undesirable to add its overhead for code that does not rely on x87 for computations (i.e. on non-x86 architectures, or x86 architectures which perform FPU computations on using SSE). Fixes `num::dec2flt::fast_path_correct` (on x87).
2016-05-12Auto merge of #33282 - alexcrichton:rustbuild-crate-tests, r=brsonbors-0/+7
rustbuild: Add support for crate tests + doctests This commit adds support to rustbuild to run crate unit tests (those defined by `#[test]`) as well as documentation tests. All tests are powered by `cargo test` under the hood. Each step requires the `libtest` library is built for that corresponding stage. Ideally the `test` crate would be a dev-dependency, but for now it's just easier to ensure that we sequence everything in the right order. Currently no filtering is implemented, so there's not actually a method of testing *only* libstd or *only* libcore, but rather entire swaths of crates are tested all at once. A few points of note here are: * The `coretest` and `collectionstest` crates are just listed as `[[test]]` entires for `cargo test` to naturally pick up. This mean that `cargo test -p core` actually runs all the tests for libcore. * Libraries that aren't tested all mention `test = false` in their `Cargo.toml` * Crates aren't currently allowed to have dev-dependencies due to rust-lang/cargo#860, but we can likely alleviate this restriction once workspaces are implemented. cc #31590
2016-05-12rustbuild: Add support for crate tests + doctestsAlex Crichton-0/+4
This commit adds support to rustbuild to run crate unit tests (those defined by `#[test]`) as well as documentation tests. All tests are powered by `cargo test` under the hood. Each step requires the `libtest` library is built for that corresponding stage. Ideally the `test` crate would be a dev-dependency, but for now it's just easier to ensure that we sequence everything in the right order. Currently no filtering is implemented, so there's not actually a method of testing *only* libstd or *only* libcore, but rather entire swaths of crates are tested all at once. A few points of note here are: * The `coretest` and `collectionstest` crates are just listed as `[[test]]` entires for `cargo test` to naturally pick up. This mean that `cargo test -p core` actually runs all the tests for libcore. * Libraries that aren't tested all mention `test = false` in their `Cargo.toml` * Crates aren't currently allowed to have dev-dependencies due to rust-lang/cargo#860, but we can likely alleviate this restriction once workspaces are implemented. cc #31590
2016-05-12Auto merge of #33306 - vadixidav:master, r=alexcrichtonbors-1/+73
add implementation of Ord for Cell<T> and RefCell<T> where T: Ord Raised this in issue #33305.
2016-05-11Rollup merge of #33401 - GuillaumeGomez:index_indication, r=pnkfelixGuillaume Gomez-0/+5
Add rustc_on_unimplemented for Index implementation on slice Reopening of #31071. It also extends the possibility of `#[rustc_on_unimplemented]` by providing a small type filter in order to find the ones which corresponds the most. r? @pnkfelix
2016-05-11doc: some `peek` improvementsTshepang Lekhonkhobe-11/+9
2016-05-11Rollup merge of #33129 - GuillaumeGomez:fmt_doc, r=steveklabnikSteve Klabnik-0/+26
Doc improvement on std::fmt module Part of #29355. r? @steveklabnik
2016-05-11Improve error message for Index trait on slicesGuillaume Gomez-0/+4
2016-05-11Extend rustc_on_unimplemented flag: if a message is available at an impl, ↵ggomez-0/+1
this message will be displayed instead
2016-05-10rustbuild: Tighten dependencies of build scriptsAlex Crichton-0/+3
Ensure that `rerun-if-changed` is printed for all build scripts to ensure that they've all got the right list of dependencies.
2016-05-10Doc improvement on std::fmt moduleGuillaume Gomez-0/+26
2016-05-10Simplify textStefan Schindler-2/+2
2016-05-09Add new atomic integer typesAmanieu d'Antras-602/+418
2016-05-09Add #[cfg(target_has_atomic)] to get atomic support for the current targetAmanieu d'Antras-0/+1
2016-05-08Rollup merge of #33426 - sfackler:try-from, r=aturonManish Goregaokar-11/+141
Implement RFC 1542 cc #33417 r? @aturon
2016-05-08Rollup merge of #33420 - durka:patch-20, r=alexcrichtonManish Goregaokar-0/+5
implement RFC 1521 Adds documentation to Clone, specifying that Copy types should have a trivial Clone impl. Fixes #33416. I tried to use "should" and "must" as defined [here](https://tools.ietf.org/html/rfc2119). cc @ubsan
2016-05-07Rollup merge of #33428 - fiveop:wrapping_example, r=steveklabnikSteve Klabnik-0/+11
Add an example to Wrapping's documentation. Such an example would have helped me understand `Wrapping` quicker. r? @steveklabnik
2016-05-07Rollup merge of #33409 - kindlychung:patch-2, r=steveklabnikSteve Klabnik-2/+2
errors in the doc
2016-05-07Implement RFC 1542Steven Fackler-11/+141
cc #33417
2016-05-06Auto merge of #33138 - arielb1:sized-shortcut, r=nikomatsakisbors-1/+1
Short-cut `T: Sized` trait selection for ADTs Basically avoids all nested obligations when checking whether an ADT is sized - this speeds up typeck by ~15% The refactoring fixed #32963, but I also want to make `Copy` not object-safe (will commit that soon). Fixes #33201 r? @nikomatsakis
2016-05-06Add `get_mut` methods to the `RefCell` and `Cell`Tobias Bucher-0/+24
This is safe since the borrow checker ensures that we have the only mutable reference to the struct, thus we can safely borrow its interior. Tracking issue is #33444.
2016-05-05Auto merge of #33067 - notriddle:wrapping_neg, r=alexcrichtonbors-0/+9
Implement negation for wrapping numerals. Fixes #33037
2016-05-05Add an example to Wrapping's documentation.Philipp Matthias Schaefer-0/+11
2016-05-04implement RFC 1521Alex Burka-0/+5
Adds documentation to Clone, specifying that Copy types should have a trivial Clone impl. Fixes #33416.
2016-05-04Update iterator.rsKaiyin Zhong-1/+1
2016-05-04errors in the docKaiyin Zhong-2/+2
2016-05-03require the non-last elements of a tuple to be SizedAriel Ben-Yehuda-1/+1
This requirement appears to be missing from RFC1214, but is clearly necessary for translation. The last field of a tuple/enum remains in a state of limbo, compiling but causing an ICE when it is used - we should eventually fix that somehow. this is a [breaking-change] - a soundness fix - and requires a crater run.
2016-05-03Rollup merge of #33357 - pcwalton:inline-mem-forget, r=brsonManish Goregaokar-0/+1
libcore: Inline `mem::forget()`. Was causing severe performance problems in WebRender. r? @brson
2016-05-03Rollup merge of #33335 - cramertj:master, r=alexcrichtonManish Goregaokar-5/+5
docs: Changed docs for `size_of` to describe size as a stride offset Current documentation for `std::mem::size_of` is ambiguous, and the documentation for `std::intrinsics::size_of` incorrectly defines size. This fix re-defines size as the offset in bytes between successive instances of a type, as described in LLVM's [getTypeAllocSize](http://llvm.org/docs/doxygen/html/classllvm_1_1DataLayout.html#a1d6fcc02e91ba24510aba42660c90e29). Fixes: #33266
2016-05-02libcore: Inline `mem::forget()`.Patrick Walton-0/+1
Was causing severe performance problems in WebRender.
2016-05-02Auto merge of #33289 - birkenfeld:chain-find, r=blussbors-0/+17
Implement find() on Chain iterators This results in a roughly 2x speedup compared to the default impl "inherited" from Iterator. Benchmark: https://gist.github.com/birkenfeld/aa9b92cb7d55666dd4821207527eaf5b
2016-05-01docs: Changed docs for `size_of` to describe size as a stride offsetTaylor Cramer-5/+5
Current description of `std::mem::size_of` is ambiguous, and the `std::intrinsics::size_of` description incorrectly defines size as the number of bytes necessary to exactly overwrite a value, not including the padding between elements necessary in a vector or structure.
2016-05-01change unstable to stable on traits and set version properlyGeordon Worley-4/+4
2016-05-01fix implementation of Ord for Cell<T> and RefCell<T> where T: OrdGeordon Worley-1/+73
2016-04-30Implement find() on Chain iteratorsGeorg Brandl-0/+17
This results in a roughly 2x speedup compared to the default impl "inherited" from Iterator.
2016-04-30Impl int/uint::MIN/MAX in terms of min/max_valueSimonas Kazlauskas-0/+26
2016-04-28Rollup merge of #33056 - GuillaumeGomez:as_mut_ptr_example, r=steveklabnikSteve Klabnik-0/+3
Improve as_mut ptr method example r? @steveklabnik
2016-04-26Auto merge of #31414 - durka:clone-copy, r=alexcrichtonbors-0/+11
special-case #[derive(Copy, Clone)] with a shallow clone If a type is Copy then its Clone implementation can be a no-op. Currently `#[derive(Clone)]` generates a deep clone anyway. This can lead to lots of code bloat. This PR detects the case where Copy and Clone are both being derived (the general case of "is this type Copy" can't be determined by a syntax extension) and generates the shallow Clone impl. Right now this can only be done if there are no type parameters (see https://github.com/rust-lang/rust/issues/31085#issuecomment-178988663), but this restriction can be removed after specialization. Fixes #31085.
2016-04-26shallow Clone for #[derive(Copy,Clone)]Alex Burka-0/+11
Changes #[derive(Copy, Clone)] to use a faster impl of Clone when both derives are present, and there are no generics in the type. The faster impl is simply returning *self (which works because the type is also Copy). See the comments in libsyntax_ext/deriving/clone.rs for more details. There are a few types which are Copy but not Clone, in violation of the definition of Copy. These include large arrays and tuples. The very existence of these types is arguably a bug, but in order for this optimization not to change the applicability of #[derive(Copy, Clone)], the faster Clone impl also injects calls to a new function, core::clone::assert_receiver_is_clone, to verify that all members are actually Clone. This is not a breaking change, because pursuant to RFC 1521, any type that implements Copy should not do any observable work in its Clone impl.
2016-04-22Make the `Iterator::enumerate` doc example more clearNick Fitzgerald-5/+4
The example uses integers for the value being iterated over, but the indices added by `enumerate` are also integers, so I always end up double taking and thinking harder than I should when parsing the documentation. I also always forget which order the index and value are in the tuple so I frequently hit this stumbling block. This commit changes the documentation to iterate over characters so that it is immediately obvious which part of the tuple is the index and which is the value.
2016-04-21Auto merge of #33079 - bluss:split-iter, r=alexcrichtonbors-5012/+5113
Split core::iter module implementation into parts Split core::iter module implementation into parts split iter.rs into a directory of (implementation private) modules. + mod (adaptor structs whose private fields need to be available both for them and Iterator + iterator (Iterator trait) + traits (FromIterator, etc; all traits but Iterator itself) + range (range related) + sources (Repeat, Once, Empty)
2016-04-20Implement negation for wrapping numerals.Michael Howell-0/+9
Fixes #33037
2016-04-20Implement `last` for `EscapeUnicode`Andrea Canciani-0/+12
Part of #24214.
2016-04-20Auto merge of #32942 - alexcrichton:bootstrap-from-previous, r=brsonbors-49/+0
mk: Bootstrap from stable instead of snapshots This commit removes all infrastructure from the repository for our so-called snapshots to instead bootstrap the compiler from stable releases. Bootstrapping from a previously stable release is a long-desired feature of distros because they're not fans of downloading binary stage0 blobs from us. Additionally, this makes our own CI easier as we can decommission all of the snapshot builders and start having a regular cadence to when we update the stage0 compiler. A new `src/etc/get-stage0.py` script was added which shares some code with `src/bootstrap/bootstrap.py` to read a new file, `src/stage0.txt`, which lists the current stage0 compiler as well as cargo that we bootstrap from. This script will download the relevant `rustc` package an unpack it into `$target/stage0` as we do today. One problem of bootstrapping from stable releases is that we're not able to compile unstable code (e.g. all the `#![feature]` directives in libcore/libstd). To overcome this we employ two strategies: * The bootstrap key of the previous compiler is hardcoded into `src/stage0.txt` (enabled as a result of #32731) and exported by the build system. This enables nightly features in the compiler we download. * The standard library and compiler are pinned to a specific stage0, which doesn't change, so we're guaranteed that we'll continue compiling as we start from a known fixed source. The process for making a release will also need to be tweaked now to continue to cadence of bootstrapping from the previous release. This process looks like: 1. Merge `beta` to `stable` 2. Produce a new stable compiler. 3. Change `master` to bootstrap from this new stable compiler. 4. Merge `master` to `beta` 5. Produce a new beta compiler 6. Change `master` to bootstrap from this new beta compiler. Step 3 above should involve very few changes as `master` was previously bootstrapping from `beta` which is the same as `stable` at that point in time. Step 6, however, is where we benefit from removing lots of `#[cfg(stage0)]` and get to use new features. This also shouldn't slow the release too much as steps 1-5 requires little work other than waiting and step 6 just needs to happen at some point during a release cycle, it's not time sensitive. Closes #29555 Closes #29557
2016-04-19Auto merge of #31253 - ranma42:improve-unicode-iter-offset, r=brsonbors-20/+32
Improve computation of offset in `EscapeUnicode` Unify the computation of `offset` and use `leading_zeros` instead of manually scanning the bits. This PR removes some duplicated code and makes it a little simpler . The computation of `offset` is also faster, but it is unlikely to have an impact on actual code. (split from #31049)
2016-04-19mk: Bootstrap from stable instead of snapshotsAlex Crichton-49/+0
This commit removes all infrastructure from the repository for our so-called snapshots to instead bootstrap the compiler from stable releases. Bootstrapping from a previously stable release is a long-desired feature of distros because they're not fans of downloading binary stage0 blobs from us. Additionally, this makes our own CI easier as we can decommission all of the snapshot builders and start having a regular cadence to when we update the stage0 compiler. A new `src/etc/get-stage0.py` script was added which shares some code with `src/bootstrap/bootstrap.py` to read a new file, `src/stage0.txt`, which lists the current stage0 compiler as well as cargo that we bootstrap from. This script will download the relevant `rustc` package an unpack it into `$target/stage0` as we do today. One problem of bootstrapping from stable releases is that we're not able to compile unstable code (e.g. all the `#![feature]` directives in libcore/libstd). To overcome this we employ two strategies: * The bootstrap key of the previous compiler is hardcoded into `src/stage0.txt` (enabled as a result of #32731) and exported by the build system. This enables nightly features in the compiler we download. * The standard library and compiler are pinned to a specific stage0, which doesn't change, so we're guaranteed that we'll continue compiling as we start from a known fixed source. The process for making a release will also need to be tweaked now to continue to cadence of bootstrapping from the previous release. This process looks like: 1. Merge `beta` to `stable` 2. Produce a new stable compiler. 3. Change `master` to bootstrap from this new stable compiler. 4. Merge `master` to `beta` 5. Produce a new beta compiler 6. Change `master` to bootstrap from this new beta compiler. Step 3 above should involve very few changes as `master` was previously bootstrapping from `beta` which is the same as `stable` at that point in time. Step 6, however, is where we benefit from removing lots of `#[cfg(stage0)]` and get to use new features. This also shouldn't slow the release too much as steps 1-5 requires little work other than waiting and step 6 just needs to happen at some point during a release cycle, it's not time sensitive. Closes #29555 Closes #29557
2016-04-18core::iter: Move ExactSizeIterator impls to each struct definitionUlrik Sverdrup-19/+19
2016-04-18core::iter: break long linesUlrik Sverdrup-2/+5
2016-04-18Split core::iter module implementation into partsUlrik Sverdrup-5012/+5110
split iter.rs into a directory of (implementation private) modules. + mod Adaptor structs - Private fields need to be available both for them and Iterator + iterator (Iterator trait) + traits (FromIterator, traits but Iterator itself) + range (range related) + sources (Repeat, Once, Empty)
2016-04-17Improve as_mut ptr method exampleGuillaume Gomez-0/+3