Commit Graph

325562 Commits

Author SHA1 Message Date
Usman Akinyemi e5b42e5084 Fix E0040 suggestion for explicit Drop::drop UFCS calls
`Drop::drop(&mut f)` now correctly suggests `drop(f)` instead of
the bare `drop` with no argument.

Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
2026-05-05 01:09:33 +05:30
bors 0469a92a76 Auto merge of #156023 - jhpratt:rollup-sZeK85e, r=jhpratt
Rollup of 19 pull requests

Successful merges:

 - rust-lang/rust#155237 (Disentangle AST crates and error crates)
 - rust-lang/rust#155249 (Fix: On wasm targets, call `panic_in_cleanup` if panic occurs in cleanup)
 - rust-lang/rust#155853 (Use `_mcount` as the mcount symbol name on RISC-V Linux GNU targets)
 - rust-lang/rust#155919 (simplify `ast_fragments!`)
 - rust-lang/rust#155939 (Add feature gate for view_types experiment)
 - rust-lang/rust#155954 (rustdoc: preserve parent doc cfg for `macro_export` macros)
 - rust-lang/rust#155974 (add `c_variadic_experimental_arch` feature)
 - rust-lang/rust#155991 (Catch unwinds from the global ctxt callback to complete queries profiling data in more cases)
 - rust-lang/rust#156003 (Pass Session to optimize_and_codegen_fat_lto)
 - rust-lang/rust#153566 (Add suggestion for E0401 on inner const items)
 - rust-lang/rust#154610 (Suggest public re-exports when a private module makes an import path inaccessible)
 - rust-lang/rust#155523 (Reorganize `tests/ui/issues/` - 02)
 - rust-lang/rust#155821 (c-variadic: document `Clone` and `Drop` instances and require `VaArgSafe: Copy`)
 - rust-lang/rust#155980 (Move `feature*` methods from `parse` mod to `errors` mod.)
 - rust-lang/rust#155987 (Make lifting infallible)
 - rust-lang/rust#155988 (tests/run-make/print-cfg: add Android target_env case)
 - rust-lang/rust#156000 (Fix ICE when using -Zinstrument-mcount and -Clinker-flavor=lld)
 - rust-lang/rust#156002 (Allow to use `Diagnostic` directly in `SharedContext::emit_lint`)
 - rust-lang/rust#156015 (rustc-dev-guide subtree update)
2026-05-01 04:14:53 +00:00
Jacob Pratt fbde425c84 Rollup merge of #156015 - tshepang:rdg-sync, r=tshepang
rustc-dev-guide subtree update

Subtree update of `rustc-dev-guide` to https://github.com/rust-lang/rustc-dev-guide/commit/cdd2373cb446ad722b160c5d599910452b3997ee.

Created using https://github.com/rust-lang/josh-sync.

r? @ghost
2026-04-30 22:28:36 -04:00
Jacob Pratt a89e69e21d Rollup merge of #156002 - GuillaumeGomez:diagnostic-instead-of-closure, r=JonathanBrouwer
Allow to use `Diagnostic` directly in `SharedContext::emit_lint`

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

r? @JonathanBrouwer
2026-04-30 22:28:35 -04:00
Jacob Pratt cf607056a0 Rollup merge of #156000 - pmur:murp/fix-155972, r=wesleywiser
Fix ICE when using -Zinstrument-mcount and -Clinker-flavor=lld

-Zinstrument-mcount passes -pg to the gnu linker command. This option is only supported by the cc frontend.

This fixes https://github.com/rust-lang/rust/issues/155972
2026-04-30 22:28:35 -04:00
Jacob Pratt b39cdf5656 Rollup merge of #155988 - Vastargazing:tests/android-target-env-print-cfg, r=petrochenkov
tests/run-make/print-cfg: add Android target_env case

Regression test for rust-lang/rust#90834

rust-lang/rust#77729 + rust-lang/rust#78929 accidentally gave Android targets `target_env="gnu"`
through `android_base` inheriting from `linux_gnu_base`. rust-lang/rust#90834 moved it
back to plain `linux_base` but didn't add a test, so a future target-spec
refactor could bring it back unnoticed. This adds an Android case to
`tests/run-make/print-cfg` covering exactly that.

