Commit graph

45112 commits

Author SHA1 Message Date
Urgau
69cb0a9e15 Expose registered_tools directly without TyCtxt-query 2025-03-31 18:03:12 +02:00
Urgau
1238a20d38 Expose LintLevelsBuilder with crate root builder 2025-03-31 17:58:13 +02:00
bors
48994b1674 Auto merge of #138923 - TaKO8Ki:rollup-f3hkmqj, r=TaKO8Ki
Rollup of 9 pull requests

Successful merges:

 - #138385 (Keyword tweaks)
 - #138580 (resolve: Avoid some unstable iteration 2)
 - #138652 (Reintroduce remote-test support in run-make tests)
 - #138701 (Make default_codegen_backend serializable)
 - #138755 ([rustdoc] Remove duplicated loop when computing doc cfgs)
 - #138829 (Slightly reword triagebot ping message for `relnotes-interest-group`)
 - #138837 (resolve: Avoid remaining unstable iteration)
 - #138838 (Fix/tweak some tests in new solver)
 - #138895 (Add a helper for building an owner id in ast lowering)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-03-25 13:29:50 +00:00
bors
7d49ae9731 Auto merge of #136410 - saethlin:clean-up-cgu-internal-copy, r=compiler-errors
Remove InstanceKind::generates_cgu_internal_copy

This PR should not contain any behavior changes. Before this PR, the logic for selecting instantiation mode is spread across all of
* `instantiation_mode`
* `cross_crate_inlinable`
* `generates_cgu_internal_copy`
* `requires_inline`

The last two of those functions are not well-designed. The function that actually decides if we generate a CGU-internal copy is `instantiation_mode`, _not_ `generates_cgu_internal_copy`. The function `requires_inline` documents that it is about the LLVM `inline` attribute and that it is a hint. The LLVM attribute is called `inlinehint`, this function is also used by other codegen backends, and since it is part of instantiation mode selection it is *not* a hint.

The goal of this PR is to start cleaning up the logic into a sequence of checks that have a more logical flow and are easier to customize in the future (to do things like improve incrementality or improve optimizations without causing obscure linker errors because you forgot to update another part of the compiler).
2025-03-25 06:36:41 +00:00
Takayuki Maeda
3757104071
Rollup merge of #138895 - oli-obk:dedup-owner-id-creation, r=compiler-errors
Add a helper for building an owner id in ast lowering

Just some deduplication of owner-id creations. Will also help me later split up ast lowering into per-owner queries, as it won't be possible anymore to go from a NodeId to a DefId of an owner without doing extra work to check whether we have an owner id. So I'd just do that in the new `owner_id` function and keep the `local_def_id` function free of that logic
2025-03-25 15:36:36 +09:00
Takayuki Maeda
b2629be2de
Rollup merge of #138838 - compiler-errors:new-solver-crashes-tweaks, r=lcnr
Fix/tweak some tests in new solver

Bunch of miscellaneous new solver tweaks that I found from the failing tests. Can split these out, but they all seemed small enough to not warrant separate PRs.

r? lcnr
2025-03-25 15:36:35 +09:00
Takayuki Maeda
117b3fdbb8
Rollup merge of #138837 - petrochenkov:resinstab2, r=jieyouxu
resolve: Avoid remaining unstable iteration

Continuation of #138580.
This should be the performance sensitive part.
2025-03-25 15:36:35 +09:00
Takayuki Maeda
e9a528c9b5
Rollup merge of #138701 - tvladyslav:serializable_default_codegen_backend, r=workingjubilee
Make default_codegen_backend serializable

This PR makes default_codegen_backend serializable.
2025-03-25 15:36:33 +09:00
Takayuki Maeda
922cc7555f
Rollup merge of #138580 - petrochenkov:resinstab, r=Nadrieril
resolve: Avoid some unstable iteration 2

Continuation of https://github.com/rust-lang/rust/pull/138502.
2025-03-25 15:36:32 +09:00
Takayuki Maeda
8020558507
Rollup merge of #138385 - nnethercote:keyword-tweaks, r=Noratrieb
Keyword tweaks

