| Age | Commit message (Collapse) | Author | Lines | |
|---|---|---|---|---|
| 2022-11-26 | Auto merge of #104935 - matthiaskrgr:rollup-nuca86l, r=matthiaskrgr | bors | -1/+12 | |
| Rollup of 6 pull requests Successful merges: - #104121 (Refine `instruction_set` MIR inline rules) - #104675 (Unsupported query error now specifies if its unsupported for local or external crate) - #104839 (improve array_from_fn documenation) - #104880 ([llvm-wrapper] adapt for LLVM API change) - #104899 (rustdoc: remove no-op CSS `#help dt { display: block }`) - #104906 (Remove AscribeUserTypeCx) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup | ||||
| 2022-11-26 | Rollup merge of #104839 - HintringerFabian:docs_array_from_fn, r=scottmcm | Matthias Krüger | -1/+12 | |
| improve array_from_fn documenation Improves array::from_fn documentation Fixes #102609 There were also unresolved comments from [this PR #100462](https://github.com/rust-lang/rust/pull/100462), which have been added to my PR | ||||
| 2022-11-26 | Auto merge of #103556 - clubby789:specialize-option-partial-eq, r=scottmcm | bors | -1/+67 | |
| Manually implement PartialEq for Option<T> and specialize non-nullable types This PR manually implements `PartialEq` and `StructuralPartialEq` for `Option`, which seems to produce slightly better codegen than the automatically derived implementation. It also allows specializing on the `core::num::NonZero*` and `core::ptr::NonNull` types, taking advantage of the niche optimization by transmuting the `Option<T>` to `T` to be compared directly, which can be done in just two instructions. A comparison of the original, new and specialized code generation is available [here](https://godbolt.org/z/dE4jxdYsa). | ||||
| 2022-11-25 | PERs are homogeneous | Ralf Jung | -2/+3 | |
| 2022-11-25 | Rollup merge of #104873 - RalfJung:therefore, r=Dylan-DPC | Matthias Krüger | -1/+1 | |
| RefCell::get_mut: fix typo and fix the same typo in a bunch of other places | ||||
| 2022-11-25 | change example of array_from_fn to match suggestion | Fabian Hintringer | -3/+3 | |
| 2022-11-25 | RefCell::get_mut: fix typo | Ralf Jung | -1/+1 | |
| and fix the same typo in a bunch of other places | ||||
| 2022-11-24 | Tune RepeatWith::try_fold and Take::for_each and Vec::extend_trusted | Scott McMurray | -1/+37 | |
| 2022-11-24 | Rollup merge of #104774 - vojtechkral:doc-str-empty-split-whitespace, r=thomcc | Matthias Krüger | -0/+12 | |
| Document split{_ascii,}_whitespace() for empty strings doc change only | ||||
| 2022-11-24 | improve array_from_fn documenation | Fabian Hintringer | -2/+13 | |
| 2022-11-24 | Document split{_ascii,}_whitespace() for empty strings | Vojtech Kral | -0/+12 | |
| 2022-11-24 | Avoid `GenFuture` shim when compiling async constructs | Arpad Borsos | -8/+20 | |
| Previously, async constructs would be lowered to "normal" generators, with an additional `from_generator` / `GenFuture` shim in between to convert from `Generator` to `Future`. The compiler will now special-case these generators internally so that async constructs will *directly* implement `Future` without the need to go through the `from_generator` / `GenFuture` shim. The primary motivation for this change was hiding this implementation detail in stack traces and debuginfo, but it can in theory also help the optimizer as there is less abstractions to see through. | ||||
| 2022-11-22 | fix OOB access in SIMD impl of str.contains() | The 8472 | -4/+6 | |
| 2022-11-22 | disable strict-provenance-violating doctests in Miri | Ralf Jung | -0/+10 | |
| 2022-11-22 | Rollup merge of #102207 - CraftSpider:const-layout, r=scottmcm | Manish Goregaokar | -18/+45 | |
| Constify remaining `Layout` methods Makes the methods on `Layout` that aren't yet unstably const, under the same feature and issue, #67521. Most of them required no changes, only non-trivial change is probably constifying `ValidAlignment` which may affect #102072 | ||||
| 2022-11-22 | Rollup merge of #95583 - scottmcm:deprecate-ptr-to-from-bits, r=dtolnay | Manish Goregaokar | -0/+20 | |
| Deprecate the unstable `ptr_to_from_bits` feature I propose that we deprecate the (unstable!) `to_bits` and `from_bits` methods on raw pointers. (With the intent to ~~remove them once `addr` has been around long enough to make the transition easy on people -- maybe another 6 weeks~~ remove them fairly soon after, as the strict and expose versions have been around for a while already.) The APIs that came from the strict provenance explorations (#95228) are a more holistic version of these, and things like `.expose_addr()` work for the "that cast looks sketchy" case even if the full strict provenance stuff never happens. (As a bonus, `addr` is even shorter than `to_bits`, though it is only applicable if people can use full strict provenance! `addr` is *not* a direct replacement for `to_bits`.) So I think it's fine to move away from the `{to|from}_bits` methods, and encourage the others instead. That also resolves the worry that was brought up (I forget where) that `q.to_bits()` and `(*q).to_bits()` both work if `q` is a pointer-to-floating-point, as they also have a `to_bits` method. Tracking issue #91126 Code search: https://github.com/search?l=Rust&p=1&q=ptr_to_from_bits&type=Code For potential pushback, some users in case they want to chime in - `@RSSchermer` https://github.com/RSSchermer/ARWA/blob/365bb68541447453fc44f6fbcc5d394bb94c14e9/arwa/src/html/custom_element.rs#L105 - `@strax` https://github.com/strax/pbr/blob/99616d1dbf42f93ec8dd668d05b3180649558180/openexr/src/core/alloc.rs#L36 - `@MiSawa` https://github.com/MiSawa/pomelo/blob/577c6223588d539295a71ff125d8f249e59f4146/crates/kernel/src/timer.rs#L50 | ||||
| 2022-11-22 | Rollup merge of #83608 - Kimundi:index_many, r=Mark-Simulacrum | Manish Goregaokar | -0/+139 | |
| Add slice methods for indexing via an array of indices. Disclaimer: It's been a while since I contributed to the main Rust repo, apologies in advance if this is large enough already that it should've been an RFC. --- # Update: - Based on feedback, removed the `&[T]` variant of this API, and removed the requirements for the indices to be sorted. # Description This adds the following slice methods to `core`: ```rust impl<T> [T] { pub unsafe fn get_many_unchecked_mut<const N: usize>(&mut self, indices: [usize; N]) -> [&mut T; N]; pub fn get_many_mut<const N: usize>(&mut self, indices: [usize; N]) -> Option<[&mut T; N]>; } ``` This allows creating multiple mutable references to disjunct positions in a slice, which previously required writing some awkward code with `split_at_mut()` or `iter_mut()`. For the bound-checked variant, the indices are checked against each other and against the bounds of the slice, which requires `N * (N + 1) / 2` comparison operations. This has a proof-of-concept standalone implementation here: https://crates.io/crates/index_many Care has been taken that the implementation passes miri borrow checks, and generates straight-forward assembly (though this was only checked on x86_64). # Example ```rust let v = &mut [1, 2, 3, 4]; let [a, b] = v.get_many_mut([0, 2]).unwrap(); std::mem::swap(a, b); *v += 100; assert_eq!(v, &[3, 2, 101, 4]); ``` # Codegen Examples <details> <summary>Click to expand!</summary> Disclaimer: Taken from local tests with the standalone implementation. ## Unchecked Indexing: ```rust pub unsafe fn example_unchecked(slice: &mut [usize], indices: [usize; 3]) -> [&mut usize; 3] { slice.get_many_unchecked_mut(indices) } ``` ```nasm example_unchecked: mov rcx, qword, ptr, [r9] mov r8, qword, ptr, [r9, +, 8] mov r9, qword, ptr, [r9, +, 16] lea rcx, [rdx, +, 8*rcx] lea r8, [rdx, +, 8*r8] lea rdx, [rdx, +, 8*r9] mov qword, ptr, [rax], rcx mov qword, ptr, [rax, +, 8], r8 mov qword, ptr, [rax, +, 16], rdx ret ``` ## Checked Indexing (Option): ```rust pub unsafe fn example_option(slice: &mut [usize], indices: [usize; 3]) -> Option<[&mut usize; 3]> { slice.get_many_mut(indices) } ``` ```nasm mov r10, qword, ptr, [r9, +, 8] mov rcx, qword, ptr, [r9, +, 16] cmp rcx, r10 je .LBB0_7 mov r9, qword, ptr, [r9] cmp rcx, r9 je .LBB0_7 cmp rcx, r8 jae .LBB0_7 cmp r10, r9 je .LBB0_7 cmp r9, r8 jae .LBB0_7 cmp r10, r8 jae .LBB0_7 lea r8, [rdx, +, 8*r9] lea r9, [rdx, +, 8*r10] lea rcx, [rdx, +, 8*rcx] mov qword, ptr, [rax], r8 mov qword, ptr, [rax, +, 8], r9 mov qword, ptr, [rax, +, 16], rcx ret .LBB0_7: mov qword, ptr, [rax], 0 ret ``` ## Checked Indexing (Panic): ```rust pub fn example_panic(slice: &mut [usize], indices: [usize; 3]) -> [&mut usize; 3] { let len = slice.len(); match slice.get_many_mut(indices) { Some(s) => s, None => { let tmp = indices; index_many::sorted_bound_check_failed(&tmp, len) } } } ``` ```nasm example_panic: sub rsp, 56 mov rax, qword, ptr, [r9] mov r10, qword, ptr, [r9, +, 8] mov r9, qword, ptr, [r9, +, 16] cmp r9, r10 je .LBB0_6 cmp r9, rax je .LBB0_6 cmp r9, r8 jae .LBB0_6 cmp r10, rax je .LBB0_6 cmp rax, r8 jae .LBB0_6 cmp r10, r8 jae .LBB0_6 lea rax, [rdx, +, 8*rax] lea r8, [rdx, +, 8*r10] lea rdx, [rdx, +, 8*r9] mov qword, ptr, [rcx], rax mov qword, ptr, [rcx, +, 8], r8 mov qword, ptr, [rcx, +, 16], rdx mov rax, rcx add rsp, 56 ret .LBB0_6: mov qword, ptr, [rsp, +, 32], rax mov qword, ptr, [rsp, +, 40], r10 mov qword, ptr, [rsp, +, 48], r9 lea rcx, [rsp, +, 32] mov edx, 3 call index_many::bound_check_failed ud2 ``` </details> # Extensions There are multiple optional extensions to this. ## Indexing With Ranges This could easily be expanded to allow indexing with `[I; N]` where `I: SliceIndex<Self>`. I wanted to keep the initial implementation simple, so I didn't include it yet. ## Panicking Variant We could also add this method: ```rust impl<T> [T] { fn index_many_mut<const N: usize>(&mut self, indices: [usize; N]) -> [&mut T; N]; } ``` This would work similar to the regular index operator and panic with out-of-bound indices. The advantage would be that we could more easily ensure good codegen with a useful panic message, which is non-trivial with the `Option` variant. This is implemented in the standalone implementation, and used as basis for the codegen examples here and there. | ||||
| 2022-11-21 | Rustc_deprecated attribute superseded by deprecated | David Tolnay | -8/+8 | |
| 2022-11-21 | Bump ptr_to_from_bits deprecation to Rust 1.67 | David Tolnay | -4/+4 | |
| 2022-11-22 | Rollup merge of #103396 - RalfJung:pinning-closure-captures, r=dtolnay | Matthias Krüger | -2/+55 | |
| Pin::new_unchecked: discuss pinning closure captures Regardless of how the discussion in https://github.com/rust-lang/rust/pull/102737 turns out, pinning closure captures is super subtle business and probably worth discussing separately. | ||||
| 2022-11-21 | Document all unsafe blocks | Lukas Bergdoll | -1/+20 | |
| There were several unsafe blocks in the existing implementation that were not documented with a SAFETY comment. | ||||
| 2022-11-21 | Remove debug unused | Lukas Bergdoll | -12/+13 | |
| 2022-11-21 | Rollup merge of #104420 - TethysSvensson:master, r=JohnTitor | Matthias Krüger | -1/+1 | |
| Fix doc example for `wrapping_abs` The `max` variable is unused. This change introduces the `min_plus` variable, to make the example similar to the one from `saturating_abs`. An alternative would be to remove the unused variable. | ||||
| 2022-11-21 | type annotate &str when stack allocating a string | ismailmaj | -1/+1 | |
| 2022-11-20 | Rollup merge of #104643 - pnkfelix:examples-for-chunks-remainder, r=scottmcm | Matthias Krüger | -2/+30 | |
| add examples to chunks remainder methods. add examples to chunks remainder methods. my motivation for adding the examples was to make it very clear that the state of the iterator (in terms of where its cursor lies) has no effect on what remainder returns. Also fixed some links to rchunk remainder methods. | ||||
| 2022-11-20 | Rollup merge of #104634 - RalfJung:core-arch, r=Mark-Simulacrum | Matthias Krüger | -31/+31 | |
| move core::arch into separate file This works around https://github.com/rust-lang/rust/issues/104633 which otherwise leads to warnings in miri-test-libstd. | ||||
| 2022-11-20 | Rollup merge of #104632 - RalfJung:core-test-strict-provenance, r=thomcc | Matthias Krüger | -0/+6 | |
| avoid non-strict-provenance casts in libcore tests r? `@thomcc` | ||||
| 2022-11-20 | Only one feature gate needed | Rune Tynan | -1/+0 | |
| 2022-11-20 | Use ? instead of match | Rune Tynan | -4/+2 | |
| 2022-11-20 | Fix issue number | Rune Tynan | -1/+1 | |
| 2022-11-20 | Add derive_const feature | Rune Tynan | -0/+1 | |
| 2022-11-20 | Update with derive_const | Rune Tynan | -13/+15 | |
| 2022-11-20 | Add stability for alignment | Rune Tynan | -0/+2 | |
| 2022-11-20 | constify remaining layout methods | Rune Tynan | -15/+40 | |
| Remove bad impl for Eq Update Cargo.lock and fix last ValidAlign | ||||
| 2022-11-20 | Unify stable and unstable sort implementations in same core module | Lukas Bergdoll | -1/+501 | |
| This moves the stable sort implementation to the core::slice::sort module. By virtue of being in core it can't access `Vec`. The two `Vec` used by merge sort, `buf` and `runs`, are modelled as custom types that implement the very limited required `Vec` interface with the help of provided allocation and free functions. This is done to allow future re-use of functions and logic between stable and unstable sort. Such as `insert_head`. | ||||
| 2022-11-20 | Rollup merge of #104568 - RalfJung:realloc, r=Amanieu | Matthias Krüger | -7/+11 | |
| clarify that realloc refreshes pointer provenance even when the allocation remains in-place This [matches what C does](https://en.cppreference.com/w/c/memory/realloc): > The original pointer ptr is invalidated and any access to it is undefined behavior (even if reallocation was in-place). Cc `@rust-lang/wg-allocators` | ||||
| 2022-11-20 | add examples to chunks remainder methods. Also fixed some links to rchunk ↵ | Felix S. Klock II | -2/+30 | |
| remainder methods. | ||||
| 2022-11-20 | Add get_many_mut methods to slice | Marvin Löbel | -0/+139 | |
| 2022-11-20 | enable fuzzy_provenance_casts in libcore+tests | Ralf Jung | -0/+6 | |
| 2022-11-20 | Incorporate review feedback | Tethys Svensson | -4/+1 | |
| 2022-11-20 | move core::arch into separate file | Ralf Jung | -31/+31 | |
| 2022-11-20 | Rollup merge of #104435 - scottmcm:iter-repeat-n, r=thomcc | Yuki Okushi | -0/+201 | |
| `VecDeque::resize` should re-use the buffer in the passed-in element Today it always copies it for *every* appended element, but one of those clones is avoidable. This adds `iter::repeat_n` (https://github.com/rust-lang/rust/issues/104434) as the primitive needed to do this. If this PR is acceptable, I'll also use this in `Vec` rather than its custom `ExtendElement` type & infrastructure that is harder to share between multiple different containers: https://github.com/rust-lang/rust/blob/101e1822c3e54e63996c8aaa014d55716f3937eb/library/alloc/src/vec/mod.rs#L2479-L2492 | ||||
| 2022-11-20 | Rollup merge of #103901 - H4x5:fmt-arguments-as-str-tracking-issue, r=the8472 | Yuki Okushi | -1/+1 | |
| Add tracking issue for `const_arguments_as_str` Tracking issue: #103900 The original PR didn't create a tracking issue. | ||||
| 2022-11-19 | Add unstable `type_ascribe` macro | Nilstrieb | -0/+30 | |
| This macro serves as a placeholder for future type ascription syntax to make sure that the semantic implementation keeps working. | ||||
| 2022-11-19 | Update comment on pointer-to-usize transmute | Lukas | -3/+4 | |
| Co-authored-by: Ralf Jung <post@ralfj.de> | ||||
| 2022-11-19 | Revert "don't call `align_offset` during const eval, ever" | Lukas Markeffsky | -2/+5 | |
| This reverts commit f3a577bfae376c0222e934911865ed14cddd1539. | ||||
| 2022-11-19 | docs cleanup | Lukas Markeffsky | -72/+140 | |
| * Fix doc examples for Platforms with underaligned integer primitives. * Mutable pointer doc examples use mutable pointers. * Fill out tracking issue. * Minor formatting changes. | ||||
| 2022-11-19 | always use `align_offset` in `is_aligned_to` + add assembly test | Lukas Markeffsky | -26/+12 | |
| 2022-11-19 | Schrödinger's pointer | Lukas Markeffsky | -0/+84 | |
| It's aligned *and* not aligned! | ||||
| 2022-11-19 | address more review comments | Lukas Markeffsky | -56/+52 | |
| * `cfg` only the body of `align_offset` * put explicit panics back * explain why `ptr.align_offset(align) == 0` is slow | ||||
