Commit Graph

284771 Commits

Author SHA1 Message Date
Manuel Drehwald
b7c63a973f add autodiff batching backend 2025-04-04 14:24:23 -04:00
Manuel Drehwald
e0c8ead880 add autodiff batching middle-end 2025-04-03 17:21:21 -04:00
Manuel Drehwald
087ffd73bf add the autodiff batch mode frontend 2025-04-03 17:19:11 -04:00
bors
aa8f0fd716 Auto merge of #136929 - joboet:move_process_pal, r=Mark-Simulacrum
std: move process implementations to `sys`

As per #117276, this moves the implementations of `Process` and friends out of the `pal` module and into the `sys` module, removing quite a lot of error-prone `#[path]` imports in the process (hah, get it ;-)). I've also made the `zircon` module a dedicated submodule of `pal::unix`, hopefully we can move some other definitions there as well (they are currently quite a lot of duplications in `sys`). Also, the `ensure_no_nuls` function on Windows now lives in `sys::pal::windows` – it's not specific to processes and shared by the argument implementation.
2025-03-23 14:10:35 +00:00
bors
97fc1f62d8 Auto merge of #138602 - Veykril:push-purxoytpktpu, r=SparrowLii
Slim `rustc_parse_format` dependencies down

`rustc_index` is only used for its size assertion macro, so demote it to a dev-dependency gated under testing instead. This allows the crate to built without having to wait for `syn` (pulled in by `rustc_index_macros`)

Alternatively we could inline the macro, though from the looks of it that will run into trouble with `rustc_randomized_layouts`
2025-03-23 10:00:10 +00:00
Lukas Wirth
5950c862bd Slim rustc_parse_format dependencies down
`rustc_index` is only used for its size assertion macro, so demote it to a dev-dependency gated under testing instead
2025-03-23 07:30:18 +01:00
bors
60a3084f64 Auto merge of #136769 - thaliaarchi:io-optional-methods/stdio, r=joboet
Provide optional `Read`/`Write` methods for stdio

Override more of the default methods for `io::Read` and `io::Write` for stdio types, when efficient to do so, and deduplicate unsupported types.

Tracked in https://github.com/rust-lang/rust/issues/136756.

try-job: x86_64-msvc-1
2025-03-23 06:23:51 +00:00
bors
f08d5c01e6 Auto merge of #138833 - joboet:optimize-repeat-n, r=thomcc
core: optimize `RepeatN`

...by adding an optimized implementation of `try_fold` and `fold` as well as replacing some unnecessary `mem::replace` calls with `MaybeUninit` helper methods.
2025-03-23 03:11:13 +00:00
bors
756bff97ea Auto merge of #138841 - matthiaskrgr:rollup-bfkls57, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #138018 (rustdoc: Use own logic to print `#[repr(..)]` attributes in JSON output.)
 - #138294 (Mark some std tests as requiring `panic = "unwind"`)
 - #138468 (rustdoc js: add nonnull helper and typecheck src-script.js)
 - #138675 (Add release notes for 1.85.1)
 - #138765 (Fix Thread::set_name on cygwin)
 - #138786 (Move some driver code around)
 - #138793 (target spec check: better error when llvm-floatabi is missing)
 - #138822 (De-Stabilize `file_lock`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-03-22 23:59:01 +00:00
bors
b48576b4db Auto merge of #138831 - matthiaskrgr:rollup-3t0dqiz, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #138609 (Add stack overflow handler for cygwin)
 - #138639 (Clean UI tests 2 of n)
 - #138773 (catch_unwind intrinsic: document return value)
 - #138782 (test(ui): add tuple-struct-where-clause-suggestion ui test for #91520)
 - #138794 (expand: Do not report `cfg_attr` traces on macros as unused attributes)
 - #138801 (triagebot: add autolabel rules for D-* and L-*)
 - #138804 (Allow inlining for `Atomic*::from_ptr`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-03-22 20:52:30 +00:00
