| Age | Commit message (Collapse) | Author | Lines |
|
Co-authored-by: David Tolnay <dtolnay@gmail.com>
|
|
Co-authored-by: Peter Todd <pete@petertodd.org>
|
|
|
|
|
|
|
|
|
|
This allows ControlFlow<BreakType> which is much more ergonomic for
common iterator combinator use cases.
|
|
|
|
Clean up on example doc fixes for ptr::copy
Follow up of #77385
r? @scottmcm
|
|
Add example for iter chain struct
r? @GuillaumeGomez
|
|
Add tracking issue of iter_advance_by feature
|
|
Follow up of #77385
|
|
Improve the example for ptr::copy
Fixes #77220
|
|
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
|
|
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.
|
|
|
|
|
|
|
|
|
|
Fixes #77220
|
|
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`
|
|
Rename AllocErr to AllocError
Implements rust-lang/wg-allocators#57
|
|
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
|
|
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.
|
|
Change `AllocRef::by_ref` to take `&self` instead of `&mut self`
r? `@Amanieu`
|
|
|
|
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`.
|
|
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
|
|
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
|
|
|
|
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.
|
|
|
|
|
|
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
|
|
r=Dylan-DPC
Add missing code examples on slice iter types
r? @Dylan-DPC
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
Also move FromStr trait
|
|
|
|
Closes #65807.
|
|
Rename Iterator::get_unchecked
Closes #76479
r? `@pnkfelix`
|
|
|
|
|
|
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.
|
|
Removing erroneous semicolon in transmute documentation
There is a semicolon in the example code that causes the expected value to not be returned.
|
|
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`.
|