Commit Graph

45081 Commits

Author SHA1 Message Date
Vadim Petrochenkov
ba4190cf7e resolve: Avoid some unstable iteration 2 2025-03-24 23:03:11 +03:00
bors
4510e86a41 Auto merge of #138629 - Zoxc:graph-anon-hashmap, r=oli-obk
Only use the new node hashmap for anonymous nodes

This is a rebase of https://github.com/rust-lang/rust/pull/112469.

cc `@cjgillot`
2025-03-24 15:02:09 +00:00
bors
90f5eab952 Auto merge of #115747 - Zoxc:query-hashes, r=oli-obk
Optimize hash map operations in the query system

This optimizes hash map operations in the query system by explicitly passing hashes and using more optimal operations. `find_or_find_insert_slot` in particular saves a hash table lookup over `entry`. It's not yet available in a safe API, but will be in https://github.com/rust-lang/hashbrown/pull/466.

<table><tr><td rowspan="2">Benchmark</td><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th></tr><tr><td align="right">Time</td><td align="right">Time</td><td align="right">%</th></tr><tr><td>🟣 <b>clap</b>:check</td><td align="right">1.6189s</td><td align="right">1.6129s</td><td align="right"> -0.37%</td></tr><tr><td>🟣 <b>hyper</b>:check</td><td align="right">0.2353s</td><td align="right">0.2337s</td><td align="right"> -0.67%</td></tr><tr><td>🟣 <b>regex</b>:check</td><td align="right">0.9344s</td><td align="right">0.9289s</td><td align="right"> -0.59%</td></tr><tr><td>🟣 <b>syn</b>:check</td><td align="right">1.4693s</td><td align="right">1.4652s</td><td align="right"> -0.28%</td></tr><tr><td>🟣 <b>syntex_syntax</b>:check</td><td align="right">5.6606s</td><td align="right">5.6439s</td><td align="right"> -0.30%</td></tr><tr><td>Total</td><td align="right">9.9185s</td><td align="right">9.8846s</td><td align="right"> -0.34%</td></tr><tr><td>Summary</td><td align="right">1.0000s</td><td align="right">0.9956s</td><td align="right"> -0.44%</td></tr></table>

r? `@cjgillot`
2025-03-24 11:40:33 +00:00
Jacob Pratt
0e95f962d9
Rollup merge of #138846 - compiler-errors:stall-prereqs, r=lcnr
Tweaks to writeback and `Obligation -> Goal` conversion

Each of these commits are self-contained, but are prerequisites that I'd like to land before #138845, which still needs some cleaning.