r? @petrochenkov
2026-04-30 22:28:34 -04:00
Jacob Pratt 96b94a8a52 Rollup merge of #155987 - nnethercote:infallible-Lifting, r=oli-obk
Make lifting infallible

Details in individual commits.

r? @oli-obk
2026-04-30 22:28:33 -04:00
Jacob Pratt 894bdf298e Rollup merge of #155980 - nnethercote:mv-feature-methods, r=TaKO8Ki
Move `feature*` methods from `parse` mod to `errors` mod.

As the FIXME comment says, these no longer use `ParseSess` and so the `parse` mod is not a good place for them. The `errors` mod is a better home.

r? @TaKO8Ki
2026-04-30 22:28:33 -04:00
Jacob Pratt 0ab1a47246 Rollup merge of #155821 - folkertdev:doc-va-list-clone, r=joshtriplett
c-variadic: document `Clone` and `Drop` instances and require `VaArgSafe: Copy`

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

Fixing some things that came up in the stabilization PR

r? tgross35
cc @kpreid
2026-04-30 22:28:32 -04:00
Jacob Pratt 5b91e270dc Rollup merge of #155523 - ujjwalvishwakarma2006:reorg-tests-02, r=Kivooeo
Reorganize `tests/ui/issues/` - 02

| old-name | new-sub-dir | new-name |
|-|-|-|
| `issue-19001.rs` [issue](https://github.com/rust-lang/rust/issues/19001) | `recursion/` | `recursive-struct-with-raw-pointer-field.rs` |
| `issue-31769.rs` [issue](https://github.com/rust-lang/rust/issues/31769) | `attributes/` | `dont-allow-inline-and-repr-at-invalid-positions.rs` |
| `issue-31769.stderr` | `attributes/` | `dont-allow-inline-and-repr-at-invalid-positions.stderr` |
| `issue-33202.rs` [issue](https://github.com/rust-lang/rust/issues/33202) | `attributes/` | `repr-on-single-variant-Enum.rs` |
| `issue-38763.rs` [issue](https://github.com/rust-lang/rust/issues/38763) | `foreign/` | `foreign-fn-with-more-than-8-byte-arg-size.rs` |

r? Kivooeo
2026-04-30 22:28:31 -04:00
Jacob Pratt 654c350837 Rollup merge of #154610 - jakubadamw:issue-13065, r=TaKO8Ki
Suggest public re-exports when a private module makes an import path inaccessible

This is an attempt at solving rust-lang/rust#13065.

When a `use` path fails because it passes through a private module (E0603), and a public re-export of the target item exists elsewhere, the compiler will now suggest importing through that re-export instead.

For example, given:

```rust
mod outer {
    pub use self::inner::MyStruct;
    mod inner {
        pub struct MyStruct;
    }
}

use outer::inner::MyStruct; // error: module `inner` is private
```

the compiler will now suggest use `outer::MyStruct`; - the publicly accessible path - rather than just pointing at the private module definition and leaving the user to figure out the alternative.

When possible, relative paths are suggested, including those using `super` (currently capped at a maximum of one `super` path item).

The newly added test is parametrised by editions because of the change in behaviour around `crate::`-prefixed imports in edition 2018. Perhaps that’s an overkill – I’ll be happy to remove the variations for editions 2021 and 2024.

Closes rust-lang/rust#13065.
2026-04-30 22:28:31 -04:00
Jacob Pratt 248756dc40 Rollup merge of #153566 - JohnTitor:sugg-generic-params-from-outer-item-err, r=wesleywiser
Add suggestion for E0401 on inner const items

Fix rust-lang/rust#68373
r? @estebank
2026-04-30 22:28:30 -04:00
Jacob Pratt 560cc23c95 Rollup merge of #156003 - bjorn3:lto_refactors17, r=lqd
Pass Session to optimize_and_codegen_fat_lto

This is necessary to fix incremental LTO in cg_gcc as well as to do some LTO refactorings I want to do. The actual fix for cg_gcc will be done on the cg_gcc repo to test it in CI.
2026-04-30 22:28:29 -04:00
Jacob Pratt 4e12409c82 Rollup merge of #155991 - lqd:in-flight-query-profiling, r=bjorn3
Catch unwinds from the global ctxt callback to complete queries profiling data in more cases

The driver/compiler interface provides multiple callbacks, and we sometimes catch unwinds to flush diagnostics, ensure ICEs appear, and so on even when fatal errors occur.

When these panics happen, we don't `finish` the `TyCtxt`, and there's a fixme about that. Unfortunately this is where we also allocate the self-profile strings: query events for example start as virtual and are turned into real strings by this finalization process; they are _invalid_ without this step. When fatal errors happen, the in-flight query name will be `<unknown>`, event counts will be inaccurate, etc.

This PR catches panics from another of these callbacks, where the `TyCtxt` is available, to allow for the self-profiling data to be computed before continuing the unwinding process as before. `finish` does more things, that I don't want to introduce here.

I remember seeing this discussed in GH issues in the past, but can't find any open ones now. It may also have been only mentioned while trying to profile existing slowness issues. I stumbled upon this again recently when looking into `tests/ui/try-trait/deep-try-chain-issue-153583.rs`, where the slowest query is `<unknown>`.

```
> rm *.mm_profdata ; rustc +nightly -Zself-profile tests/ui/try-trait/deep-try-chain-issue-153583.rs ; summarize summarize *.mm_profdata | head -n 5

error[E0277]: the `?` operator can only be applied to values that implement `Try`
 --> tests/ui/try-trait/deep-try-chain-issue-153583.rs:6:5
  |
6 |     0?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...
  |     ^^ the `?` operator cannot be applied to type `{integer}`
  |
  = help: the nightly-only, unstable trait `Try` is not implemented for `{integer}`

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0277`.
+------------------------------------------------------+-----------+-----------------+----------+------------+
| Item                                                 | Self time | % of total time | Time     | Item count |
+------------------------------------------------------+-----------+-----------------+----------+------------+
| <unknown>                                            | 1.55s     | 99.416          | 3.21s    | 15230      |
+------------------------------------------------------+-----------+-----------------+----------+------------+
```

This PR fixes that case at least. In general, it should fix the invalid profiling records for fatal errors happening while a query is running.

```
+------------------------------------------------------+-----------+-----------------+----------+------------+
| Item                                                 | Self time | % of total time | Time     | Item count |
+------------------------------------------------------+-----------+-----------------+----------+------------+
| typeck_root                                          | 5.04s     | 95.588          | 5.08s    | 1          |
+------------------------------------------------------+-----------+-----------------+----------+------------+
```

r? @bjorn3
2026-04-30 22:28:29 -04:00
Jacob Pratt fae8c6edd1 Rollup merge of #155974 - folkertdev:c-variadic-experimental-arch, r=joshtriplett
add `c_variadic_experimental_arch` feature

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

Based on https://hackmd.io/pIbUgMQuQcGaibJcinOcEw#Stabilize-c-variadic-function-definitions-rust155697, we'll gate niche targets where we don't control the implementation of `va_arg`, the ABI is unclear, or in general where we're not confident stabilizing the implementation.
2026-04-30 22:28:28 -04:00
Jacob Pratt 0a05ddf92b Rollup merge of #155954 - cijiugechu:doc_cfg-decl-macro, r=notriddle
rustdoc: preserve parent doc cfg for `macro_export` macros

The detached-item context is discovered before `propagate_doc_cfg`, it is carried on the clean item and consumed by the pass.

Closes rust-lang/rust#100916
2026-04-30 22:28:27 -04:00
Jacob Pratt f7b1e7d892 Rollup merge of #155939 - scrabsha:view-types/feature-gate, r=nikomatsakis
Add feature gate for view_types experiment
2026-04-30 22:28:26 -04:00
Jacob Pratt d0836bbbfb Rollup merge of #155919 - cyrgani:ast-fragments, r=petrochenkov
simplify `ast_fragments!`

The syntax and meaning of this macro are not very intuitive as its just a large dump of function names and has some special cases.
Each commit should be a small improvement that can be evaluated on its own.
2026-04-30 22:28:26 -04:00
Jacob Pratt 6e290dec8a Rollup merge of #155853 - lapla-cogito:rv_mcount, r=mati865
Use `_mcount` as the mcount symbol name on RISC-V Linux GNU targets

Fixes rust-lang/rust#155830

glibc on RISC-V exports `_mcount`, not `mcount`. https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/riscv/machine-gmon.h;hb=HEAD

r? mati865 (I think you're well-suited to review this area, but feel free to reroll)
2026-04-30 22:28:25 -04:00
Jacob Pratt 0649c3f5d5 Rollup merge of #155249 - hoodmane:wasm-panic-in-cleanup-reland, r=bjorn3
Fix: On wasm targets, call `panic_in_cleanup` if panic occurs in cleanup

Relies on https://github.com/rust-lang/llvm-project/pull/194.
Reland of https://github.com/rust-lang/rust/pull/151771.

Previously this was not correctly implemented. Each funclet may need its own terminate block, so this changes the `terminate_block` into a `terminate_blocks` `IndexVec` which can have a terminate_block for each funclet. We key on the first basic block of the funclet -- in particular, this is the start block for the old case of the top level terminate function.

Rather than using a catchswitch/catchpad pair, I used a cleanuppad. The reason for the pair is to avoid catching foreign exceptions on MSVC. On wasm, it seems that the catchswitch/catchpad pair is optimized back into a single cleanuppad and a catch_all instruction is emitted which will catch foreign exceptions. Because the new logic is only used on wasm, it seemed better to take the simpler approach seeing as they do the same thing.

- [ ] Add test for https://github.com/rust-lang/rust/issues/153948
2026-04-30 22:28:24 -04:00
Jacob Pratt f5304d2c66 Rollup merge of #155237 - nnethercote:ast-errors-rejig, r=petrochenkov
Disentangle AST crates and error crates

Currently the `rustc_ast*` crates and the `rustc_error*` crates (and `rustc_lint_defs`) are quite intertwined. This PR disentangles them. Details in individual commits.

r? @davidtwco
2026-04-30 22:28:23 -04:00
Nicholas Nethercote 339797e8b6 Eliminate rustc_lint_defs' dependency on rustc_ast.
It currently only depends on two things:
- `rustc_ast::AttrId`: this is just a re-export of `rustc_span::AttrId`,
  so we can import the original instead.
- `rustc_ast::AttributeExt`: needed only for the `name` and `id`
  methods. We can instead pass in the `name` and `id` directly.
2026-05-01 10:58:42 +10:00
Nicholas Nethercote 9454be304f Invert dependency between rustc_error_messages and rustc_ast*.
`rustc_error_messages` currently depends on
`rustc_ast`/`rustc_ast_pretty`. This is odd, because
`rustc_error_messages` feels like a very low-level module but
`rustc_ast`/`rustc_ast_pretty` do not.

The reason is that a few AST types impl `IntoDiagArg` via
pretty-printing. `rustc_error_messages` can define `IntoDiagArg` and
then impl it for the AST types. But if we invert the dependency we hit
a problem with the orphan rule: `rustc_ast` must impl `IntoDiagArg`
for the AST types, but that requires calling pretty-printing code which
is in `rustc_ast_pretty`, a downstream crate.

This commit avoids this problem by just removing the `IntoDiagArg` impls
for these AST types. There aren't that many of them, and we can just use
`String` in the relevant error structs and use the pretty printer in the
downstream crates that construct the error structs. There are plenty of
existing examples where `String` is used in error structs.

There is now no dependency between `rustc_ast*` and
`rustc_error_messages`.
2026-05-01 10:58:14 +10:00
Tshepang Mbambo 8eedc9f9ca Merge pull request #2860 from rust-lang/tshepang/sembr
sembr a few files
2026-04-30 21:47:15 +02:00
Tshepang Mbambo c0e3f05f46 reflow 2026-04-30 20:37:36 +02:00
Tshepang Mbambo cd47965c28 sembr src/panic-implementation.md 2026-04-30 20:35:27 +02:00
Tshepang Mbambo c4ad3037e6 sembr src/tests/directives.md 2026-04-30 20:34:39 +02:00
Tshepang Mbambo 373f5d3987 sembr src/tests/compiletest.md 2026-04-30 20:33:33 +02:00
Folkert de Vries ac12c696b8 remove custom va_end implementation in the LLVM backend
it should use the fallback body instead
2026-04-30 20:32:15 +02:00
Tshepang Mbambo 958600a559 sembr src/backend/backend-agnostic.md
It has required much reflowing
(and sembr tool is not fancy enough yet)
2026-04-30 20:31:25 +02:00
Tshepang Mbambo d12e52d852 reflow 2026-04-30 20:28:39 +02:00
Folkert de Vries ba9444c4f4 c-variadic: test that const and mutable void and char pointers implement VaArgSafe 2026-04-30 20:09:52 +02:00
Folkert de Vries ab19cd3dea c-variadic: add a Copy bound to VaArgSafe
because a VaList can be cloned, the same c-variadic argument can be read twice and that is only safe if the argument type is copy
2026-04-30 20:09:51 +02:00
Folkert de Vries eb8f85e7f4 c-variadic: document Clone and Drop instances 2026-04-30 20:09:51 +02:00
Tshepang Mbambo 44034eca66 inclusive wording 2026-04-30 20:07:22 +02:00
Tshepang Mbambo d6af96f447 reflow 2026-04-30 20:02:35 +02:00
Tshepang Mbambo 80f3a50056 sembr src/asm.md 2026-04-30 19:01:35 +02:00
Tshepang Mbambo dc2397c9ce capitalise first word in sentence 2026-04-30 19:01:09 +02:00
Tshepang Mbambo d2b6863037 "the LLVM" sounds wrong 2026-04-30 19:00:07 +02:00
Tshepang Mbambo 714854d53e sembr src/backend/backend-agnostic.md 2026-04-30 18:23:50 +02:00
Tshepang Mbambo 219cd1f949 Merge pull request #2859 from rust-lang/rustc-pull
Rustc pull update
2026-04-30 18:22:02 +02:00
The rustc-josh-sync Cronjob Bot 6d2abd726b Merge ref 'f53b654a8882' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh.

Upstream ref: rust-lang/rust@f53b654a88
Filtered ref: rust-lang/rustc-dev-guide@854e05348f
Upstream diff: https://github.com/rust-lang/rust/compare/ca9a134e0985765ded9cfdde4030a5df4db7e2bd...f53b654a8882fd5fc036c4ca7a4ff41ce32497a6

This merge was created using https://github.com/rust-lang/josh-sync.
2026-04-30 16:20:37 +00:00
The rustc-josh-sync Cronjob Bot a0db15f7cf Prepare for merging from rust-lang/rust
This updates the rust-version file to f53b654a88.
2026-04-30 16:20:30 +00:00
bjorn3 c5e38b741d Pass Session to optimize_and_codegen_fat_lto
This is necessary to fix incremental LTO in cg_gcc as well as to do some
LTO refactorings I want to do. The actual fix for cg_gcc will be done on
the cg_gcc repo to test it in CI.
2026-04-30 14:18:33 +00:00
Guillaume Gomez f51cf6398b Allow to use Diagnostic directly in SharedContext::emit_lint 2026-04-30 16:01:12 +02:00
Paul Murphy 74060d46ca Fix ICE when using -Zinstrument-mcount and -Clinker-flavor=lld
-Zinstrument-mcount passes -pg to the gnu linker command. This
option is only supported by the cc frontend.

This fixes https://github.com/rust-lang/rust/issues/155972
2026-04-30 08:27:31 -05:00
Rémy Rakic e4eb91ca0f catch callback unwinding to finalize in-flight self-profiling events from queries
fatal errors currently abort the compiler process without allocating the self-profile
strings: query events aren't always correctly recorded, and will show up as <unknown>
in the data.

catching the unwinding panic allows us to finalize the self-profiling process correctly
before continuing unwinding as before.
2026-04-30 15:14:55 +02:00
cijiugechu 09e9d3f6da rustdoc: preserve parent doc cfg for macro_export macros 2026-04-30 16:31:22 +08:00
bors f53b654a88 Auto merge of #155018 - nnethercote:simplify-HashStable, r=fee1-dead
Simplify `HashStable`



This PR:
- Simplifies the `HashStable` trait, by moving its generic parameter from the trait to its single method.
- Eliminates the need for the non-obvious `derive(HashStable)`/`derive(HashStable_Generic)` distinction.
- Reduces the need for, and clarifies, the non-obvious `derive(HashStable)`/`derive(HashStable_NoContext)` distinction.

r? @fee1-dead
2026-04-30 07:30:46 +00:00
Vastargazing ef93fbbc9d tests/run-make/print-cfg: add Android target_env case
Android targets must not inherit `target_env="gnu"` from the Linux GNU
base. Cover this in the existing print-cfg run-make test so a future
target-spec refactor cannot silently re-introduce it.
2026-04-30 10:24:54 +03:00