about summary refs log tree commit diff
path: root/src/libcore
AgeCommit message (Collapse)AuthorLines
2018-05-10Rollup merge of #50588 - ExpHP:i-can-see-my-house-from-here, r=frewsxcvAlex Crichton-4/+4
Move "See also" disambiguation links for primitive types to top Closes #50384. <details> <summary>Images</summary> ![rust-slice](https://user-images.githubusercontent.com/1411280/39843148-caa41c3e-53b7-11e8-8123-b57c25a4d9e0.png) ![rust-isize](https://user-images.githubusercontent.com/1411280/39843146-ca94b384-53b7-11e8-85f3-3f5e5d353a05.png) </details> r? @steveklabnik
2018-05-10Rollup merge of #50574 - s3bk:range_inclusive_into_inner, r=SimonSapinAlex Crichton-0/+15
add fn `into_inner(self) -> (Idx, Idx)` to RangeInclusive (#49022) adds `into_inner(self) -> (Idx, Idx)` to RangeInclusive https://github.com/rust-lang/rust/issues/49022#issuecomment-387645176
2018-05-10Rollup merge of #50010 - ExpHP:slice-bounds, r=alexcrichtonAlex Crichton-74/+242
Give SliceIndex impls a test suite of girth befitting the implementation (and fix a UTF8 boundary check) So one day I was writing something in my codebase that basically amounted to `impl SliceIndex for (Bound<usize>, Bound<usize>)`, and I said to myself: *Boy, gee, golly! I never realized bounds checking was so tricky!* At some point when I had around 60 lines of tests for it, I decided to go see how the standard library does it to see if I missed any edge cases. ...That's when I discovered that libcore only had about 40 lines of tests for slicing altogether, and none of them even used `..=`. --- This PR includes: * **Literally the first appearance of the word `get_unchecked_mut` in any directory named `test` or `tests`.** * Likewise the first appearance of `get_mut` used with _any type of range argument_ in these directories. * Tests for the panics on overflow with `..=`. * I wanted to test on `[(); usize::MAX]` as well but that takes linear time in debug mode </3 * A horrible and ugly test-generating macro for the `should_panic` tests that increases the DRYness by a single order of magnitude (which IMO wasn't enough, but I didn't want to go any further and risk making the tests inaccessible to next guy). * Same stuff for str! * Actually, the existing `str` tests were pretty good. I just helped filled in the holes. * [A fix for the bug it caught](https://github.com/rust-lang/rust/issues/50002). (only one ~~sadly~~)
2018-05-09move See also links to topMichael Lamparski-4/+4
2018-05-09add fn `into_inner(self) -> (Idx, Idx)` to RangeInclusive (#49022)Sebastian Köln-0/+15
2018-05-09Rollup merge of #50511 - Manishearth:must-use, r=QuietMisdreavuskennytm-6/+6
Add some explanations for #[must_use] `#[must_use]` can be given a string argument which is shown whilst warning for things. We should add a string argument to most of the user-exposed ones. I added these for everything but the operators, mostly because I'm not sure what to write there or if we need anything there.
2018-05-09Rollup merge of #50464 - est31:master, r=rkruppekennytm-6/+4
Remove some transmutes
2018-05-09Rollup merge of #50148 - japaric:const-manuallydrop, r=oli-obkkennytm-1/+2
turn `ManuallyDrop::new` into a constant function
2018-05-09Rollup merge of #50539 - clarcharr:log_const, r=dtolnaykennytm-0/+16
Add more logarithm constants Right now, we have `ln(2)` and `ln(10)`, but only `log2(e)` and `log10(e)`. This also adds `log2(10)` and `log10(2)` for consistency.
2018-05-08Add more logarithm constantsClar Charr-0/+16
2018-05-07Add explanation for #[must_use] on Debug buildersManish Goregaokar-5/+5
2018-05-07Add explanation for #[must_use] on ResultManish Goregaokar-1/+1
2018-05-07Unpin: Fix references to Pin typeRalf Jung-4/+4
2018-05-07Rename PinMut::borrow to PinMut::reborrow and make it a methodRalf Jung-3/+6
2018-05-07PinMut::get_mut can also preserve the lifetimeRalf Jung-1/+1
2018-05-07Change PinMut::map to be able to preserve the original reference's lifetimeRalf Jung-1/+1
Suggested by @dylanede at <https://github.com/rust-lang/rust/issues/49150#issuecomment-381071442>.
2018-05-07Rename Pin to PinMutRalf Jung-24/+24
As discussed at [1] §3 and [2] and [3], a formal look at pinning requires considering a distinguished "shared pinned" mode/typestate. Given that, it seems desirable to at least eventually actually expose that typestate as a reference type. This renames Pin to PinMut, freeing the name Pin in case we want to use it for a shared pinned reference later on. [1] https://www.ralfj.de/blog/2018/04/10/safe-intrusive-collections-with-pinning.html [2] https://github.com/rust-lang/rfcs/pull/2349#issuecomment-379250361 [3] https://github.com/rust-lang/rust/issues/49150#issuecomment-380488275
2018-05-07make the const constructor unstableJorge Aparicio-0/+1
2018-05-06Added some simple documentation.kennytm-0/+8
2018-05-06Some final touches to ensure `./x.py test --stage 0 src/lib*` workskennytm-0/+3
2018-05-06Move the tests in src/libcore/slice/memchr.rs as well.kennytm-82/+86
2018-05-06Fix warning in `core::time` testsLukas Kalbertodt-4/+6
2018-05-06Move libcore/time tests from `time.rs` to `tests/time.rs`Lukas Kalbertodt-116/+123
All other tests of libcore reside in the tests/ directory, too. Apparently the tests of `time.rs` weren't run before, at least not by `x.py test src/libcore`.
2018-05-05Remove some transmutesest31-6/+4
2018-05-05Suggest more helpful formatting stringKornel-5/+6
2018-05-04Auto merge of #50398 - llogiq:memchr-nano-opt, r=nagisabors-13/+2
nano-optimization for memchr::repeat_byte This replaces the multiple shifts & bitwise or with a single multiplication In my benchmarks this performs equally well or better, especially on 64bit systems (it shaves a stable nanosecond on my skylake). This may go against conventional wisdom, but the shifts and bitwise ors cannot be pipelined because of hard data dependencies. While it may or may not be worthwile from an optimization standpoint, it also reduces code size, so there's basically no downside.
2018-05-04Rollup merge of #50406 - ExpHP:concat-nonzero-idents, r=dtolnaykennytm-2/+2
Forbid constructing empty identifiers from concat_idents The empty identifier is a [reserved identifier](https://github.com/rust-lang/rust/blob/8a37c75a3a661385cc607d934c70e86a9eaf5fd7/src/libsyntax_pos/symbol.rs#L300-L305) in rust, apparently used for black magicks like representing the crate root or somesuch... and therefore, being able to construct it is Ungood. Presumably. ...even if the macro that lets you construct it is so useless that you can't actually do any damage with it. (and believe me, I tried) Fixes #50403. **Note:** I noticed that when you try to do something similar with `proc_macro::Term`, the compiler actually catches it and flags the identifier as reserved. Perhaps a better solution would be to somehow have that same check applied here.
2018-05-03update concat_idents doc stubsMichael Lamparski-2/+2
2018-05-03Auto merge of #50369 - pftbest:unicode, r=SimonSapinbors-8/+8
Fix a warning in libcore on 16bit targets. This code is assuming that usize >= 32bits, but it is not the case on 16bit targets. It is producing a warning that can fail the compilation on MSP430 if deny(warnings) is enabled. It is very unlikely that someone would actually use this code on a microcontroller, but since unicode was merged into libcore we have to compile it on 16bit targets. I've tried to make sure that the code stays the same on x86, here is an assembly comparison: https://godbolt.org/g/wFw7dZ r? @SimonSapin
2018-05-02nano-optimization for memchr::repeat_byteAndre Bogus-13/+2
2018-05-01Fix a warning in libcore on 16bit targets.Vadzim Dambrouski-8/+8
This code is assuming that usize >= 32bits, but it is not the case on 16bit targets. It is producing a warning that will fail the compilation on MSP430 if deny(warnings) is enabled. It is very unlikely that someone would actually use this code on a microcontroller, but since unicode was merged into libcore we have compile it on 16bit targets.
2018-05-01Auto merge of #49724 - kennytm:range-inc-start-end-methods, r=Kimundibors-7/+82
Introduce RangeInclusive::{new, start, end} methods and make the fields private. cc #49022
2018-04-30Auto merge of #48925 - zackmdavis:fn_must_stabilize, r=nikomatsakisbors-1/+1
stabilize `#[must_use]` for functions and must-use comparison operators (RFC 1940) r? @nikomatsakis
2018-05-01new() should be const; start()/end() after iteration is unspecified.kennytm-1/+17
2018-05-01Removed direct field usage of RangeInclusive in rustc itself.kennytm-5/+6
2018-05-01Rollup merge of #50316 - ehuss:fix-doc-links, r=frewsxcvkennytm-0/+4
Fix some broken links in docs.
2018-05-01Rollup merge of #50233 - mark-i-m:const_vec, r=kennytmkennytm-3/+2
Make `Vec::new` a `const fn` `RawVec::empty/_in` are a hack. They're there because `if size_of::<T> == 0 { !0 } else { 0 }` is not allowed in `const` yet. However, because `RawVec` is unstable, the `empty/empty_in` constructors can be removed when #49146 is done...
2018-04-30revise macro in slice testsMichael Lamparski-92/+62
2018-04-30Make the fields of RangeInclusive private.kennytm-2/+60
Added new()/start()/end() methods to RangeInclusive. Changed the lowering of `..=` to use RangeInclusive::new().
2018-04-30flesh out tests for SliceIndexMichael Lamparski-38/+244
m*n lines of implementation deserves m*n lines of tests
2018-04-30update libcore's comment about str testsMichael Lamparski-1/+1
2018-04-30Clean up the other Slice*Inclusive impls for strMichael Lamparski-24/+10
A previous PR fixed one method that was legitimately buggy; this cleans up the rest to be less diverse, mirroring the corresponding impls on [T] to the greatest extent possible without introducing any unnecessary UTF-8 boundary checks at 0.
2018-04-30str/slice: factor out overflow error messagesMichael Lamparski-12/+18
2018-04-29Fix some broken links in docs.Eric Huss-0/+4
2018-04-29Auto merge of #50217 - z4v1er:patch-1, r=aturonbors-1/+0
Fix typo
2018-04-28stabilize `#[must_use]` for functions and must-use operatorsZack M. Davis-1/+1
This is in the matter of RFC 1940 and tracking issue #43302.
2018-04-28Auto merge of #50149 - aaronaaeng:master, r=estebankbors-0/+13
Added warning for unused arithmetic expressions The compiler now displays a warning when a binary arithmetic operation is evaluated but not used. This resolves #50124 by following the instructions outlined in the issue. The changes are as follows: - Added new pattern matching for unused arithmetic expressions in `src/librustc_lint/unused.rs` - Added `#[must_use]` attributes to the binary operation methods in `src/libcore/internal_macros.rs` - Added `#[must_use]` attributes to the non-assigning binary operators in `src/libcore/ops/arith.rs`
2018-04-28Rollup merge of #49858 - dmizuk:unique-doc-hidden, r=steveklabnikkennytm-0/+1
std: Mark `ptr::Unique` with `#[doc(hidden)]` `Unique` is now perma-unstable, so let's hide its docs.
2018-04-26Add more doc aliasesGuillaume Gomez-0/+33
2018-04-25Make Vec::new constMark Mansi-3/+2