The ""most controversial"" one is probably [Explicitly don't fold coroutine obligations in writeback](e7d27bae27), which I prefer because I think using `fold_predicate` to control against not normalizing predicates seems... easy to mess up 🤔, and we could have *other things* that we don't want to normalize.

Explicitly noting whether we want `resolve` to normalize is a lot clearer (and currently in writeback is limited to resolving stalled coroutine obligations), since we can attach it to a comment that explains *why*.
2025-03-23 20:44:13 -04:00
Jacob Pratt
ab138e6aa8
Rollup merge of #138783 - bjorn3:cache_current_dll_path, r=lqd
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-23 20:44:12 -04:00
Jacob Pratt
b406d9aaaa
Rollup merge of #138728 - tgross35:update-builtins, r=tgross35
Update `compiler-builtins` to 0.1.152

Includes the following changes related to unordered atomics:

* Remove element_unordered_atomic intrinsics [1]
* Remove use of `atomic_load_unordered` and undefined behaviour [2]

There are a handful of other small changes, but nothing else user-visible.

[1]: https://github.com/rust-lang/compiler-builtins/pull/789
[2]: https://github.com/rust-lang/compiler-builtins/pull/790
2025-03-23 20:44:12 -04:00
Jacob Pratt
9a243cf7d3
Rollup merge of #137736 - bjorn3:compiler_builtins_export_fix, r=petrochenkov
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.

Part of https://github.com/rust-lang/rust/issues/136096

cc `@jyn514`
2025-03-23 20:44:08 -04:00
Trevor Gross
95181ae170 Update compiler-builtins to 0.1.152
Includes the following changes related to unordered atomics:

* Remove element_unordered_atomic intrinsics [1]
* Remove use of `atomic_load_unordered` and undefined behaviour [2]

There are a handful of other small changes, but nothing else
user-visible.

[1]: https://github.com/rust-lang/compiler-builtins/pull/789
[2]: https://github.com/rust-lang/compiler-builtins/pull/790
2025-03-24 00:29:21 +00:00
Michael Goulet
045a1c78ae
Rollup merge of #138861 - compiler-errors:flags-tweaks, r=lcnr
Tweak type flags, fix missing flags from coroutine kind ty

Firstly, make sure we visit the coroutine kind ty. Since this kind ty is either infer (before upvar computation), or `()` or `i8`/`i16`/`i32`, this isn't really that big of a deal, since other types in the coroutine will also be infer, so we're not misreporting `ty.has_infer()` or anything, but it's still wrong not to do this.

Furthermore, remove `HAS_TY_COROUTINE`, since nobody used it, and also remove special casing for `STILL_FURTHER_SPECIALIZABLE` since it's likely not important anymore? I have a vague recollection that it was important for polymorphization(?), but no tests seem to rely on this behavior.

r? lcnr or reassign
2025-03-23 14:59:36 -04:00
Michael Goulet
1e023420f9
Rollup merge of #138854 - TaKO8Ki:invalid-extern-fn-body, r=compiler-errors
Fix ICE #138415 for invalid extern function body

Fixes #138415
2025-03-23 14:59:35 -04:00
Michael Goulet
21cdebcf4e
Rollup merge of #138641 - jieyouxu:print-supported-crate-types, r=Urgau
Add unstable `--print=supported-crate-types` option

MCP: https://github.com/rust-lang/compiler-team/issues/836
Tracking issue: https://github.com/rust-lang/rust/issues/138640

### Test coverage

Two tests:

1. `tests/ui/print-request/stability.rs` to check that `--print=supported-crate-types` is `-Zunstable-options`-gated
2. `tests/ui/print-request/supported-crate-types.rs` is added as a basic smoke test. Observe that the compiler stdout corresponds to the below *Example output* section (e.g. `proc-macro` is unsupported on `wasm32-unknown-unknown` currently).

### Example output

<details>
<summary>For `x86_64-unknown-linux-gnu`</summary>

Notice the presence of `{c,}dylib` and `proc-macro`:
```
bin
cdylib
dylib
lib
proc-macro
rlib
staticlib
```
</details>

<details>
<summary>For `wasm32-unknown-unknown`</summary>

Notice the absence of `dylib` and `proc-macro`:
```
bin
cdylib
lib
rlib
staticlib
```
</details>

<details>
<summary>For `x86_64-unknown-linux-musl`</summary>

Notice the absence of `{c,}dylib` but presence of `proc-macro`:
```
bin
lib
proc-macro
rlib
staticlib
```
</details>

### Documentation

I added an entry in the unstable book's print request section to document this `supported-crate-types` print request.

### Unresolved questions

- [ ] (Name bikeshedding) is `supported-crate-types` a good name for the print request? I'm inclined to say it's good enough for an unstable print request, but may be worth revisiting at stabilization time.

### Stability

This print request being added is *unstable* in this PR. A separate stabilization PR following the usual compiler flag stabilization procedure should be filed for stabilization after some baking time.

### Review remarks

Best reviewed commit-by-commit.

r? compiler
2025-03-23 14:59:33 -04:00
Michael Goulet
fad34c603c Explicitly don't fold coroutine obligations in writeback 2025-03-23 18:34:33 +00:00
Michael Goulet
d588bc2a2b Don't super fold const in Resolver 2025-03-23 18:18:47 +00:00
Michael Goulet
575f129faa Obligation::as_goal 2025-03-23 18:18:47 +00:00
Michael Goulet
77a106e61f Remove STILL_FURTHER_SPECIALIZABLE special casing 2025-03-23 18:13:52 +00:00
Michael Goulet
e4f13e3ccd Remove HAS_TY_COROUTINE 2025-03-23 18:03:09 +00:00
Michael Goulet
e934975339 Visit coroutine kind ty in FlagComputation 2025-03-23 18:03:09 +00:00
Jieyou Xu
0e7dbab1fc
Implement supported-crate-types print request
As an unstable print request.
2025-03-23 19:08:54 +08:00
Takayuki Maeda
20f4a0d586 fix ICE #138415 2025-03-23 17:02:42 +09: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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
John Kåre Alsaker
93bfe39ba5 Use hashbrown from crates.io 2025-03-21 07:54:35 +01:00
John Kåre Alsaker
fcd3349d14 Optimize hash map operations in the query system 2025-03-21 07:51:20 +01:00
Matthias Krüger
5ba395a98b
Rollup merge of #138754 - oli-obk:push-vtqtnwluyxop, r=compiler-errors
Handle spans of `~const`, `const`  and `async` trait bounds in macro expansion

r? `@compiler-errors`

`visit_span` is actually only used in one place (the `transcribe::Marker`), and all of this syntax is unstable, so while it would still be nice to write a test for it, I wager there's lots more interesting things in `transcribe::Marker` to write tests for. And the worst is some diagnostics being weird or incremental being not as incremental as it could be
2025-03-21 06:56:49 +01:00
Matthias Krüger
1135a63286
Rollup merge of #138724 - fmease:list-stems-bear-no-name, r=nnethercote
Check attrs: Don't try to retrieve the name of list stems

Fixes #138723.

r? nnethercote or compiler
2025-03-21 06:56:47 +01:00
Matthias Krüger
7c1b128383
Rollup merge of #138713 - RalfJung:memory-hook-pointers, r=oli-obk
interpret memory access hooks: also pass through the Pointer used for the access

In some ongoing work on the Miri side, we need the absolute address that the memory access occurred at. That is non-trivial to obtain since we don't have an `ecx`. So pass through the `Pointer` used for the access, which contains the address, and which is available everywhere we are calling these hooks.

r? `@oli-obk`
2025-03-21 06:56:47 +01:00
bors
eda7820be5 Auto merge of #138747 - matthiaskrgr:rollup-68x44rw, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #138435 (Add support for postfix yield expressions)
 - #138685 (Use `Option<Ident>` for lowered param names.)
 - #138700 (Suggest `-Whelp` when pass `--print lints` to rustc)
 - #138727 (Do not rely on `type_var_origin` in `OrphanCheckErr::NonLocalInputType`)
 - #138729 (Clean up `FnCtxt::resolve_coroutine_interiors`)
 - #138731 (coverage: Add LLVM plumbing for expansion regions)
 - #138732 (Use `def_path_str` for def id arg in `UnsupportedOpInfo`)
 - #138735 (Remove `llvm` and `llvms` triagebot ping aliases for `icebreakers-llvm` ping group)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-03-20 22:35:15 +00:00