summary refs log tree commit diff
path: root/library/core/src
AgeCommit message (Collapse)AuthorLines
2020-11-15Add missing `mut`.Mara Bos-1/+1
Co-authored-by: David Tolnay <dtolnay@gmail.com>
2020-11-15Reword safety guarantee of Pin::static_{ref,mut}.Mara Bos-6/+6
Co-authored-by: Peter Todd <pete@petertodd.org>
2020-11-15Add Pin::static_mut.Mara Bos-0/+14
2020-11-15Rename Pin::new_static to Pin::static_ref.Mara Bos-1/+1
2020-11-15Make Pin::new_static const.Mara Bos-1/+2
2020-11-15Add Pin::new_static.Mara Bos-0/+13
2020-11-15change the order of type arguments on ControlFlowLeonora Tindall-23/+17
This allows ControlFlow<BreakType> which is much more ergonomic for common iterator combinator use cases.
2020-11-15Add `ControlFlow::is_{break,continue}` methodsLeSeulArtichaut-0/+14
2020-10-02Rollup merge of #77442 - pickfire:patch-7, r=scottmcmJonas Schievink-2/+3
Clean up on example doc fixes for ptr::copy Follow up of #77385 r? @scottmcm
2020-10-02Rollup merge of #77409 - pickfire:patch-6, r=GuillaumeGomezJonas Schievink-0/+11
Add example for iter chain struct r? @GuillaumeGomez
2020-10-02Rollup merge of #77405 - timvermeulen:iter_advance_by_tracking_issue, r=scottmcmJonas Schievink-2/+2
Add tracking issue of iter_advance_by feature
2020-10-02Clean up on example doc fixes for ptr::copyIvan Tham-2/+3
Follow up of #77385
2020-10-02Rollup merge of #77385 - scottmcm:fix-77220, r=jyn514Yuki Okushi-1/+11
Improve the example for ptr::copy Fixes #77220
2020-10-02Rollup merge of #77111 - fusion-engineering-forks:stabilize-slice-ptr-range, ↵Yuki Okushi-4/+2
r=dtolnay Stabilize slice_ptr_range. This has been unstable for almost a year now. Time to stabilize? Closes #65807. @rustbot modify labels: +T-libs +A-raw-pointers +A-slice +needs-fcp
2020-10-01Auto merge of #76971 - bugadani:issue-75659, r=Amanieubors-16/+27
Refactor memchr to allow optimization Closes #75659 The implementation already uses naive search if the slice if short enough, but the case is complicated enough to not be optimized away. This PR refactors memchr so that it exists early when the slice is short enough. Codegen-wise, as shown in #75659, memchr was not inlined previously so the only way I could find to test this is to check if there is no memchr call. Let me know if there is a more robust solution here.
2020-10-02Remove trailing whitespace in iter chain docIvan Tham-1/+1
2020-10-02Add example for iter chain structIvan Tham-0/+11
2020-10-01Add tracking issueTim Vermeulen-2/+2
2020-10-01Things are only moved if non-copyscottmcm-1/+1
2020-09-30Improve the example for ptr::copyScott McMurray-1/+11
Fixes #77220
2020-10-01Auto merge of #77381 - Dylan-DPC:rollup-0sr6p5p, r=Dylan-DPCbors-30/+114
Rollup of 12 pull requests Successful merges: - #76909 (Add Iterator::advance_by and DoubleEndedIterator::advance_back_by) - #77153 (Fix recursive nonterminal expansion during pretty-print/reparse check) - #77202 (Defer Apple SDKROOT detection to link time.) - #77303 (const evaluatable: improve `TooGeneric` handling) - #77305 (move candidate_from_obligation_no_cache) - #77315 (Rename AllocErr to AllocError) - #77319 (Stable hashing: add comments and tests concerning platform-independence) - #77324 (Don't fire `const_item_mutation` lint on writes through a pointer) - #77343 (Validate `rustc_args_required_const`) - #77349 (Update cargo) - #77360 (References to ZSTs may be at arbitrary aligned addresses) - #77371 (Remove trailing space in error message) Failed merges: r? `@ghost`
2020-10-01Rollup merge of #77315 - exrook:rename-allocerror, r=joshtriplettDylan DPC-14/+14
Rename AllocErr to AllocError Implements rust-lang/wg-allocators#57
2020-10-01Rollup merge of #76909 - timvermeulen:advance_by, r=AmanieuDylan DPC-16/+100
Add Iterator::advance_by and DoubleEndedIterator::advance_back_by This PR adds the iterator method ```rust fn advance_by(&mut self, n: usize) -> Result<(), usize> ``` that advances the iterator by `n` elements, returning `Ok(())` if this succeeds or `Err(len)` if the length of the iterator was less than `n`. Currently `Iterator::nth` is the method to override for efficiently advancing an iterator by multiple elements at once. `advance_by` is superior for this purpose because - it's simpler to implement: instead of advancing the iterator and producing the next element you only need to advance the iterator - it composes better: iterators like `Chain` and `FlatMap` can implement `advance_by` in terms of `advance_by` on their inner iterators, but they cannot implement `nth` in terms of `nth` on their inner iterators (see #60395) - the default implementation of `nth` can trivially be implemented in terms of `advance_by` and `next`, which this PR also does This PR also adds `DoubleEndedIterator::advance_back_by` for all the same reasons. I'll make a tracking issue if it's decided this is worth merging. Also let me know if anything can be improved, this went through several iterations so there might very well still be room for improvement (especially in the doc comments). I've written overrides of these methods for most iterators that already override `nth`/`nth_back`, but those still need tests so I'll add them in a later PR. cc @cuviper @scottmcm @Amanieu
2020-09-30Auto merge of #76325 - lzutao:split-core-str, r=Amanieubors-2444/+2506
Split core/str/mod.rs to smaller files Note for reviewer: * I split to multiple commits for easier reviewing, but I could git squash them all to one if requested. * Recommend pulling this change locally and using advanced git diff viewer or this command: ```bash git show --reverse --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space master.. ``` --- I split `core/str/mod.rs` to these modules: * `converts`: Contains helper functions to convert from bytes to str. * `error`: For error structs like Utf8Error. * `iter`: For iterators of many str methods. * `traits`: For indexing operations and build in traits on str. * `validations`: For functions validating utf8 --- This name is awkward, maybe utf8.rs is better.
2020-09-29Auto merge of #77289 - TimDiekmann:alloc-ref-by-ref, r=Amanieubors-1/+1
Change `AllocRef::by_ref` to take `&self` instead of `&mut self` r? `@Amanieu`
2020-09-28Rename AllocErr to AllocErrorJacob Hughes-14/+14
2020-09-28Rollup merge of #77194 - pickfire:patch-7, r=withoutboatsRalf Jung-0/+2
Add doc alias for iterator fold fold is known in python and javascript as reduce, not sure about inject but it was written in doc there. This was my first confusion when coming into rust, I somehow cannot find where is reduce, sometimes I still forget that it is known as `fold`.
2020-09-28Rollup merge of #77170 - ecstatic-morse:const-fn-ptr, r=oli-obkRalf Jung-6/+3
Remove `#[rustc_allow_const_fn_ptr]` and add `#![feature(const_fn_fn_ptr_basics)]` `rustc_allow_const_fn_ptr` was a hack to work around the lack of an escape hatch for the "min `const fn`" checks in const-stable functions. Now that we have co-opted `allow_internal_unstable` for this purpose, we no longer need a bespoke attribute. Now this functionality is gated under `const_fn_fn_ptr_basics` (how concise!), and `#[allow_internal_unstable(const_fn_fn_ptr_basics)]` replaces `#[rustc_allow_const_fn_ptr]`. `const_fn_fn_ptr_basics` allows function pointer types to appear in the arguments and locals of a `const fn` as well as function pointer casts to be performed inside a `const fn`. Both of these were allowed in constants and statics already. Notably, this does **not** allow users to invoke function pointers in a const context. Presumably, we will use a nicer name for that (`const_fn_ptr`?). r? @oli-obk
2020-09-28Rollup merge of #76454 - poliorcetics:ui-to-unit-test-1, r=matkladRalf Jung-1/+2
UI to unit test for those using Cell/RefCell/UnsafeCell Helps with #76268. I'm working on all files using `Cell` and moving them to unit tests when possible. r? @matklad
2020-09-28Change `AllocRef::by_ref` to take `&self` instead of `&mut self`Tim Diekmann-1/+1
2020-09-27Remove `rustc_allow_const_fn_ptr`Dylan MacKenzie-6/+1
This was a hack to work around the lack of an escape hatch for the "min `const fn`" checks in const-stable functions. Now that we have co-opted `allow_internal_unstable` for this purpose, we no longer need the bespoke attribute.
2020-09-27Add a feature gate for basic function pointer use in `const fn`Dylan MacKenzie-0/+2
2020-09-27Refactor memchr to allow optimizationDániel Buga-16/+27
2020-09-26Rollup merge of #77122 - ecstatic-morse:const-fn-arithmetic, r=RalfJung,oli-obkRalf Jung-0/+1
Add `#![feature(const_fn_floating_point_arithmetic)]` cc #76618 This is a template for splitting up `const_fn` into granular feature gates. I think this will make it easier, both for us and for users, to track stabilization of each individual feature. We don't *have* to do this, however. We could also keep stabilizing things out from under `const_fn`. cc @rust-lang/wg-const-eval r? @oli-obk
2020-09-26Rollup merge of #77076 - GuillaumeGomez:missing-code-examples-slice-iter, ↵Ralf Jung-0/+164
r=Dylan-DPC Add missing code examples on slice iter types r? @Dylan-DPC
2020-09-26Rollup merge of #75454 - ltratt:option_optimisation_guarantees, r=dtolnayRalf Jung-4/+17
Explicitly document the size guarantees that Option makes. Triggered by a discussion on wg-unsafe-code-guidelines about which layouts of `Option<T>` one can guarantee are optimised to a single pointer. CC @RalfJung
2020-09-26Remove unneeded tidy commentLzu Tao-2/+0
2020-09-26Gather all ZST structs of str togetherLzu Tao-26/+22
2020-09-26Move functions converting bytes to str to new modLzu Tao-194/+202
2020-09-26Move utf-8 validating helpers to new modLzu Tao-279/+288
2020-09-26Move str's impl of iterations to new modLzu Tao-1246/+1292
2020-09-26Move traits implementation of str to new modLzu Tao-602/+599
Also move FromStr trait
2020-09-26Move Utf8Error to new modLzu Tao-126/+134
2020-09-26Stabilize slice_ptr_range.Mara Bos-4/+2
Closes #65807.
2020-09-25Auto merge of #77201 - matthewjasper:rename-get-unchecked, r=spastorinobors-57/+65
Rename Iterator::get_unchecked Closes #76479 r? `@pnkfelix`
2020-09-25review: fix nits and move panic safety tests to the correct placeAlexis Bourget-1/+2
2020-09-25Add missing code examples on slice iter typesGuillaume Gomez-0/+164
2020-09-25Rename Iterator::get_uncheckedMatthew Jasper-57/+65
It's possible for method resolution to pick this method over a lower priority stable method, causing compilation errors. Since this method is permanently unstable, give it a name that is very unlikely to be used in user code.
2020-09-25Rollup merge of #77176 - austinkeeley:intrinsics-documentatation-error, r=jyn514Jonas Schievink-1/+1
Removing erroneous semicolon in transmute documentation There is a semicolon in the example code that causes the expected value to not be returned.
2020-09-25Rollup merge of #77097 - fusion-engineering-forks:slice-ptr-range-const-fn, ↵Jonas Schievink-3/+6
r=oli-obk Make [].as_[mut_]ptr_range() (unstably) const. Gated behind `const_ptr_offset`, as suggested by https://github.com/rust-lang/rust/issues/65807#issuecomment-697229404 This also marks `[].as_mut_ptr()` as const, because it's used by `as_mut_ptr_range`. I gated it behind the same feature, because I figured it's not worth adding a separate tracking issue for const `as_mut_ptr`.