| Age | Commit message (Collapse) | Author | Lines | |
|---|---|---|---|---|
| 2022-12-26 | Revert "Replace usage of `ResumeTy` in async lowering with `Context`" | Andrew Pollack | -9/+2 | |
| 2022-12-12 | update stabilization version numbers | Pietro Albini | -34/+34 | |
| 2022-12-09 | Auto merge of #105262 - eduardosm:more-inline-always, r=thomcc | bors | -25/+33 | |
| Make some trivial functions `#[inline(always)]` This is some kind of follow-up of PRs like https://github.com/rust-lang/rust/pull/85218, https://github.com/rust-lang/rust/pull/84061, https://github.com/rust-lang/rust/pull/87150. Functions that do very basic operations are made `#[inline(always)]` to avoid pessimizing them in debug builds when compared to using built-in operations directly. | ||||
| 2022-12-09 | Rollup merge of #105474 - RalfJung:typo, r=dtolnay | Matthias Krüger | -1/+1 | |
| lib docs: fix typo r? `@thomcc` | ||||
| 2022-12-09 | Rollup merge of #105245 - RalfJung:align_to, r=Amanieu | Matthias Krüger | -8/+10 | |
| attempt to clarify align_to docs This is not intended the change the docs at all, but `@workingjubilee` said the current docs are incomprehensible to some people so this is an attempt to fix that. No idea if it helps, so -- feedback welcome. (Please let's not use this to discuss *changing* the spec. Whoever wants to change the spec should please make a separate PR for that.) | ||||
| 2022-12-08 | lib docs: fix typo | Ralf Jung | -1/+1 | |
| 2022-12-08 | Fix warning when libcore is compiled with no_fp_fmt_parse | Gary Guo | -1/+3 | |
| 2022-12-07 | Make some trivial functions `#[inline(always)]` | Eduardo Sánchez Muñoz | -25/+33 | |
| 2022-12-06 | Auto merge of #105271 - eduardosm:inline-always-int-conv, r=scottmcm | bors | -1/+1 | |
| Make integer-to-integer `From` impls `#[inline(always)]` Splited from https://github.com/rust-lang/rust/pull/105262 | ||||
| 2022-12-06 | Rollup merge of #105250 - Swatinem:async-rm-resumety, r=oli-obk | Matthias Krüger | -2/+9 | |
| Replace usage of `ResumeTy` in async lowering with `Context` Replaces using `ResumeTy` / `get_context` in favor of using `&'static mut Context<'_>`. Usage of the `'static` lifetime here is technically "cheating", and replaces the raw pointer in `ResumeTy` and the `get_context` fn that pulls the correct lifetimes out of thin air. fixes https://github.com/rust-lang/rust/issues/104828 and https://github.com/rust-lang/rust/pull/104321#issuecomment-1336363077 r? `@oli-obk` | ||||
| 2022-12-06 | Replace usage of `ResumeTy` in async lowering with `Context` | Arpad Borsos | -2/+9 | |
| Replaces using `ResumeTy` / `get_context` in favor of using `&'static mut Context<'_>`. Usage of the `'static` lifetime here is technically "cheating", and replaces the raw pointer in `ResumeTy` and the `get_context` fn that pulls the correct lifetimes out of thin air. | ||||
| 2022-12-06 | Rollup merge of #105289 - Rageking8:fix-dupe-word-typos, r=cjgillot | Yuki Okushi | -2/+2 | |
| Fix dupe word typos | ||||
| 2022-12-05 | Rollup merge of #104912 - RalfJung:per, r=Mark-Simulacrum | Matthias Krüger | -2/+3 | |
| PartialEq: PERs are homogeneous PartialEq claims that it corresponds to a PER, but that is only a well-defined statement when `Rhs == Self`. There is no standard notion of PER on a relation between two different sets/types. So move this out of the first paragraph and clarify this. | ||||
| 2022-12-05 | attempt to clarify align_to docs | Ralf Jung | -8/+10 | |
| 2022-12-05 | fix dupe word typos | Rageking8 | -2/+2 | |
| 2022-12-04 | Make integer-to-integer `From` impls `#[inline(always)]` | Eduardo Sánchez Muñoz | -1/+1 | |
| 2022-12-04 | Auto merge of #101514 - nvzqz:nvzqz/stabilize-nonzero-bits, r=thomcc | bors | -2/+1 | |
| Stabilize `nonzero_bits` Closes #94881, implemented by #93292. This change stabilizes the associated `BITS` constant for `NonZero{U,I}{8,16,32,64,128,size}` integers, e.g.: ```rs impl NonZeroUsize { pub const BITS: u32 = usize::BITS; } ``` | ||||
| 2022-12-02 | Auto merge of #104999 - saethlin:immediate-abort-inlining, r=thomcc | bors | -22/+24 | |
| Adjust inlining attributes around panic_immediate_abort The goal of `panic_immediate_abort` is to permit the panic runtime and formatting code paths to be optimized away. But while poking through some disassembly of a small program compiled with that option, I found that was not the case. Enabling LTO did address that specific issue, but enabling LTO is a steep price to pay for this feature doing its job. This PR fixes that, by tweaking two things: * All the slice indexing functions that we `const_eval_select` on get `#[inline]`. `objdump -dC` told me that originally some `_ct` functions could end up in an executable. I won't pretend to understand what's going on there. * Normalize attributes across all `panic!` wrappers: use `inline(never) + cold` normally, and `inline` when `panic_immediate_abort` is enabled. But also, with LTO and `panic_immediate_abort` enabled, this patch knocks ~709 kB out of the `.text` segment of `librustc_driver.so`. That is slightly surprising to me, my best theory is that this shifts some inlining earlier in compilation, enabling some subsequent optimizations. The size improvement of `librustc_driver.so` with `panic_immediate_abort` due to this patch is greater with LTO than without LTO, which I suppose backs up this theory. I do not know how to test this. I would quite like to, because I think what this is solving was an accidental regression. This only works with `-Zbuild-std` which is a cargo flag, and thus can't be used in a rustc codegen test. r? `@thomcc` --- I do not seriously think anyone is going to use a compiler built with `panic_immediate_abort`, but I wanted a big complicated Rust program to try this out on, and the compiler is such. | ||||
| 2022-12-02 | Rollup merge of #104614 - Nilstrieb:type-ascribe!, r=TaKO8Ki | Matthias Krüger | -0/+20 | |
| Add `type_ascribe!` macro as placeholder syntax for type ascription This makes it still possible to test the internal semantics of type ascription even once the `:`-syntax is removed from the parser. The macro now gets used in a bunch of UI tests that test the semantics and not syntax of type ascription. I might have forgotten a few tests but this should hopefully be most of them. The remaining ones will certainly be found once type ascription is removed from the parser altogether. Part of #101728 | ||||
| 2022-12-01 | Auto merge of #104975 - JakobDegen:custom_mir_let, r=oli-obk | bors | -4/+170 | |
| `#![custom_mir]`: Various improvements This PR makes a bunch of improvements to `#![custom_mir]`. Ideally this would be 4 PRs, one for each commit, but those would take forever to get merged and be a pain to juggle. Should still be reviewed one commit at a time though. ### Commit 1: Support arbitrary `let` Before this change, all locals used in the body need to be declared at the top of the `mir!` invocation, which is rather annoying. We attempt to change that. Unfortunately, we still have the requirement that the output of the `mir!` macro must resolve, typecheck, etc. Because of that, we can't just accept this in the THIR -> MIR parser because something like ```rust { let x = 0; Goto(other) } other = { RET = x; Return() } ``` will fail to resolve. Instead, the implementation does macro shenanigans to find the let declarations and extract them as part of the `mir!` macro. That *works*, but it is fairly complicated and degrades debuginfo by quite a bit. Specifically, the spans for any statements and declarations that are affected by this are completely wrong. My guess is that this is a net improvement though. One way to recover some of the debuginfo would be to not support type annotations in the `let` statements, which would allow us to parse like `let $stmt:stmt`. That seems quite surprising though. ### Commit 2: Parse consts Reuses most of the const parsing from regular Mir building for building custom mir ### Commit 3: Parse statics Statics are slightly weird because the Mir primitive associated with them is a reference/pointer to them, so this is factored out separately. ### Commit 4: Fix some spans A bunch of the spans were non-ideal, so we adjust them to be much more helpful. r? `@oli-obk` | ||||
| 2022-12-01 | Gate macros behind `#[cfg(not(bootstrap))]` | nils | -11/+1 | |
| Co-authored-by: Takayuki Maeda <takoyaki0316@gmail.com> | ||||
| 2022-11-29 | Support statics in custom mir | Jakob Degen | -0/+2 | |
| 2022-11-29 | Support most constant kinds in custom mir | Jakob Degen | -0/+29 | |
| 2022-11-29 | Support arbitrary `let` statements in custom mir | Jakob Degen | -4/+139 | |
| 2022-11-29 | Rollup merge of #104436 - ↵ | Matthias Krüger | -1/+1 | |
| ismailmaj:add-slice-to-stack-allocated-string-comment, r=Mark-Simulacrum Add slice to the stack allocated string comment Precise that the "stack allocated string" is not a string but a string slice. ``@rustbot`` label +A-docs | ||||
| 2022-11-29 | Adjust inlining attributes around panic_immediate_abort | Ben Kimock | -22/+24 | |
| 2022-11-27 | Rollup merge of #104892 - lukas-code:discriminant, r=scottmcm | Matthias Krüger | -1/+60 | |
| Explain how to get the discriminant out of a `#[repr(T)] enum` with payload example stolen from https://github.com/rust-lang/reference/pull/1055 ````@rustbot```` label A-docs | ||||
| 2022-11-27 | Auto merge of #104818 - scottmcm:refactor-extend-func, r=the8472 | bors | -1/+37 | |
| Stop peeling the last iteration of the loop in `Vec::resize_with` `resize_with` uses the `ExtendWith` code that peels the last iteration: https://github.com/rust-lang/rust/blob/341d8b8a2c290b4535e965867e876b095461ff6e/library/alloc/src/vec/mod.rs#L2525-L2529 But that's kinda weird for `ExtendFunc` because it does the same thing on the last iteration anyway: https://github.com/rust-lang/rust/blob/341d8b8a2c290b4535e965867e876b095461ff6e/library/alloc/src/vec/mod.rs#L2494-L2502 So this just has it use the normal `extend`-from-`TrustedLen` code instead. r? `@ghost` | ||||
| 2022-11-26 | fix broken link fragment | Lukas Markeffsky | -1/+1 | |
| 2022-11-26 | explain how to get the discriminant out of a `#[repr(T)] enum` | Lukas Markeffsky | -1/+60 | |
| 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. | ||||
