Commit Graph

47247 Commits

Author SHA1 Message Date
Matthias Krüger
9f6e81c202
Rollup merge of #141307 - b-naber:closure-body, r=celinval
Add method to retrieve body of closure in stable-mir

fixes https://github.com/rust-lang/project-stable-mir/issues/85

r? `@celinval`
2025-06-12 03:14:49 +02:00
Matthias Krüger
f417620160
Rollup merge of #142369 - jdonszelmann:attr-docs, r=fmease
Improve some attribute docs and rename groups

r? `@nnethercote`

Some naming here got changed at some point, and this feels more consistent. The docs changes were a direct response to `@mejrs` trying to implement a new parsers and running into this.
2025-06-11 22:58:29 +02:00
Matthias Krüger
e78b619cad
Rollup merge of #142362 - Veykril:push-rzmrsswqourz, r=oli-obk
Add expectation for `{` when parsing lone coroutine qualifiers

Fixes https://github.com/rust-lang/rust/issues/80931
2025-06-11 22:58:28 +02:00
Matthias Krüger
e2846d6b75
Rollup merge of #142356 - Stypox:fix-enter_trace_span, r=RalfJung
Fix enter_trace_span!() using wrong $crate paths

This is a followup to rust-lang/rust#140972, where I made a silly mistake and forgot to update `$crate::interpret::tracing_utils::...` to `$crate::interpret::util::...` inside the macro after moving the referenced code from `tracing_utils.rs` to `util.rs`. Sorry about this.

r? `@RalfJung`
2025-06-11 22:58:28 +02:00
Matthias Krüger
b29c9a3588
Rollup merge of #142305 - GuillaumeGomez:remove-visit_id-EarlyContextAndPass, r=oli-obk
Remove unneeded `check_id` calls as they are already called in `visit_id` in `EarlyContextAndPass` type