r? ```@Noratrieb```
2025-03-25 15:36:31 +09:00
bors
e61403aa4c Auto merge of #138634 - saethlin:repeated-uninit, r=scottmcm,oli-obk
Lower to a memset(undef) when Rvalue::Repeat repeats uninit

Fixes https://github.com/rust-lang/rust/issues/138625.

It is technically correct to just do nothing. But if we actually do nothing, we may miss that this is de-initializing something, so instead we just lower to a single memset that writes undef. This is still superior to the memcpy loop, in both quality of code we hand to the backend and LLVM's final output.
2025-03-25 02:09:15 +00:00
Ben Kimock
817e2c598d Remove InstanceKind::generates_cgu_internal_copy 2025-03-24 20:29:24 -04:00
bors
1df5affaca Auto merge of #133984 - DaniPopes:scmp-ucmp, r=scottmcm
Lower BinOp::Cmp to llvm.{s,u}cmp.* intrinsics

Lowers `mir::BinOp::Cmp` (`three_way_compare` intrinsic) to the corresponding LLVM `llvm.{s,u}cmp.i8.*` intrinsics.

These are the intrinsics mentioned in https://github.com/rust-lang/rust/pull/118310, which are now available in LLVM 19.

I couldn't find any follow-up PRs/discussions about this, please let me know if I missed something.

r? `@scottmcm`
2025-03-24 22:53:12 +00:00
Vadim Petrochenkov
ba4190cf7e resolve: Avoid some unstable iteration 2 2025-03-24 23:03:11 +03:00
Matthias Krüger
d1ac5e145b
Rollup merge of #138882 - oli-obk:ast-lowering-mod-rib, r=fee1-dead
`with_scope` is only ever used for ast modules

Thus I renamed it to match other similar functions (`with_mod_rib`) and made it panic if used on non-modules
2025-03-24 20:40:10 +01:00
Matthias Krüger
a678d2068d
Rollup merge of #138868 - mejrs:d_not_recommend_typo, r=davidtwco
Add do_not_recommend typo help
2025-03-24 20:40:09 +01:00
Matthias Krüger
dfd83be4da
Rollup merge of #138821 - dianne:cleanup-non-scalar-compare, r=oli-obk
match lowering cleanup: remove unused unsizing logic from `non_scalar_compare`

Since array and slice constants are now translated to array and slice patterns, `non_scalar_compare` is only used for string comparisons. This specializes it to strings, renames it, and removes the unused array-unsizing logic.

This also updates the doc comments for  `thir::PatKind::Constant` and `TestKind::Eq`, which referred to them being used for slice references.

r? ````@oli-obk````
2025-03-24 20:40:08 +01:00
Michael Goulet
c80d9b8d67 Don't ICE when encountering placeholders in layout computation 2025-03-24 16:57:07 +00:00
Michael Goulet
251455bcc5 Allow WellFormed goals to be returned from relating in new solver 2025-03-24 16:57:06 +00:00
Oli Scherer
67e0b899f0 Add a helper for building an owner id in ast lowering 2025-03-24 15:41:33 +00: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
Oli Scherer
2d3115f61f with_scope is only ever used for ast modules 2025-03-24 09:55:54 +00:00
Nicholas Nethercote
a29e875b63 Move is_used_keyword_conditional.
So the order of the `Symbol::is_*` predicates match the order of the
keywords list.
2025-03-24 18:44:40 +11:00
Nicholas Nethercote
10236fbe7b Alphabetize the keywords list. 2025-03-24 18:44:38 +11:00
Nicholas Nethercote
3aaa12f622 Fix some formatting. 2025-03-24 18:43:37 +11:00
Nicholas Nethercote
a28d5092e9 Improve keyword comments a little. 2025-03-24 18:43:37 +11:00
Nicholas Nethercote
9dd5340d3c Remove is_any_keyword methods.
They're dodgy, covering all the keywords, including weak ones, and
edition-specific ones without considering the edition. They have a
single use in rustfmt. This commit changes that use to
`is_reserved_ident`, which is a much more widely used alternative and is
good enough, judging by the lack of effect on the test suite.
2025-03-24 18:43:37 +11: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
mejrs
f390dd7911 Add do_not_recommend typo help 2025-03-24 01:02:07 +01: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