summary refs log tree commit diff
path: root/src/libcore
AgeCommit message (Collapse)AuthorLines
2016-10-19Review changesNick Cameron-1/+1
2016-10-19Deprecate `Reflect`Nick Cameron-4/+6
[tracking issue](https://github.com/rust-lang/rust/issues/27749)
2016-10-19Stabilise `?`Nick Cameron-1/+4
cc [`?` tracking issue](https://github.com/rust-lang/rust/issues/31436)
2016-10-10std: Stabilize and deprecate APIs for 1.13Alex Crichton-35/+37
This commit is intended to be backported to the 1.13 branch, and works with the following APIs: Stabilized * `i32::checked_abs` * `i32::wrapping_abs` * `i32::overflowing_abs` * `RefCell::try_borrow` * `RefCell::try_borrow_mut` * `DefaultHasher` * `DefaultHasher::new` * `DefaultHasher::default` Deprecated * `BinaryHeap::push_pop` * `BinaryHeap::replace` * `SipHash13` * `SipHash24` * `SipHasher` - use `DefaultHasher` instead in the `std::collections::hash_map` module Closes #28147 Closes #34767 Closes #35057 Closes #35070
2016-09-22Rollup merge of #36589 - jpadkins:option_docs_safety_wording_fix, r=blussJonathan Turner-6/+4
fixed the safety header/wording in option.rs Fixes #36581 screenshot of the rendered documentation: http://imgur.com/14kLVrA r? @steveklabnik
2016-09-22Rollup merge of #36423 - GuillaumeGomez:eq_impl, r=pnkfelixJonathan Turner-10/+10
Add missing Eq implementations Part of #36301.
2016-09-21add assert_ne and debug_assert_ne macrosAshley Williams-0/+63
2016-09-19Auto merge of #34942 - porglezomp:master, r=sfacklerbors-15/+11
Fix overflow checking in unsigned pow() The pow() method for unsigned integers produced 0 instead of trapping overflow for certain inputs. Calls such as 2u32.pow(1024) produced 0 when they should trap an overflow. This also adds tests for the correctly handling overflow in unsigned pow(). This was previously fixed for signed integers in #28248, but it seems unsigned integers got missed that time. For issue number #34913
2016-09-19fixed the safety header/wording in option.rsjacobpadkins-6/+4
2016-09-18Auto merge of #36523 - Mark-Simulacrum:format-args-link, r=GuillaumeGomezbors-3/+7
Add links between format_args! macro and std::fmt::Arguments struct r? @GuillaumeGomez
2016-09-18Add missing Eq implementationsGuillaume Gomez-10/+10
2016-09-17Auto merge of #36490 - bluss:zip-slightly-despecialized-edition, r=alexcrichtonbors-38/+14
Remove data structure specialization for .zip() iterator Go back on half the specialization, the part that changed the Zip struct's fields themselves depending on the types of the iterators. Previous PR: #33090 This means that the Zip iterator will always carry two usize fields, which are sometimes unused. If a whole for loop using a .zip() iterator is inlined, these are simply removed and have no effect. The same improvement for Zip of for example slice iterators remain, and they still optimize well. However, like when the specialization of zip was merged, the compiler is still very sensistive to the exact context. For example this code only autovectorizes if the function is used, not if the code in zip_sum_i32 is inserted inline where it was called: ```rust fn zip_sum_i32(xs: &[i32], ys: &[i32]) -> i32 { let mut s = 0; for (&x, &y) in xs.iter().zip(ys) { s += x * y; } s } fn zipdot_i32_default_zip(b: &mut test::Bencher) { let xs = vec![1; 1024]; let ys = vec![1; 1024]; b.iter(|| { zip_sum_i32(&xs, &ys) }) } ``` Include a test that checks that `Zip<T, U>` is covariant w.r.t. T and U. Fixes #35727
2016-09-16Add links between format_args! macro and std::fmt::Arguments structMark-Simulacrum-3/+7
2016-09-16Rollup merge of #36519 - Mark-Simulacrum:example-asmut, r=GuillaumeGomezJonathan Turner-0/+16
Add example in AsMut trait documentation Let me know of any changes I should make. r? @GuillaumeGomez
2016-09-16Rollup merge of #36424 - kmcallister:gh-29361-marker-docs, r=GuillaumeGomezJonathan Turner-155/+268
Tweak std::marker docs Fixes #29361. r? @GuillaumeGomez
2016-09-15Add example in AsMut trait documentationMark-Simulacrum-0/+16
2016-09-15Tweak std::marker docsKeegan McAllister-155/+268
Fixes #29361.
2016-09-15Auto merge of #35992 - SimonSapin:rc-arc-ptr-eq, r=alexcrichtonbors-0/+34
Add `pub fn ptr_eq(this: &Self, other: &Self) -> bool` to Rc and Arc Servo and Kuchiki have had helper functions doing this for some time.
2016-09-15Add std::ptr::eq, for referential equality of &T references.Simon Sapin-0/+34
Fixes https://github.com/rust-lang/rfcs/issues/1155
2016-09-15Auto merge of #36491 - Manishearth:rollup, r=Manishearthbors-8/+32
Rollup of 9 pull requests - Successful merges: #36384, #36405, #36425, #36429, #36438, #36454, #36459, #36461, #36463 - Failed merges: #36444
2016-09-15Rollup merge of #36454 - bluss:slice-primitive-index, r=alexcrichtonManish Goregaokar-4/+4
Use primitive indexing in slice's Index/IndexMut [T]'s Index implementation is normally not used for indexing, instead the compiler supplied indexing is used. Use the compiler supplied version in Index/IndexMut. This removes an inconsistency: Compiler supplied bound check failures look like this: thread 'main' panicked at 'index out of bounds: the len is 3 but the index is 4' If you convince Rust to use the Index impl for slices, bounds check failure looks like this instead: thread 'main' panicked at 'assertion failed: index < self.len()' The latter is used if you for example use Index generically: ```rust use std::ops::Index; fn foo<T: ?Sized>(x: &T) where T: Index<usize> { &x[4]; } foo(&[1, 2, 3][..]) ```
2016-09-15Rollup merge of #36384 - petrochenkov:derclone, r=alexcrichtonManish Goregaokar-4/+28
Improve shallow `Clone` deriving `Copy` unions now support `#[derive(Clone)]`. Less code is generated for `#[derive(Clone, Copy)]`. + Unions now support `#[derive(Eq)]`. Less code is generated for `#[derive(Eq)]`. --- Example of code reduction: ``` enum E { A { a: u8, b: u16 }, B { c: [u8; 100] }, } ``` Before: ``` fn clone(&self) -> E { match (&*self,) { (&E::A { a: ref __self_0, b: ref __self_1 },) => { ::std::clone::assert_receiver_is_clone(&(*__self_0)); ::std::clone::assert_receiver_is_clone(&(*__self_1)); *self } (&E::B { c: ref __self_0 },) => { ::std::clone::assert_receiver_is_clone(&(*__self_0)); *self } } } ``` After: ``` fn clone(&self) -> E { { let _: ::std::clone::AssertParamIsClone<u8>; let _: ::std::clone::AssertParamIsClone<u16>; let _: ::std::clone::AssertParamIsClone<[u8; 100]>; *self } } ``` All the matches are removed, bound assertions are more lightweight. `let _: Checker<CheckMe>;`, unlike `checker(&check_me);`, doesn't have to be translated by rustc_trans and then inlined by LLVM, it doesn't even exist in MIR, this means faster compilation. --- Union impls are generated like this: ``` union U { a: u8, b: u16, c: [u8; 100], } ``` ``` fn clone(&self) -> U { { let _: ::std::clone::AssertParamIsCopy<Self>; *self } } ``` Fixes https://github.com/rust-lang/rust/issues/36043 cc @durka r? @alexcrichton
2016-09-15Remove data structure specialization for .zip() iteratorUlrik Sverdrup-38/+14
Go back on half the specialization, the part that changed the Zip struct's fields themselves depending on the types of the iterators. This means that the Zip iterator will always carry two usize fields, which are unused. If a whole for loop using a .zip() iterator is inlined, these are simply removed and have no effect. The same improvement for Zip of for example slice iterators remain, and they still optimize well. However, like when the specialization of zip was merged, the compiler is still very sensistive to the exact context. For example this code only autovectorizes if the function is used, not if the code in zip_sum_i32 is inserted inline it was called: ``` fn zip_sum_i32(xs: &[i32], ys: &[i32]) -> i32 { let mut s = 0; for (&x, &y) in xs.iter().zip(ys) { s += x * y; } s } fn zipdot_i32_default_zip(b: &mut test::Bencher) { let xs = vec![1; 1024]; let ys = vec![1; 1024]; b.iter(|| { zip_sum_i32(&xs, &ys) }) } ``` Include a test that checks that Zip<T, U> is covariant w.r.t. T and U.
2016-09-15Auto merge of #36372 - sfackler:sum-prod-overflow, r=alexcrichtonbors-14/+10
Inherit overflow checks for sum and product We have previously documented the fact that these will panic on overflow, but I think this behavior is what people actually want/expect. `#[rustc_inherit_overflow_checks]` didn't exist when we discussed these for stabilization. r? @alexcrichton Closes #35807
2016-09-14core: Use primitive indexing in slice's Index/IndexMutUlrik Sverdrup-4/+4
[T]'s Index implementation is normally not used for indexing, instead the compiler supplied indexing is used. Use the compiler supplied version in Index/IndexMut. This removes an inconsistency: Compiler supplied bound check failures look like this: thread 'main' panicked at 'index out of bounds: the len is 3 but the index is 4' If you convince Rust to use the Index impl for slices, bounds check failure looks like this instead: thread 'main' panicked at 'assertion failed: index < self.len()' The latter is used if you for example use Index generically:: use std::ops::Index; fn foo<T: ?Sized>(x: &T) where T: Index<usize> { &x[4]; } foo(&[1, 2, 3][..])
2016-09-14Rollup merge of #36396 - athulappadan:Default-docs, r=blussGuillaume Gomez-0/+10
Documentation of what Default does for each type Addresses #36265 I haven't changed the following types due to doubts: 1)src/libstd/ffi/c_str.rs 2)src/libcore/iter/sources.rs 3)src/libcore/hash/mod.rs 4)src/libcore/hash/mod.rs 5)src/librustc/middle/privacy.rs r? @steveklabnik
2016-09-14Rollup merge of #36363 - GuillaumeGomez:add_urls, r=steveklabnikGuillaume Gomez-89/+160
Add urls r? @steveklabnik
2016-09-13Auto merge of #36041 - ahmedcharles:try, r=nrcbors-2/+2
Replace try! with ?.
2016-09-13Auto merge of #36181 - seanmonstar:likely, r=nikomatsakisbors-0/+14
core: add likely and unlikely intrinsics I'm no good at reading assembly, but I have tried a stage1 compiler with this patch, and it does cause different asm output. Additionally, testing this compiler on my httparse crate with some `likely` usage added in to the branches does affect benchmarks. However, I'm sure a codegen test should be included, if anyone knows what it should look like. There isn't an entry in `librustc_trans/context.rs` in this diff, because it already exists (`llvm.expect.i1` is used for array indices). ---- Even though this does affect httparse benchmarks, it doesn't seem to affect it the same way GCC's `__builtin_expect` affects picohttpparser. I was confused that the deviation on the benchmarks grew hugely when testing this, especially since I'm absolutely certain that the branchs where I added `likely` were always `true`. I chalk that up to GCC and LLVM handle branch prediction differently. cc #26179
2016-09-12Remove stray attributeSteven Fackler-1/+0
2016-09-11Use question_mark feature in libcore.Ahmed Charles-2/+2
2016-09-11Documentation for default types modifiedathulappadan-4/+4
2016-09-11Documentation of what does for each typeathulappadan-0/+10
2016-09-11Improve Result docggomez-36/+59
2016-09-11Improve Option docggomez-28/+50
2016-09-11Improve Copy trait docggomez-16/+35
2016-09-11Improve Clone docggomez-9/+16
2016-09-10Improve `Eq` derivingVadim Petrochenkov-1/+12
2016-09-10Tweak std::mem docsKeegan McAllister-110/+231
Fixes #29362.
2016-09-10Inherit overflow checks for sum and productSteven Fackler-14/+11
2016-09-10Improve shallow `Clone` derivingVadim Petrochenkov-3/+16
2016-09-06remove the extraneous not_equal implementation for slices.Justin LeFebvre-19/+2
2016-09-05Auto merge of #35845 - frewsxcv:result-into-iter, r=GuillaumeGomezbors-1/+7
Indicate where `core::result::IntoIter` is created. None
2016-09-03Indicate where `core::result::IntoIter` is created.Corey Farwell-1/+7
2016-09-02Auto merge of #35856 - phimuemue:master, r=brsonbors-0/+53
Introduce max_by/min_by on iterators See https://github.com/rust-lang/rfcs/issues/1722 for reference. It seems that there is `min`, `max` (simple computation of min/max), `min_by_key`, `max_by_key` (min/max by comparing mapped values) but no `min_by` and `max_by` (min/max according to comparison function). However, e.g. on vectors or slices there is `sort`, `sort_by_key` and `sort_by`.
2016-09-02Rollup merge of #36099 - skade:better-try-documentation, r=steveklabnikJonathan Turner-7/+26
Document try!'s error conversion behaviour try!'s documentation currently doesn't document the error conversion behaviour of the macro. This patch extends the documentation. Open questions: * is it worthwhile to have seperate examples with and without wrapping behaviour? It's not immediately obvious that From<T> for T is always defined. Though this is necessary for the macro to work in any case, is this the place to expect that knowledge.
2016-09-02Rollup merge of #35793 - matthew-piziak:add-rhs-example, r=steveklabnikJonathan Turner-0/+12
demonstrate `RHS != Self` use cases for `Add` and `Sub`
2016-09-02core: add likely and unlikely intrinsicsSean McArthur-0/+14
2016-09-01Document try!'s error conversion behaviourFlorian Gilcher-7/+26
2016-09-01Auto merge of #35755 - SimonSapin:char_convert, r=alexcrichtonbors-6/+63
Implement std::convert traits for char This is motivated by avoiding the `as` operator, which sometimes silently truncates, and instead use conversions that are explicitly lossless and infallible. I’m less certain that `From<u8> for char` should be implemented: while it matches an existing behavior of `as`, it’s not necessarily the right thing to use for non-ASCII bytes. It effectively decodes bytes as ISO/IEC 8859-1 (since Unicode designed its first 256 code points to be compatible with that encoding), but that is not apparent in the API name.