Follow-up from [this message](https://github.com/rust-lang/rust/pull/142240/files#r2137474724).

Since `check_id` is already called in `visit_id` which is supposed to be called for each item with an ID, we don't need to manually call `check_id`.

r? `@oli-obk`
2025-06-11 22:58:26 +02:00
bors
e703dff8fe Auto merge of #142358 - matthiaskrgr:rollup-fxe6m7k, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#141967 (Configure bootstrap backport nominations through triagebot)
 - rust-lang/rust#142042 (Make E0621 missing lifetime suggestion verbose)
 - rust-lang/rust#142272 (tests: Change ABIs in tests to more future-resilient ones)
 - rust-lang/rust#142282 (Only run `citool` tests on the `auto` branch)
 - rust-lang/rust#142297 (Implement `//@ needs-target-std` compiletest directive)
 - rust-lang/rust#142298 (Make loongarch-none target maintainers more easily pingable)
 - rust-lang/rust#142306 (Dont unwrap and re-wrap typing envs)
 - rust-lang/rust#142324 (Remove unneeded `FunctionCx` from some codegen methods)
 - rust-lang/rust#142328 (feat: Add `bit_width` for unsigned integer types)

Failed merges:

 - rust-lang/rust#141639 (Expose discriminant values in stable_mir)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-11 17:51:57 +00:00
Jana Dönszelmann
ce0438684d
consistently rename (old) attribute groups 2025-06-11 18:46:57 +02:00
Jana Dönszelmann
34241e5397
document attribute parsers better 2025-06-11 18:46:57 +02:00
Lukas Wirth
edc405d383 Add expectation for { when parsing lone coroutine qualifiers 2025-06-11 17:11:58 +02:00
Matthias Krüger
b1c668ca03
Rollup merge of #142324 - scottmcm:less-functioncx, r=workingjubilee
Remove unneeded `FunctionCx` from some codegen methods

No changes; just removing the `self` that wasn't needed.

r? workingjubilee
cc https://github.com/rust-lang/rust/pull/138759#issuecomment-2920860686
2025-06-11 13:48:13 +02:00
Matthias Krüger
9ef19ddfd8
Rollup merge of #142306 - compiler-errors:nit-reveal-param-env-query, r=lcnr
Dont unwrap and re-wrap typing envs

Just a tiny tweak to make the query less awkward.

r? lcnr
2025-06-11 13:48:12 +02:00
Matthias Krüger
58d80b6d05
Rollup merge of #142042 - estebank:explicit-lifetime-verbose-suggestion, r=compiler-errors
Make E0621 missing lifetime suggestion verbose

```
error[E0621]: explicit lifetime required in the type of `x`
  --> $DIR/42701_one_named_and_one_anonymous.rs:10:9
   |
LL |         &*x
   |         ^^^ lifetime `'a` required
   |
help: add explicit lifetime `'a` to the type of `x`
   |
LL | fn foo2<'a>(a: &'a Foo, x: &'a i32) -> &'a i32 {
   |                             ++
```

Part of rust-lang/rust#141973.
2025-06-11 13:48:09 +02:00
bors
bdb04d6c4f Auto merge of #141763 - lcnr:fixme-gamer, r=BoxyUwU
`FIXME(-Znext-solver)` triage

r? `@BoxyUwU`
2025-06-11 11:47:05 +00:00
Stypox
cd04717899
Fix enter_trace_span!() using wrong $crate paths 2025-06-11 12:22:20 +02:00
bors
0a39445252 Auto merge of #141942 - ShoyuVanilla:smir-repr, r=oli-obk
Implement representation options to smir

Resolves rust-lang/project-stable-mir#89
2025-06-11 07:45:07 +00:00
bors
2b0274c71d Auto merge of #142090 - compiler-errors:perf-stable-root-var, r=lcnr
Make root vars more stable

Never resolve a ty/ct vid to a higher vid as its root. This should make the optimization in rust-lang/rust#141500 more "stable" when there are a lot of vars flying around.

r? `@ghost`
2025-06-11 03:34:30 +00:00
bors
1c047506f9 Auto merge of #141883 - oli-obk:remove-check-mod-loops, r=nnethercote
Remove check_mod_loops query and run the checks per-body instead

This analysis is older than my first rustc contribution I believe. It was never querified. Ideally we'd merge it into the analysis happening within typeck anyway (typeck just uses span_delayed_bug instead of erroring), but I didn't want to do that within this PR that also moves things around and subtly changes diagnostic ordering.
2025-06-10 23:54:45 +00:00
Scott McMurray
ed06f361ac Remove unneeded FunctionCx from some codegen methods
No changes; just removing the `self` that wasn't needed.
2025-06-10 16:50:17 -07:00
Guillaume Gomez
6f958ac88f Remove unneeded check_id calls as they are already called in visit_id in EarlyContextAndPass type 2025-06-10 20:09:37 +02:00
bors
8ce2287586 Auto merge of #142299 - fmease:rollup-u86s80a, r=fmease
Rollup of 16 pull requests

Successful merges:

 - rust-lang/rust#134442 (Specify the behavior of `file!`)
 - rust-lang/rust#140372 (Exhaustively handle parsed attributes in CheckAttr)
 - rust-lang/rust#140766 (Stabilize keylocker)
 - rust-lang/rust#141642 (Note the version and PR of removed features when using it)
 - rust-lang/rust#141818 (Don't create .msi installer for gnullvm hosts)
 - rust-lang/rust#141909 (Add central execution context to bootstrap)
 - rust-lang/rust#141992 (use `#[naked]` for `__rust_probestack`)
 - rust-lang/rust#142101 (core::ptr: deduplicate more method docs)
 - rust-lang/rust#142102 (docs: Small clarification on the usage of read_to_string and read_to_end trait methods)
 - rust-lang/rust#142124 (Allow transmute casts in pre-runtime-MIR)
 - rust-lang/rust#142240 (deduplicate the rest of AST walker functions)
 - rust-lang/rust#142258 (platform-support.md: Mention specific Linux kernel version or later)
 - rust-lang/rust#142262 (Mark `core::slice::memchr` as `#[doc(hidden)]`)
 - rust-lang/rust#142271 (compiler: fn ptrs should hit different lints based on ABI)
 - rust-lang/rust#142275 (rustdoc: Refractor `clean_ty_generics`)
 - rust-lang/rust#142288 (const_eval: fix some outdated comments)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-10 17:51:43 +00:00
Michael Goulet
6227acc749 Dont unwrap and re-wrap typing envs 2025-06-10 17:01:55 +00:00
León Orell Valerian Liehr
9f5c10ed43
Rollup merge of #142288 - RalfJung:const-eval-comments, r=oli-obk
const_eval: fix some outdated comments

r? ``@oli-obk``
2025-06-10 16:54:54 +02:00
León Orell Valerian Liehr
a2badebce5
Rollup merge of #142271 - workingjubilee:fn-ptrs-have-two-different-lints, r=RalfJung
compiler: fn ptrs should hit different lints based on ABI

I was looking closer at the code for linting on ABIs and realized a mistake was probably made during rebase or review. I think that for function pointers in the HIR, the lint that fires should probably depend on the ABI we encountered, e.g. if it's on the newly-deprecated set of ABIs or not. This will be slightly confusing for a little bit, but I think we can do more to reduce that confusion by switching `unsupported_fn_ptr_calling_conventions` to a hard error.

r? ``@RalfJung``
2025-06-10 16:54:52 +02:00
León Orell Valerian Liehr
407b81caf4
Rollup merge of #142240 - fee1-dead-contrib:push-zkkzoxlymslv, r=oli-obk
deduplicate the rest of AST walker functions

After this, we can tidy things up and deduplicate the visitor traits themselves too.

Fixes rust-lang/rust#139825, apparently

r? ``@oli-obk``
2025-06-10 16:54:51 +02:00
León Orell Valerian Liehr
e8be230f1f
Rollup merge of #142124 - oli-obk:transmute-cast, r=scottmcm
Allow transmute casts in pre-runtime-MIR

r? ``@scottmcm``

cc ``@BoxyUwU``

turns out in https://github.com/rust-lang/rust/pull/138393 I erroneously used transmute casts in fd3da4bebd/compiler/rustc_mir_build/src/builder/matches/test.rs (L209)

I don't think they have any issues using them before runtime, we just checked for them because we didn't have code exercising those code paths
2025-06-10 16:54:50 +02:00
León Orell Valerian Liehr
a55b610d7d
Rollup merge of #141992 - folkertdev:probestack-naked-function, r=tgross35
use `#[naked]` for `__rust_probestack`

Let's see if this works now.

Previously this change was in https://github.com/rust-lang/compiler-builtins/pull/897, but we decided to wait until `compiler-builtins` was a subtree (and also `cfg(bootstrap)` is gone now).

r? ``@tgross35``  cc ``@bjorn3``

try-job: `dist-various*`
try-job: `test-various*`
2025-06-10 16:54:48 +02:00
León Orell Valerian Liehr
2aea4b2bf1
Rollup merge of #141642 - xizheyin:issue-141619, r=BoxyUwU
Note the version and PR of removed features when using it

Fixes rust-lang/rust#141619

I added the diagnostic information. Since all the current version information is present, it prints the version information anyway, as shown in tests/ui. And PR will not print if it is None, we can gradually add the PR links.

Split into two commits for easier review.

r? compiler

cc ``@jyn514`` Since you're on vocation in the review list, I can't r? you.
2025-06-10 16:54:46 +02:00
León Orell Valerian Liehr
d11756f811
Rollup merge of #140766 - sayantn:stabilize-keylocker, r=traviscross,tgross35
Stabilize keylocker

This PR stabilizes the feature flag `keylocker_x86` (tracking issue rust-lang/rust#134813).

# Public API
The 2 `x86` target features `kl` and `widekl`, and the associated intrinsics in stdarch.

These target features are very specialized, and are only used to signal the presence of the corresponding CPU instruction. They don't have any nontrivial interaction with the ABI (contrary to something like AVX), and serve the only purpose of enabling 11 stdarch intrinsics, all of which have been implemented and propagated to rustc via a stdarch submodule update.

Also, these were added way back in LLVM12, and as the minimum LLVM required for rustc is LLVM19, we are safe in that front too!

# Associated PRs
 - rust-lang/rust#134814
 - rust-lang/stdarch#1706
 - rust-lang/rust#136831 (stdarch submodule update)
 - rust-lang/stdarch#1795 (stabilizing the runtime detection and intrinsics)
 - rust-lang/rust#141964 (stdarch submodule update for the stabilization of the runtime detection and intrinsics)

As all of the required tasks have been done (adding the target features to rustc, implementing their runtime detection in std_detect and implementing the associated intrinsics in core_arch), these target features can be stabilized now.

cc ````@rust-lang/lang````
cc ````@rust-lang/libs-api```` for the intrinsics and runtime detection

I don't think anyone else worked on this feature, so no one else to ping, maybe cc ````@Amanieu.```` I will send the reference pr soon.
2025-06-10 16:54:46 +02:00
León Orell Valerian Liehr
0f16ccbb64
Rollup merge of #140372 - mejrs:attrs, r=jdonszelmann
Exhaustively handle parsed attributes in CheckAttr

This pr
 - Deletes the unused `DiagnosticAttribute ` struct and variant
 - Comments the `AttributeKind ` enum
 - The match in `CheckAttrVisitor` is now exhaustive for `AttributeKind::Parsed`.
 - Moved some checks around after that change

I did *not* thoroughly check that there's no duplicated logic between this pass and the attribute parsing but I think it's OK.

  r? ````@jdonszelmann````
2025-06-10 16:54:45 +02:00
bors
c6a955468b Auto merge of #141485 - dianqk:early_otherwise_branch_loop, r=oli-obk
mir-opt: Do not create storage marks in EarlyOtherwiseBranch

Fixes #141212.

The first commit add `StorageDead` by creating new indirect BB that makes CFG more complicated, but I think it's better to just not create storage marks.

r? mir-opt
2025-06-10 14:50:54 +00:00
Shoyu Vanilla
dabed3372c Implement representation options to smir 2025-06-10 22:58:27 +09:00
bors
100199c9aa Auto merge of #141451 - lcnr:canonicalize-env-cache, r=compiler-errors
cache `param_env` canonicalization

BLocked on rust-lang/rust#141581
2025-06-10 10:42:35 +00:00
Ralf Jung
6d1db1144c const_eval: fix some outdated comments 2025-06-10 11:45:38 +02:00
Oli Scherer
7f4093e78b Loop check anon consts on their own 2025-06-10 08:41:23 +00:00
Oli Scherer
1b9d38dd08 Remove check_mod_loops query and run the checks per-body instead 2025-06-10 08:41:23 +00:00
Folkert de Vries
b6eb4f9c3a
use #[naked] for __rust_probestack 2025-06-10 10:08:57 +02:00
Jubilee
8808a9c17f
hir_analysis: Elaborate on lint strategy for unsupported ABIs
Co-authored-by: Ralf Jung <post@ralfj.de>
2025-06-09 23:48:33 -07:00
Jubilee Young
580a9555d5 compiler: Fix reusing same lint on fn ptrs with newly-deprecated ABIs 2025-06-09 15:38:38 -07:00
Esteban Küber
3fce086d79 Make E0621 missing lifetime suggestion verbose
```
error[E0621]: explicit lifetime required in the type of `x`
  --> $DIR/42701_one_named_and_one_anonymous.rs:10:9
   |
LL |         &*x
   |         ^^^ lifetime `'a` required
   |
help: add explicit lifetime `'a` to the type of `x`
   |
LL | fn foo2<'a>(a: &'a Foo, x: &'a i32) -> &'a i32 {
   |                             ++
```
2025-06-09 19:55:00 +00:00
Trevor Gross
facc5da22c
Rollup merge of #142208 - Urgau:dead_code-const_, r=petrochenkov
Always consider `const _` items as live for dead code analysis

This PR alters dead code analysis to always consider `const _: () = { ... };` to be live.

This doesn't address the `_name` pattern from https://github.com/rust-lang/rust/issues/142075.

Fixes https://github.com/rust-lang/rust/issues/142104
2025-06-09 12:17:54 -05:00
Trevor Gross
ab87ed150b
Rollup merge of #141993 - tgross35:use-in-tree-builtins, r=bjorn3
Use the in-tree `compiler-builtins` for the sysroot

Many of `std`'s dependency have a dependency on the crates.io `compiler-builtins` when used with the feature `rustc-std-workspace-core`. Use a Cargo patch to select the in-tree version instead.

`compiler-builtins` is also added as a dependency of `rustc-std-workspace-core` so these crates can remove their crates.io dependency in the future.

Zulip discussion: [#t-compiler > Using in-tree compiler-builtins](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Using.20in-tree.20compiler-builtins/with/522445336)

Once this merges, the following PRs will need to make it to a release for the relevant crates:

- https://github.com/rust-lang/getopts/pull/119 (can merge at any time)
- https://github.com/rust-lang/hashbrown/pull/625 (can merge at any time)
- https://github.com/rust-lang/stdarch/pull/1825
- https://github.com/rust-lang/rustc-demangle/pull/80
- https://github.com/rust-lang/cfg-if/pull/84
- https://github.com/unicode-rs/unicode-width/pull/77

The above should cover all tier 1 targets with no `std` features enabled. The remaining cover the rest:

- https://github.com/alexcrichton/dlmalloc-rs/pull/50 (wasm, xous, sgx)
- https://github.com/gimli-rs/gimli/pull/769
- https://github.com/r-efi/r-efi/pull/89 (efi)
- https://github.com/r-efi/r-efi-alloc/pull/9 (efi)
- https://github.com/fortanix/rust-sgx/pull/770 (sgx)
- https://github.com/hermit-os/hermit-rs/pull/718 (hermit)
- https://github.com/bytecodealliance/wasi-rs/pull/108 (wasi)
- https://github.com/gimli-rs/addr2line/pull/345
- https://github.com/oyvindln/adler2/pull/2
- https://github.com/BurntSushi/memchr/pull/180
- https://github.com/Frommi/miniz_oxide/pull/173
- https://github.com/gimli-rs/object/pull/777

try-job: x86_64-gnu
try-job: test-various
2025-06-09 12:17:53 -05:00
Trevor Gross
2f26913270
Rollup merge of #140767 - sayantn:stabilize-sha512, r=traviscross,tgross35
Stabilize `sha512`, `sm3` and `sm4` for x86

This PR stabilizes the feature flag `sha512_sm_x86` (tracking issue rust-lang/rust#126624).

# Public API
The 3 `x86` target features `sha512`, `sm3` and `sm4`, and the associated intrinsics in stdarch.

These target features are very specialized, and are only used to signal the presence of the corresponding CPU instruction. They don't have any nontrivial interaction with the ABI (contrary to something like AVX), and serve the only purpose of enabling 10 stdarch intrinsics, all of which have been implemented and propagated to rustc via a stdarch submodule update.

Also, these were added in LLVM17, and as the minimum LLVM required for rustc is LLVM19, we are safe in that front too!

# Associated PRs
 - rust-lang/rust#126704
 - rust-lang/stdarch#1592
 - rust-lang/stdarch#1790
 - rust-lang/rust#140389 (stdarch submodule update)
 - rust-lang/stdarch#1796 (stabilizing the runtime detection and intrinsics)
 - rust-lang/rust#141964 (stdarch submodule update for the stabilization of the runtime detection and intrinsics)

As all of the required tasks have been done (adding the target features to rustc, implementing their runtime detection in std_detect and implementing the associated intrinsics in core_arch), these target features can be stabilized now.

cc `@rust-lang/lang`
cc `@rust-lang/libs-api` for the intrinsics and runtime detection

I don't think anyone else worked on this feature, so no one else to ping, maybe cc `@Amanieu.` I will send the reference pr soon.
2025-06-09 12:17:52 -05:00
Deadbeef
9b0ad97287 deduplicate the rest of AST walker functions 2025-06-09 21:59:20 +08:00
Urgau
33beaba7c8 Always consider const _ items as live for dead code analysis 2025-06-09 15:48:06 +02:00
bors
14863ea077 Auto merge of #142242 - matthiaskrgr:rollup-1sgx0ji, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - rust-lang/rust#129121 (Stabilize `tcp_quickack`)
 - rust-lang/rust#142192 (De-duplicate f16 & f128 doctest attributes)
 - rust-lang/rust#142193 (add tests for pattern binding drop order edge cases)
 - rust-lang/rust#142222 (Dont make `ObligationCtxt`s with diagnostics unnecessarily)
 - rust-lang/rust#142228 (rustc-dev-guide subtree update)
 - rust-lang/rust#142231 (Run `calculate_matrix` job on `master` to cache citool builds)
 - rust-lang/rust#142232 (add `Cargo.lock` to CI-rustc allowed list for non-CI env)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-09 12:21:14 +00:00
Matthias Krüger
7ab938375d
Rollup merge of #142222 - compiler-errors:ocx-w-no-diag, r=lcnr
Dont make `ObligationCtxt`s with diagnostics unnecessarily

just a nit, shouldn't affect perf b/c `ObligationCtxt::new_with_diagnostics` should only be more expensive in the new trait solver, and I don't expect either of these to encounter errors today anyways.

r? oli-obk
2025-06-09 13:55:34 +02:00
xizheyin
4b898041f6 Make since of removed features the version removed and fill pull
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-06-09 17:17:49 +08:00
xizheyin
b4ba017c33 Note the version and PR of removed features when using it
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-06-09 17:10:58 +08:00
bors
7c10378e1f Auto merge of #142234 - matthiaskrgr:rollup-kg5wibu, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#141751 (Remap compiler vs non-compiler sources differently (bootstrap side))
 - rust-lang/rust#142160 (Only allow `bootstrap` cfg in rustc & related)
 - rust-lang/rust#142191 (early return in trait detection for non-trait item)
 - rust-lang/rust#142211 (Do not checkout GCC submodule for the tidy job)
 - rust-lang/rust#142218 (CI: rfl: move job forward to Linux v6.16-rc1)
 - rust-lang/rust#142224 (Avoid a gratuitous 10s wait in a stress test)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-09 08:27:35 +00:00
Matthias Krüger
9e2512036b
Rollup merge of #142191 - bvanjoi:issue-135863, r=compiler-errors
early return in trait detection for non-trait item

Fixes rust-lang/rust#135863
2025-06-09 10:20:53 +02:00