about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2025-04-05Auto merge of #139292 - compiler-errors:folder-experiment-7, r=lqdbors-1/+23
Folder experiment: Micro-optimize RegionEraserVisitor **NOTE:** This is one of a series of perf experiments that I've come up with while sick in bed. I'm assigning them to lqd b/c you're a good reviewer and you'll hopefully be awake when these experiments finish, lol. r? lqd The region eraser is very hot, so let's see if we can avoid erasing types (and visiting consts and preds that don't have region-ful types) unnecessarily.
2025-04-05Auto merge of #139401 - matthiaskrgr:rollup-uqdfj6u, r=matthiaskrgrbors-351/+558
Rollup of 4 pull requests Successful merges: - #138368 (KCFI: Add KCFI arity indicator support) - #138381 (Implement `SliceIndex` for `ByteStr`) - #139092 (Move `fd` into `std::sys`) - #139398 (Change notifications for Exploit Mitigations PG) r? `@ghost` `@rustbot` modify labels: rollup
2025-04-05Rollup merge of #139398 - rcvalle:rust-exploit-mitigations-pg-notifications, ↵Matthias Krüger-3/+3
r=cuviper Change notifications for Exploit Mitigations PG Reduce the amount of notifications sent to all the Exploit Mitigations PG by removing it from some of the paths.
2025-04-05Rollup merge of #139092 - thaliaarchi:move-fd-pal, r=joboetMatthias Krüger-33/+55
Move `fd` into `std::sys` Move platform definitions of `fd` into `std::sys`, as part of https://github.com/rust-lang/rust/issues/117276. Unlike other modules directly under `std::sys`, this is only available on some platforms and I have not provided a fallback abstraction for unsupported platforms. That is similar to how `std::os::fd` is gated to only supported platforms. Also, fix the `unsafe_op_in_unsafe_fn` lint, which was allowed for the Unix fd impl. Since macro expansions from `std::sys::pal::unix::weak` trigger this lint, fix it there too. cc `@joboet,` `@ChrisDenton` try-job: x86_64-gnu-aux
2025-04-05Rollup merge of #138381 - thaliaarchi:bstr-sliceindex, r=joshtriplettMatthias Krüger-315/+352
Implement `SliceIndex` for `ByteStr` Implement `Index` and `IndexMut` for `ByteStr` in terms of `SliceIndex`. Implement it for the same types that `&[u8]` supports (a superset of those supported for `&str`, which does not have `usize` and `ops::IndexRange`). At the same time, move compare and index traits to a separate file in the `bstr` module, to give it more space to grow as more functionality is added (e.g., iterators and string-like ops). Order the items in `bstr/traits.rs` similarly to `str/traits.rs`. cc `@joshtriplett` `ByteStr`/`ByteString` tracking issue: https://github.com/rust-lang/rust/issues/134915
2025-04-05Rollup merge of #138368 - rcvalle:rust-kcfi-arity, r=davidtwcoMatthias Krüger-0/+148
KCFI: Add KCFI arity indicator support Adds KCFI arity indicator support to the Rust compiler (see https://github.com/rust-lang/rust/issues/138311, https://github.com/llvm/llvm-project/pull/121070, and https://lore.kernel.org/lkml/CANiq72=3ghFxy8E=AU9p+0imFxKr5iU3sd0hVUXed5BA+KjdNQ@mail.gmail.com/).
2025-04-05Auto merge of #139281 - petrochenkov:ctxtdecod6, r=wesleywiserbors-103/+67
hygiene: Avoid recursion in syntax context decoding #139241 has two components - Avoiding recursion during syntax context decoding - Encoding/decoding only the non-redundant data, and recalculating the redundant data again during decoding Both of these parts may influence compilation times, possibly in opposite directions. So this PR contains only the first part to evaluate its effect in isolation.
2025-04-05KCFI: Add KCFI arity indicator supportRamon de C Valle-0/+148
Adds KCFI arity indicator support to the Rust compiler (see rust-lang/rust#138311, https://github.com/llvm/llvm-project/pull/121070, and https://lore.kernel.org/lkml/CANiq72=3ghFxy8E=AU9p+0imFxKr5iU3sd0hVUXed5BA+KjdNQ@mail.gmail.com/).
2025-04-04Fix unsafe_op_in_unsafe_fn for Unix fd and weakThalia Archibald-10/+14
2025-04-04Move fd into sysThalia Archibald-25/+43
2025-04-05Auto merge of #139396 - Zalathar:rollup-lmoqvru, r=Zalatharbors-482/+2264
Rollup of 11 pull requests Successful merges: - #136457 (Expose algebraic floating point intrinsics) - #137880 (Autodiff batching) - #137897 (fix pthread-based tls on apple targets) - #138024 (Allow optimizing out `panic_bounds_check` in Unicode checks.) - #138546 (Add integer to string formatting tests) - #138826 (StableMIR: Add `associated_items`.) - #138950 (replace extra_filename with strict version hash in metrics file names) - #139274 (Rustdoc: typecheck settings.js) - #139285 (use lower case to match other error messages) - #139341 (Apply `Recovery::Forbidden` when reparsing pasted macro fragments.) - #139389 (make `Arguments::as_statically_known_str` doc(hidden)) r? `@ghost` `@rustbot` modify labels: rollup
2025-04-05Change notifications for Exploit Mitigations PGRamon de C Valle-3/+3
Reduce the amount of notifications sent to all the Exploit Mitigations PG by removing it from some of the paths.
2025-04-05Rollup merge of #139389 - mejrs:hidden, r=workingjubileeStuart Cook-0/+1
make `Arguments::as_statically_known_str` doc(hidden) Fixes `as_statically_known_str` being [visible](https://doc.rust-lang.org/nightly/std/fmt/struct.Arguments.html#method.as_statically_known_str) ([Rendered](https://github.com/user-attachments/assets/45482d9f-2ec5-4610-be9c-b231bd2850c6)) This snuck in with https://github.com/rust-lang/rust/pull/138650, cc `@thaliaarchi` This is also visible in the beta docs. `@rustbot` label +beta-nominated
2025-04-05Rollup merge of #139341 - nnethercote:fix-137874, r=petrochenkovStuart Cook-33/+48
Apply `Recovery::Forbidden` when reparsing pasted macro fragments. Fixes #137874. The changes to the output of `tests/ui/associated-consts/issue-93835.rs` partly undo the changes seen when `NtTy` was removed in #133436, which is good. r? ``@petrochenkov``
2025-04-05Rollup merge of #139285 - tshepang:uniform-case, r=jieyouxuStuart Cook-8/+12
use lower case to match other error messages
2025-04-05Rollup merge of #139274 - lolbinarycat:rustdoc-js-less-expect-error-part5, ↵Stuart Cook-46/+100
r=notriddle Rustdoc: typecheck settings.js This makes the file fully typechecked with no instances of ``````@ts-expect-error`````` and no type casts. r? `````@notriddle`````
2025-04-05Rollup merge of #138950 - yaahc:svh-metrics-name, r=bjorn3Stuart Cook-8/+10
replace extra_filename with strict version hash in metrics file names Should resolve the potential issue of overwriting metrics from the same crate when compiled with different features or flags. r? `````@estebank````` try-job: test-various
2025-04-05Rollup merge of #138826 - makai410:assoc-items, r=celinvalStuart Cook-7/+330
StableMIR: Add `associated_items`. Resolves: https://github.com/rust-lang/project-stable-mir/issues/87
2025-04-05Rollup merge of #138546 - GuillaumeGomez:integer-to-string-tests, r=AmanieuStuart Cook-0/+70
Add integer to string formatting tests As discussed in https://github.com/rust-lang/rust/pull/136264, there doesn't seem to have tests to ensure that int to string conversion is performed correctly, only sporadic tests here and there. Now we have some basic tests. :) r? `````@Mark-Simulacrum`````
2025-04-05Rollup merge of #138024 - reitermarkus:unicode-panic-optimization, r=ibraheemdevStuart Cook-122/+346
Allow optimizing out `panic_bounds_check` in Unicode checks. Allow optimizing out `panic_bounds_check` in Unicode checks. For context, see https://github.com/japaric/ufmt/issues/52#issuecomment-2699207241.
2025-04-05Rollup merge of #137897 - xTachyon:tls-fix, r=thomcc,jieyouxuStuart Cook-1/+76
fix pthread-based tls on apple targets Tries to fix #127773.
2025-04-05Rollup merge of #137880 - EnzymeAD:autodiff-batching, r=oli-obkStuart Cook-233/+727
Autodiff batching Enzyme supports batching, which is especially known from the ML side when training neural networks. There we would normally have a training loop, where in each iteration we would pass in some data (e.g. an image), and a target vector. Based on how close we are with our prediction we compute our loss, and then use backpropagation to compute the gradients and update our weights. That's quite inefficient, so what you normally do is passing in a batch of 8/16/.. images and targets, and compute the gradients for those all at once, allowing better optimizations. Enzyme supports batching in two ways, the first one (which I implemented here) just accepts a Batch size, and then each Dual/Duplicated argument has not one, but N shadow arguments. So instead of ```rs for i in 0..100 { df(x[i], y[i], 1234); } ``` You can now do ```rs for i in 0..100.step_by(4) { df(x[i+0],x[i+1],x[i+2],x[i+3], y[i+0], y[i+1], y[i+2], y[i+3], 1234); } ``` which will give the same results, but allows better compiler optimizations. See the testcase for details. There is a second variant, where we can mark certain arguments and instead of having to pass in N shadow arguments, Enzyme assumes that the argument is N times longer. I.e. instead of accepting 4 slices with 12 floats each, we would accept one slice with 48 floats. I'll implement this over the next days. I will also add more tests for both modes. For any one preferring some more interactive explanation, here's a video of Tim's llvm dev talk, where he presents his work. https://www.youtube.com/watch?v=edvaLAL5RqU I'll also add some other docs to the dev guide and user docs in another PR. r? ghost Tracking: - https://github.com/rust-lang/rust/issues/124509 - https://github.com/rust-lang/rust/issues/135283
2025-04-05Rollup merge of #136457 - calder:master, r=tgross35Stuart Cook-24/+544
Expose algebraic floating point intrinsics # Problem A stable Rust implementation of a simple dot product is 8x slower than C++ on modern x86-64 CPUs. The root cause is an inability to let the compiler reorder floating point operations for better vectorization. See https://github.com/calder/dot-bench for benchmarks. Measurements below were performed on a i7-10875H. ### C++: 10us ✅ With Clang 18.1.3 and `-O2 -march=haswell`: <table> <tr> <th>C++</th> <th>Assembly</th> </tr> <tr> <td> <pre lang="cc"> float dot(float *a, float *b, size_t len) { #pragma clang fp reassociate(on) float sum = 0.0; for (size_t i = 0; i < len; ++i) { sum += a[i] * b[i]; } return sum; } </pre> </td> <td> <img src="https://github.com/user-attachments/assets/739573c0-380a-4d84-9fd9-141343ce7e68" /> </td> </tr> </table> ### Nightly Rust: 10us ✅ With rustc 1.86.0-nightly (8239a37f9) and `-C opt-level=3 -C target-feature=+avx2,+fma`: <table> <tr> <th>Rust</th> <th>Assembly</th> </tr> <tr> <td> <pre lang="rust"> fn dot(a: &[f32], b: &[f32]) -> f32 { let mut sum = 0.0; for i in 0..a.len() { sum = fadd_algebraic(sum, fmul_algebraic(a[i], b[i])); } sum } </pre> </td> <td> <img src="https://github.com/user-attachments/assets/9dcf953a-2cd7-42f3-bc34-7117de4c5fb9" /> </td> </tr> </table> ### Stable Rust: 84us ❌ With rustc 1.84.1 (e71f9a9a9) and `-C opt-level=3 -C target-feature=+avx2,+fma`: <table> <tr> <th>Rust</th> <th>Assembly</th> </tr> <tr> <td> <pre lang="rust"> fn dot(a: &[f32], b: &[f32]) -> f32 { let mut sum = 0.0; for i in 0..a.len() { sum += a[i] * b[i]; } sum } </pre> </td> <td> <img src="https://github.com/user-attachments/assets/936a1f7e-33e4-4ff8-a732-c3cdfe068dca" /> </td> </tr> </table> # Proposed Change Add `core::intrinsics::f*_algebraic` wrappers to `f16`, `f32`, `f64`, and `f128` gated on a new `float_algebraic` feature. # Alternatives Considered https://github.com/rust-lang/rust/issues/21690 has a lot of good discussion of various options for supporting fast math in Rust, but is still open a decade later because any choice that opts in more than individual operations is ultimately contrary to Rust's design principles. In the mean time, processors have evolved and we're leaving major performance on the table by not supporting vectorization. We shouldn't make users choose between an unstable compiler and an 8x performance hit. # References * https://github.com/rust-lang/rust/issues/21690 * https://github.com/rust-lang/libs-team/issues/532 * https://github.com/rust-lang/rust/issues/136469 * https://github.com/calder/dot-bench * https://www.felixcloutier.com/x86/vfmadd132ps:vfmadd213ps:vfmadd231ps try-job: x86_64-gnu-nopt try-job: x86_64-gnu-aux
2025-04-04Expose algebraic floating point intrinsicsCalder Coalson-24/+544
2025-04-04Auto merge of #139390 - matthiaskrgr:rollup-l64euwx, r=matthiaskrgrbors-128/+274
Rollup of 9 pull requests Successful merges: - #139041 (Remove `rustc_middle::ty::util::ExplicitSelf`.) - #139328 (Fix 2024 edition doctest panic output) - #139339 (unstable book: document tait) - #139348 (AsyncDestructor: replace fields with impl_did) - #139353 (Fix `Debug` impl for `LateParamRegionKind`.) - #139366 (ToSocketAddrs: fix typo) - #139374 (Use the span of the whole bound when the diagnostic talks about a bound) - #139378 (Use target-agnostic LLD flags in bootstrap for `use-lld`) - #139384 (Add `compiletest` adhoc_group for `r? compiletest`) r? `@ghost` `@rustbot` modify labels: rollup
2025-04-04Rollup merge of #139384 - jieyouxu:compiletest-reviewers, r=KobzolMatthias Krüger-1/+3
Add `compiletest` adhoc_group for `r? compiletest` r? `@Kobzol` (or bootstrap/compiler)
2025-04-04Rollup merge of #139378 - Kobzol:bootstrap-use-lld-fix, r=petrochenkovMatthias Krüger-2/+2
Use target-agnostic LLD flags in bootstrap for `use-lld` [Before](https://github.com/rust-lang/rust/pull/135001), I hardcoded LLD flags that pretty much only worked on GNU. The right way is to use `-Zlinker-features` instead though. I *think* that this should also make this work on Windows mingw, and thus `@petrochenkov's` workaround is no longer necessary. Fixes: https://github.com/rust-lang/rust/issues/139372 Closes: https://github.com/rust-lang/rust/pull/139375 r? `@lqd`
2025-04-04Rollup merge of #139374 - oli-obk:const-trait-bound, r=compiler-errorsMatthias Krüger-33/+33
Use the span of the whole bound when the diagnostic talks about a bound While it makes sense that the host predicate only points to the `~const` part, as whether the actual trait bound is satisfied is checked separately, the user facing diagnostic is talking about the entire trait bound, at which point it makes more sense to just highlight the entire bound r? `@compiler-errors` or `@fee1-dead`
2025-04-04Rollup merge of #139366 - RalfJung:ToSocketAddrs, r=jieyouxuMatthias Krüger-2/+2
ToSocketAddrs: fix typo It's "a function", never "an function". I noticed the same typo somewhere in the compiler sources so figured I'd fix it there as well.
2025-04-04Rollup merge of #139353 - nnethercote:LateAnon, r=compiler-errorsMatthias Krüger-8/+8
Fix `Debug` impl for `LateParamRegionKind`. It uses `Br` prefixes which are inappropriate and appear to have been incorrectly copy/pasted from the `Debug` impl for `BoundRegionKind`. r? `@BoxyUwU`
2025-04-04Rollup merge of #139348 - meithecatte:async-destructor-minify, r=petrochenkovMatthias Krüger-17/+6
AsyncDestructor: replace fields with impl_did The future and ctor fields aren't actually used, and the way they are extracted is obviously wrong – swapping the order of the items in the source code will give wrong results. Instead, store just the LocalDefId of the impl, which is enough for the only use of this data.
2025-04-04Rollup merge of #139339 - mejrs:tait, r=oli-obkMatthias Krüger-0/+159
unstable book: document tait Documents the type alias impl trait feature. Rendered: ![image](https://github.com/user-attachments/assets/1d904ff9-e1e1-4ef0-a62d-cbe2d480dce0) ![image](https://github.com/user-attachments/assets/9e877ad1-0f73-4ead-a4ac-0e106512cef8) ![image](https://github.com/user-attachments/assets/86663a23-9824-406d-a5e1-1e0c1662b5f5) because you are deeply involved in this I'll r you but feel free to reroll r? `@oli-obk`
2025-04-04Rollup merge of #139328 - GuillaumeGomez:fix-panic-output-137970, r=fmeaseMatthias Krüger-3/+39
Fix 2024 edition doctest panic output Fixes #137970. The problem was that the output was actually displayed by rustc itself because we're exiting with `Result<(), String>`, and the display is really not great. So instead, we get the output, we print it and then we return an `ExitCode`. r? ````@aDotInTheVoid````
2025-04-04Rollup merge of #139041 - nnethercote:rm-rustc_middle-ty-util-ExplicitSelf, ↵Matthias Krüger-62/+22
r=BoxyUwU Remove `rustc_middle::ty::util::ExplicitSelf`. It's an old (2017 or earlier) type that describes a `self` receiver. It's only used in `rustc_hir_analysis` for two error messages, and much of the complexity isn't used. I suspect it used to be used for more things. This commit removes it, and moves a greatly simplified version of the `determine` method into `rustc_hir_analysis`, renamed as `get_self_string`. The big comment on the method is removed because it no longer seems relevant. r? `@BoxyUwU`
2025-04-04Auto merge of #138785 - lcnr:typing-mode-borrowck, r=compiler-errors,oli-obkbors-987/+1063
add `TypingMode::Borrowck` Shares the first commit with #138499, doesn't really matter which PR to land first :blush: :grin: Introduces `TypingMode::Borrowck` which unlike `TypingMode::Analysis`, uses the hidden type computed by HIR typeck as the initial value of opaques instead of an unconstrained infer var. This is a part of https://github.com/rust-lang/types-team/issues/129. Using this new `TypingMode` is unfortunately a breaking change for now, see tests/ui/impl-trait/non-defining-uses/as-projection-term.rs. Using an inference variable as the initial value results in non-defining uses in the defining scope. We therefore only enable it if with `-Znext-solver=globally` or `-Ztyping-mode-borrowck` To do that the PR contains the following changes: - `TypeckResults::concrete_opaque_type` are already mapped to the definition of the opaque type - writeback now checks that the non-lifetime parameters of the opaque are universal - for this, `fn check_opaque_type_parameter_valid` is moved from `rustc_borrowck` to `rustc_trait_selection` - we add a new `query type_of_opaque_hir_typeck` which, using the same visitors as MIR typeck, attempts to merge the hidden types from HIR typeck from all defining scopes - done by adding a `DefiningScopeKind` flag to toggle between using borrowck and HIR typeck - the visitors stop checking that the MIR type matches the HIR type. This is trivial as the HIR type are now used as the initial hidden types of the opaque. This check is useful as a safeguard when not using `TypingMode::Borrowck`, but adding it to the new structure is annoying and it's not soundness critical, so I intend to not add it back. - add a `TypingMode::Borrowck` which behaves just like `TypingMode::Analysis` except when normalizing opaque types - it uses `type_of_opaque_hir_typeck(opaque)` as the initial value after replacing its regions with new inference vars - it uses structural lookup in the new solver fixes #112201, fixes #132335, fixes #137751 r? `@compiler-errors` `@oli-obk`
2025-04-04make `Arguments::as_statically_known_str` doc(hidden)mejrs-0/+1
2025-04-04add new flag to print the module post-AD, before optsManuel Drehwald-5/+17
2025-04-04add new tests for autodiff batching and update old onesManuel Drehwald-54/+251
2025-04-04add autodiff batching backendManuel Drehwald-44/+196
2025-04-05triagebot: add `compiletest` adhoc_group for `r? compiletest`Jieyou Xu-1/+3
2025-04-04Use target-agnostic LLD flags in bootstrap for use-lldJakub Beránek-2/+2
2025-04-04Auto merge of #137869 - ↵bors-43/+46
Noratrieb:Now_I_am_become_death,_the_destroyer_of_i686-pc-windows-gnu, r=workingjubilee Demote i686-pc-windows-gnu to Tier 2 In accordance with [RFC 3771](https://github.com/rust-lang/rfcs/pull/3771). FCP has been completed. tracking issue #138422 I also added a stub doc page for the target and renamed the windows-gnullvm page for consistency.
2025-04-04Use the span of the whole bound when the diagnostic talks about a boundOli Scherer-33/+33
2025-04-04ToSocketAddrs: fix typoRalf Jung-2/+2
2025-04-04Auto merge of #139213 - bjorn3:cg_clif_test_coretests, r=jieyouxubors-24/+35
Run coretests and alloctests with cg_clif in CI Part of https://github.com/rust-lang/rustc_codegen_cranelift/issues/1290
2025-04-04Auto merge of #139354 - matthiaskrgr:rollup-04lgx23, r=matthiaskrgrbors-407/+531
Rollup of 8 pull requests Successful merges: - #138949 (Rename `is_like_osx` to `is_like_darwin`) - #139295 (Remove creation of duplicate `AnonPipe`) - #139313 (Deduplicate some `rustc_middle` function bodies by calling the `rustc_type_ir` equivalent) - #139317 (compiletest: Encapsulate all of the code that touches libtest) - #139322 (Add helper function for checking LLD usage to `run-make-support`) - #139335 (Pass correct param-env to `error_implies`) - #139342 (Add a mailmap entry for myself) - #139349 (adt_destructor: sanity-check returned item) r? `@ghost` `@rustbot` modify labels: rollup
2025-04-04Rollup merge of #139349 - meithecatte:destructor-constness, r=compiler-errorsMatthias Krüger-0/+33
adt_destructor: sanity-check returned item Fixes #139278
2025-04-04Rollup merge of #139342 - meithecatte:mailmap, r=compiler-errorsMatthias Krüger-0/+2
Add a mailmap entry for myself
2025-04-04Rollup merge of #139335 - compiler-errors:error-implies, r=oli-obkMatthias Krüger-29/+98
Pass correct param-env to `error_implies` Duplicated comment from the test: In the error reporting code, when reporting fulfillment errors for goals A and B, we try to see if elaborating A will result in another goal that can equate with B. That would signal that B is "implied by" A, allowing us to skip reporting it, which is beneficial for cutting down on the number of diagnostics we report. In the new trait solver especially, but even in the old trait solver through things like defining opaque type usages, this `can_equate` call was not properly taking the param-env of the goals, resulting in nested obligations that had empty param-envs. If one of these nested obligations was a `ConstParamHasTy` goal, then we would ICE, since those goals are particularly strict about the param-env they're evaluated in. This is morally a fix for <https://github.com/rust-lang/rust/issues/139314>, but that repro uses details about how defining usages in the `check_opaque_well_formed` code can spring out of type equality, and will likely stop failing soon coincidentally once we start using `PostBorrowck` mode in that check. Instead, we use lazy normalization to end up generating an alias-eq goal whose nested goals woul trigger the ICE instead, since this is a lot more stable. Fixes https://github.com/rust-lang/rust/issues/139314 r? ``@oli-obk`` or reassign
2025-04-04Rollup merge of #139322 - Kobzol:run-make-lld-refactor, r=jieyouxuMatthias Krüger-119/+69
Add helper function for checking LLD usage to `run-make-support` Extracted out of https://github.com/rust-lang/rust/pull/138645, should be a simple refactoring. r? ``@jieyouxu``