Matthias Krüger
3f59916a30
Rollup merge of #138822 - moxian:unlock, r=joshtriplett
De-Stabilize `file_lock`

This reverts #136794

FCP on the tracking issue (#130994) passsed successfully https://github.com/rust-lang/rust/issues/130994#issuecomment-2646158607 but there are now concerns about the suitability of the proposed API (https://github.com/rust-lang/rust/issues/130994#issuecomment-2734608366)

On zullip it was [suggested](https://rust-lang.zulipchat.com/#narrow/channel/219381-t-libs/topic/File.3A.3Atry_lock.20API.3A.20Result.3Cbool.3E/near/506823067) that it would be better to temporarily(?) destabilize the feature ASAP to buy us some more time reflecting on the API.

This PR implements the revert.

The feature is not currently on beta (https://github.com/rust-lang/rust/blob/beta/library/std/src/fs.rs#L672) so a beta backport is not yet neccessary.

If this revert is accepted, the tracking issue (#130994) should be reopened
2025-03-22 21:34:40 +01:00
Matthias Krüger
7372f2812b
Rollup merge of #138793 - RalfJung:arm-floatabi, r=Noratrieb
target spec check: better error when llvm-floatabi is missing
2025-03-22 21:34:39 +01:00
Matthias Krüger
4457da3dc4
Rollup merge of #138786 - bjorn3:driver_code_move, r=compiler-errors
Move some driver code around

`--emit mir`, `#[rustc_symbol_name]` and `#[rustc_def_path]` now run before codegen and thus work even if codegen fails. This can help with debugging.
2025-03-22 21:34:39 +01:00
Matthias Krüger
9a9859637a
Rollup merge of #138765 - Berrysoft:cygwin-thread-name, r=joboet
Fix Thread::set_name on cygwin

Just like Linux, Cygwin also sets a limitation to thread name.

8e50c7af7c/winsup/cygwin/thread.cc (L3175)
2025-03-22 21:34:38 +01:00
Matthias Krüger
8986c532c4
Rollup merge of #138675 - cuviper:release-1.85.1, r=Urgau
Add release notes for 1.85.1

Closes #138819.
2025-03-22 21:34:37 +01:00
Matthias Krüger
26ecbc68ef
Rollup merge of #138468 - lolbinarycat:rustdoc-js-less-expect-error-part3, r=notriddle
rustdoc js: add nonnull helper and typecheck src-script.js

this removes ``@ts-nocheck`` from `src-script.js` and adds a `nonnull` helper function that assists in adding null checks to places where null values should be impossible.

r? `@notriddle`
2025-03-22 21:34:37 +01:00
Matthias Krüger
53076de369
Rollup merge of #138294 - paulmenage:test-panic-unwind, r=bjorn3
Mark some std tests as requiring `panic = "unwind"`

This allows these test modules to pass on builds/targets without unwinding support, where `panic = "abort"` - the ignored tests are for functionality that's not supported on those targets.
2025-03-22 21:34:36 +01:00
Matthias Krüger
c5a5f8a74a
Rollup merge of #138018 - obi1kenobi:pg/librustdoc_repr_attr, r=aDotInTheVoid
rustdoc: Use own logic to print `#[repr(..)]` attributes in JSON output.

Switch away from `Debug`-like representation of `#[repr(..)]` attributes, and start using rustdoc's own logic for pretty-printing `#[repr(..)]` in rustdoc JSON.

Part of addressing #137645 but not a complete solution for it.

r? `@aDotInTheVoid`
2025-03-22 21:34:35 +01:00
Predrag Gruevski
bafdbcadd5 rustdoc: Use own logic to print #[repr(..)] attributes in JSON output. 2025-03-22 18:47:12 +00:00
Josh Stone
f39478f8a5 Clarify "Windows 1607" 2025-03-22 09:50:07 -07:00
bors
d93f678fa5 Auto merge of #138830 - matthiaskrgr:rollup-gaxgfwl, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #138410 (Couple mir building cleanups)
 - #138490 (Forward `stream_position` in `Arc<File>` as well)
 - #138535 (Cleanup `LangString::parse`)
 - #138536 (stable_mir: Add `MutMirVisitor`)
 - #138673 (Fix build failure on Trusty)
 - #138750 (Make `crate_hash` not iterate over `hir_crate` owners anymore)
 - #138763 (jsondocck: Replace `jsonpath_lib` with `jsonpath-rust`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-03-22 14:03:50 +00:00
joboet
51d51c8666
core: optimize RepeatN
...by adding an optimized implementation of `try_fold` and `fold` as well as replacing some unnecessary `mem::replace` calls with `MaybeUninit` helper methods.
2025-03-22 13:35:46 +01:00
joboet
89f85cbfa7
std: move process implementations to sys
As per #117276, this moves the implementations of `Process` and friends out of the `pal` module and into the `sys` module, removing quite a lot of error-prone `#[path]` imports in the process (hah, get it ;-)). I've also made the `zircon` module a dedicated submodule of `pal::unix`, hopefully we can move some other definitions there as well (they are currently quite a lot of duplications in `sys`). Also, the `ensure_no_nuls` function on Windows now lives in `sys::pal::windows` – it's not specific to processes and shared by the argument implementation.
2025-03-22 12:42:34 +01:00
Matthias Krüger
2644500bff
Rollup merge of #138804 - tgross35:atomic-from-ptr-inline, r=RalfJung
Allow inlining for `Atomic*::from_ptr`

Currently this cannot be inlined, which among other things means it can't be used in `compiler-builtins` [1]. These are trivial functions that should be inlineable, so add `#[inline]`.

[1]: https://github.com/rust-lang/compiler-builtins/pull/790#issuecomment-2744371738
2025-03-22 12:00:51 +01:00
Matthias Krüger
5a9d98d1d3
Rollup merge of #138801 - lolbinarycat:triagebot-autolabel-138565, r=Noratrieb
triagebot: add autolabel rules for D-* and L-*

fixes #138565

r? `@Noratrieb`
2025-03-22 12:00:51 +01:00
Matthias Krüger
66c3566b88
Rollup merge of #138794 - petrochenkov:cfgtracefix, r=jieyouxu
expand: Do not report `cfg_attr` traces on macros as unused attributes

Fixes https://github.com/rust-lang/rust/issues/138779
2025-03-22 12:00:50 +01:00
Matthias Krüger
f463e473d9
Rollup merge of #138782 - karolzwolak:where-test-91520, r=compiler-errors
test(ui): add tuple-struct-where-clause-suggestion ui test for #91520

Fixes #91520

I tried to also make it a .fixed test, but I failed to accomplish that.
That's because of the 'consider annotating `Inner<T>` with `#[derive(Clone)]`' suggestion does not compile (conflicting Clone implementations), and I can't isolate them with `rustfix-only-machine-applicable` as both suggestions are not marked as `MachineApplicable`.
Instead I just test that the where clause suggestion is applied to the correct line.
2025-03-22 12:00:50 +01:00
Matthias Krüger
ca86dd5036
Rollup merge of #138773 - RalfJung:catch_unwind_docs, r=jhpratt
catch_unwind intrinsic: document return value

Seems like we forgot to document this. The comment reflects what Miri does, which seems to also match what codegen does at least [in `codegen_gnu_try`](b754ef727c/compiler/rustc_codegen_llvm/src/intrinsic.rs (L953-L964)).
2025-03-22 12:00:49 +01:00
Matthias Krüger
f01d0960e9
Rollup merge of #138639 - spencer3035:clean-ui-tests-2-of-n, r=jieyouxu
Clean UI tests 2 of n

Modified 4 tests in tests/ui. Cleaned 3 and deleted one.

I have a final commit changing the values in `src/tools/tidy/src/ui_tests.rs`.
I wasn't sure if it was best practice to change this value as you go along or
once at the end. I can rebase to something that incrementally changes the value
in the "cleaned" commits if that is preferred.

Related Issues:
#73494
#133895

r? jieyouxu
2025-03-22 12:00:48 +01:00
Matthias Krüger
92caac41ff
Rollup merge of #138609 - Berrysoft:cygwin-stackoverflow, r=joboet
Add stack overflow handler for cygwin

The cygwin runtime handles stack overflow exception and converts it to `SIGSEGV`, but the passed `si_addr` is obtained from `ExceptionInformation[1]` which is actually an undocumented value when stack overflows. Thus I choose to use Windows API directly to register handler, just like how std does on native Windows. The code is basically copied from the Windows one.

Ref:
* 5ec497dc80/winsup/cygwin/exceptions.cc (L822-L823)
* https://learn.microsoft.com/zh-cn/windows/win32/api/winnt/ns-winnt-exception_record
2025-03-22 12:00:48 +01:00
Matthias Krüger
a4c0173d12
Rollup merge of #138763 - aDotInTheVoid:two-years-later, r=GuillaumeGomez
jsondocck: Replace `jsonpath_lib` with `jsonpath-rust`

The current jsonpath implementation we use isn't spec-compliant, and is buggy. See https://github.com/freestrings/jsonpath/issues/91

To solve it, it's replaced with https://github.com/besok/jsonpath-rust. This is spec-compiant, and doesn't have a really awkward bug we need to always dance around.

Unfortunately, this requires rewriting almost every test, as the behaviour of `[?(```@`,``` which is *extremely* common was changed. (But the new behaviour makes way more sense, and isn't buggy with tripply nested selectors)

Unblocks #110406. Makes #100515 much easier as we don't need to explain the broken JSONPath implementation

Best reviewed commit-by-commit. The first does the replacement. The next two rewrite the test-suite mechanically. The last rewrites the test-suite by hand.

r? ```@GuillaumeGomez```
2025-03-22 11:59:19 +01:00
Matthias Krüger
fb09bd52a8
Rollup merge of #138750 - oli-obk:decouple-hir-queries, r=fee1-dead
Make `crate_hash` not iterate over `hir_crate` owners anymore

cc https://github.com/rust-lang/rust/issues/95004

One more direct usage of hir::Crate removed
2025-03-22 11:59:19 +01:00
Matthias Krüger
14f6216cf4
Rollup merge of #138673 - taiki-e:trusty-fix, r=Noratrieb
Fix build failure on Trusty

This target is currently broken due to update to 2024 editon.

```console
$ cargo new --lib repro
$ cd repro
$ cargo check -Z build-std=std --target aarch64-unknown-trusty
   Compiling std v0.0.0 ($HOME/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/std)
error: extern blocks must be unsafe
 --> $HOME/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/std/src/sys/random/trusty.rs:1:1
  |
1 | / extern "C" {
2 | |     fn trusty_rng_secure_rand(randomBuffer: *mut core::ffi::c_void, randomBufferLen: libc::size_t);
3 | | }
  | |_^

error: could not compile `std` (lib) due to 1 previous error
```

cc ```@randomPoison``` ```@ahomescu``` ([target maintainers](https://doc.rust-lang.org/nightly/rustc/platform-support/trusty.html#target-maintainers))
2025-03-22 11:59:18 +01:00
Matthias Krüger
1cb17dd6f2
Rollup merge of #138536 - makai410:mut-mir-visitor, r=celinval
stable_mir: Add `MutMirVisitor`

Resolves: [rust-lang/project-stable-mir#81](https://github.com/rust-lang/project-stable-mir/issues/81).

I am unsure if we should add a `MutableBody` like Kani did.
Currently, I use `&mut Body` in `MutMirVisitor::visit_body()`.

r? ``````@celinval``````
2025-03-22 11:59:17 +01:00
Matthias Krüger
e8326805c7
Rollup merge of #138535 - yotamofek:pr/rustdoc/lang-string-parse-cleanup, r=notriddle
Cleanup `LangString::parse`

Flatten some `if`s into match patterns
Use `str::strip_prefix` instead of `starts_with`+indexing
Avoid redundant tests for `extra.is_some()`
2025-03-22 11:59:17 +01:00
Matthias Krüger
07c503c3e4
Rollup merge of #138490 - tbu-:pr_arc_file_pos, r=Noratrieb
Forward `stream_position` in `Arc<File>` as well

It was missed in #137165.
2025-03-22 11:59:16 +01:00
Matthias Krüger
92acd148f8
Rollup merge of #138410 - bjorn3:misc_cleanups, r=compiler-errors
Couple mir building cleanups
2025-03-22 11:59:15 +01:00
bors
0ce1369bde Auto merge of #136974 - m-ou-se:fmt-options-64-bit, r=scottmcm
Reduce FormattingOptions to 64 bits

This is part of https://github.com/rust-lang/rust/issues/99012

This reduces FormattingOptions from 6-7 machine words (384 bits on 64-bit platforms, 224 bits on 32-bit platforms) to just 64 bits (a single register on 64-bit platforms).

Before:

```rust
pub struct FormattingOptions {
    flags: u32, // only 6 bits used
    fill: char,
    align: Option<Alignment>,
    width: Option<usize>,
    precision: Option<usize>,
}
```

After:

```rust
pub struct FormattingOptions {
    /// Bits:
    ///  - 0-20: fill character (21 bits, a full `char`)
    ///  - 21: `+` flag
    ///  - 22: `-` flag
    ///  - 23: `#` flag
    ///  - 24: `0` flag
    ///  - 25: `x?` flag
    ///  - 26: `X?` flag
    ///  - 27: Width flag (if set, the width field below is used)
    ///  - 28: Precision flag (if set, the precision field below is used)
    ///  - 29-30: Alignment (0: Left, 1: Right, 2: Center, 3: Unknown)
    ///  - 31: Always set to 1
    flags: u32,
    /// Width if width flag above is set. Otherwise, always 0.
    width: u16,
    /// Precision if precision flag above is set. Otherwise, always 0.
    precision: u16,
}
```
2025-03-22 10:56:14 +00:00
Thalia Archibald
f6e90d804a Use unit structs for stateless stdio
This seems to be the pattern for newer pal stdio types.
2025-03-22 01:21:23 -07:00
Thalia Archibald
ec4beda5d2 Implement exact reads for StdinRaw 2025-03-22 01:21:23 -07:00
Thalia Archibald
bd49a4beb7 Implement optional methods for unsupported stdio
Match what `std::io::Empty` does, since it is very similar. However,
still evaluate the `fmt::Arguments` in `write_fmt` to be consistent with
other platforms.
2025-03-22 01:21:23 -07:00
bors
db687889a5 Auto merge of #138719 - lcnr:concrete_opaque_types-closures, r=oli-obk
merge opaque types defined in nested bodies

A small step towards https://github.com/rust-lang/types-team/issues/129

r? `@oli-obk`
2025-03-22 06:55:52 +00:00
Spencer
5e6b4592d2 cleaned and organized 3 tests in ./tests/ui/issues 2025-03-21 22:55:00 -06:00
moxian
110f1fe17f Revert "Stabilize file_lock"
This reverts commit 82af73dd4c.
2025-03-21 20:24:31 -07:00
bors
2a1c8beabf Auto merge of #138808 - weihanglo:update-cargo, r=weihanglo
Update cargo

14 commits in 6cf8267012570f63d6b86e85a2ae5627de52df9e..307cbfda3119f06600e43cd38283f4a746fe1f8b
2025-03-14 15:25:36 +0000 to 2025-03-20 20:00:39 +0000
- feat: Add custom completer for cargo &lt;TAB&gt; to complete aliases defined in config.toml (rust-lang/cargo#15319)
- fix(build-dir): Renamed workspace-manifest-path-hash to workspace-path-hash (rust-lang/cargo#15334)
- feat: vcs, color, and message format native completion (rust-lang/cargo#15322)
- Fix `[env]` `relative` description in reference (rust-lang/cargo#15332)
- chore: fix some typos (rust-lang/cargo#15329)
- Cleanup for rustc-link-arg-cdylib (rust-lang/cargo#15326)
- fix(toml): Report '&lt;target&gt;.edition' deprecation to users (rust-lang/cargo#15321)
- test(build-std): address overly-matched snapshot (rust-lang/cargo#15325)
- Added `build.build_dir` templating support (rust-lang/cargo#15236)
- docs: make it clearer that `rust_version` is enforced during compile (rust-lang/cargo#15303)
- feat: Add custom completer for cargo +&lt;TAB&gt; to complete toolchain name (rust-lang/cargo#15301)
- chore: fix some typos (rust-lang/cargo#15316)
- fix: deduplicate crate types in cargo rustc command (rust-lang/cargo#15314)
- docs: mention wrong URLs as a cause of git authentication errors (rust-lang/cargo#15304)

r? ghost
2025-03-22 02:12:35 +00:00
Weihang Lo
14062b299c
Update cargo 2025-03-21 19:25:30 -04:00
binarycat
f0c0862a2b triagebot: add autolabel rules for D-* and L-*
fixes #138565
2025-03-21 17:02:20 -05:00
bors
48b36c9d59 Auto merge of #128320 - saethlin:link-me-maybe, r=compiler-errors
Avoid no-op unlink+link dances in incr comp

Incremental compilation scales quite poorly with the number of CGUs. This PR improves one reason for that.

The incr comp process hard-links all the files from an old session into a new one, then it runs the backend, which may just hard-link the new session files into the output directory. Then codegen hard-links all the output files back to the new session directory.

This PR (perhaps unimaginatively) fixes the silliness that ensues in the last step. The old `link_or_copy` implementation would be passed pairs of paths which are already the same inode, then it would blindly delete the destination and re-create the hard-link that it just deleted. This PR lets us skip both those operations. We don't skip the other two hard-links.

`cargo +stage1 b && touch crates/core/main.rs && strace -cfw -elink,linkat,unlink,unlinkat cargo +stage1 b` before and then after on `ripgrep-13.0.0`:
```
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 52.56    0.024950          25       978       485 unlink
 34.38    0.016318          22       727           linkat
 13.06    0.006200          24       249           unlinkat
------ ----------- ----------- --------- --------- ----------------
100.00    0.047467          24      1954       485 total
```
```
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 42.83    0.014521          57       252           unlink
 38.41    0.013021          26       486           linkat
 18.77    0.006362          25       249           unlinkat
------ ----------- ----------- --------- --------- ----------------
100.00    0.033904          34       987           total
```

This reduces the number of hard-links that are causing perf troubles, noted in https://github.com/rust-lang/rust/issues/64291 and https://github.com/rust-lang/rust/issues/137560
2025-03-21 21:03:49 +00:00
Trevor Gross
eb2a2f86bb Allow inlining for Atomic*::from_ptr
Currently this cannot be inlined, which among other things means it
can't be used in `compiler-builtins` [1]. These are trivial functions
that should be inlineable, so add `#[inline]`.

[1]: https://github.com/rust-lang/compiler-builtins/pull/790#issuecomment-2744371738
2025-03-21 20:51:06 +00:00
bors
be73c1f461 Auto merge of #138791 - matthiaskrgr:rollup-ev46cqr, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #138364 (ports the compiler test cases to new rust_intrinsic format)
 - #138570 (add `naked_functions_target_feature` unstable feature)
 - #138623 ([bootstrap] Use llvm_runtimes for compiler-rt)
 - #138627 (Autodiff cleanups)
 - #138669 (tests: accept some noise from LLVM 21 in symbols-all-mangled)
 - #138706 (Improve bootstrap git modified path handling)
 - #138709 (Update GCC submodule)
 - #138717 (Add an attribute that makes the spans from a macro edition 2021, and fix pin on edition 2024 with it)
 - #138721 (Use explicit cpu in some asm and codegen tests.)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-03-21 17:55:41 +00:00