Commit graph

284993 commits

Author SHA1 Message Date
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
dianne
83145a6744 match lowering cleanup: non_scalar_compare is only for &str
Since array and slice constants are now lowered to array and slice
patterns, `non_scalar_compare` was only called for string comparisons.
This specializes it to strings, renames it, and removes the unused
array-unsizing logic.

This also updates some outdated doc comments.
2025-03-21 20:14:40 -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
Kyle Huey
8cab8e07bc Don't produce debug information for compiler-introduced-vars when desugaring assignments.
An assignment such as

(a, b) = (b, c);

desugars to the HIR

{ let (lhs, lhs) = (b, c); a = lhs; b = lhs; };

The repeated `lhs` leads to multiple Locals assigned to the same DILocalVariable. Rather than
attempting to fix that, get rid of the debug info for these bindings that don't even exist
in the program to begin with.

Fixes #138198
2025-03-21 17:34:45 -07: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
Ralf Jung
7b9d5b8758 remove remnants of const_box feature 2025-03-21 21:02:06 +01: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
Redddy
b523301368 Add test to ensure no index out of bounds panic (#135474) 2025-03-22 02:08:44 +09:00
Mara Bos
d7685f0d0b Add test for Formatter flags. 2025-03-21 17:05:56 +01:00
Mara Bos
9b7060ad31 Add todo comment on using a niche type for fmt flags. 2025-03-21 17:05:56 +01:00
Vadim Petrochenkov
0ac2801f25 expand: Do not report cfg_attr traces on macros as unused attributes 2025-03-21 18:25:29 +03:00
Ralf Jung
b2d7271858 target spec check: better error when llvm-floatabi is missing 2025-03-21 16:08:48 +01:00
Matthias Krüger
bc46c98dd8
Rollup merge of #138721 - jchecahi:tests-explicit-cpus, r=tgross35
Use explicit cpu in some asm and codegen tests.

Some tests expect to be compiled for a specific CPU or require certain target features to be present (or absent). These tests work fine with default CPUs but fail in downstream builds for RHEL and Fedora, where we use non-default CPUs such as z13 on s390x, pwr9 on ppc64le, or x86-64-v2/x86-64-v3 on x86_64.

This is similar to #124597.
2025-03-21 15:48:58 +01:00
Matthias Krüger
7c2475e9aa
Rollup merge of #138717 - jdonszelmann:pin-macro, r=WaffleLapkin
Add an attribute that makes the spans from a macro edition 2021, and fix pin on edition 2024 with it

Fixes a regression, see issue below. This is a temporary fix, super let is the real solution.

Closes #138596
2025-03-21 15:48:57 +01:00
Matthias Krüger
a27b21e53a
Rollup merge of #138709 - Kobzol:update-gcc, r=GuillaumeGomez
Update GCC submodule

Includes https://github.com/rust-lang/gcc/pull/66 to use our mirrors for downloading GCC dependencies.

r? ```@GuillaumeGomez```
2025-03-21 15:48:57 +01:00
Matthias Krüger
ed3a39da7f
Rollup merge of #138706 - Kobzol:bootstrap-git-refactor-1, r=onur-ozkan
Improve bootstrap git modified path handling

Drive-by improvements extracted out of https://github.com/rust-lang/rust/pull/138591.

r? ``@onur-ozkan``
2025-03-21 15:48:56 +01:00
Matthias Krüger
015df66ee2
Rollup merge of #138669 - durin42:llvm-21-anon-func-unmangled, r=bjorn3
tests: accept some noise from LLVM 21 in symbols-all-mangled

I'm not entirely sure this is correct, but it doesn't feel obviously-wrong so I figured I'd just start by sending a PR rather than filing a bug and letting it linger.

``@rustbot`` label llvm-main
2025-03-21 15:48:55 +01:00
Matthias Krüger
0c594da55f
Rollup merge of #138627 - EnzymeAD:autodiff-cleanups, r=oli-obk
Autodiff cleanups

Splitting out some cleanups to reduce the size of my batching PR and simplify ``@haenoe`` 's [PR](https://github.com/rust-lang/rust/pull/138314).

r? ``@oli-obk``

Tracking:

- https://github.com/rust-lang/rust/issues/124509
2025-03-21 15:48:55 +01:00
Matthias Krüger
a8f0c6bbcb
Rollup merge of #138623 - daltenty:daltenty/fix-compiler-rt, r=Kobzol
[bootstrap] Use llvm_runtimes for compiler-rt

Trying to enable `compiler-rt` via `LLVM_ENABLE_PROJECTS` is no longer a supported option in LLVM, and gives you nasty warnings:
```
Using LLVM_ENABLE_PROJECTS=compiler-rt is deprecated now, and will become a
  fatal error in the LLVM 21 release.  Please use
  -DLLVM_ENABLE_RUNTIMES=compiler-rt or see the instructions at
  https://compiler-rt.llvm.org/ for building the runtimes.
```

try-job: aarch64-gnu-debug
try-job: x86_64-gnu-debug
2025-03-21 15:48:53 +01:00
Matthias Krüger
c354a97bd9
Rollup merge of #138570 - folkertdev:naked-function-target-feature-gate, r=Amanieu
add `naked_functions_target_feature` unstable feature

tracking issue: https://github.com/rust-lang/rust/issues/138568

tagging https://github.com/rust-lang/rust/pull/134213 https://github.com/rust-lang/rust/issues/90957

This PR puts `#[target_feature(/* ... */)]` on `#[naked]` functions behind its own feature gate, so that naked functions can be stabilized. It turns out that supporting `target_feature` on naked functions is tricky on some targets, so we're splitting it out to not block stabilization of naked functions themselves. See the tracking issue for more information and workarounds.

Note that at the time of writing, the `target_features` attribute is ignored when generating code for naked functions.

r? ``@Amanieu``
2025-03-21 15:48:52 +01:00
Matthias Krüger
f7f287077b
Rollup merge of #138364 - BLANKatGITHUB:compiler, r=RalfJung
ports the compiler test cases to new rust_intrinsic format

pr is part of #132735
2025-03-21 15:48:51 +01:00
bors
a4a11aca5e Auto merge of #138704 - Kobzol:ci-llvm-checks, r=onur-ozkan
Simplify CI LLVM checks in bootstrap

Extracted out of https://github.com/rust-lang/rust/pull/138591. Apart from simplifying the checks, it will make it easier to run E2E tests of bootstrap on a mostly empty directory without checking out LLVM on CI :)

The commits should be mostly self-explanatory.

r? `@onur-ozkan`
2025-03-21 14:47:25 +00:00
bjorn3
530ab61c0e Also check for compiler-builtins in linked_symbols
Otherwise the linker complains about EC symbols missing when compiling
for arm64ec.
2025-03-21 14:06:34 +00:00
bjorn3
63cfd47cb1 Don't attempt to export compiler-builtins symbols from rust dylibs
They are marked with hidden visibility to prevent them from getting
exported, so we shouldn't ask the linker to export them anyway. The only
thing that does it cause a warning on macOS.
2025-03-21 13:59:51 +00:00
bjorn3
cd929bfccb Fix lint name in unused linker_messages warning 2025-03-21 13:59:29 +00:00
bjorn3
41f1ed11c2 Move some calls to before calling codegen_crate
`--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-21 13:23:07 +00:00
bjorn3
7d3965e0cd Move make_input call 2025-03-21 13:21:53 +00:00
bjorn3
521d0c4a30 Cache current_dll_path output
Computing the current dll path is somewhat expensive relative to other
work when compiling `fn main() {}` as `dladdr` needs to iterate over the
symbol table of librustc_driver.so until it finds a match.
2025-03-21 12:46:24 +00:00
Karol Zwolak
2c77a0775c test(ui): add tuple-struct-where-clause-suggestion ui test for #91520 2025-03-21 13:12:15 +01:00
Jakub Beránek
f5c59a444f Fix test using download-ci-llvm=true on CI 2025-03-21 12:23:44 +01:00
Jakub Beránek
e288faa4b0 Disable CI mode when checking default bootstrap profiles 2025-03-21 12:18:51 +01:00