465 Commits

Author SHA1 Message Date
Camille Gillot
a3c878f813 Separate transmute checking from typeck. 2025-08-22 20:10:27 +00:00
Jonathan Brouwer
21d3189779
Move validate_attr to rustc_attr_parsing 2025-08-22 08:37:19 +02:00
bors
41ede7bd9b Auto merge of #145146 - fee1-dead-contrib:push-zmqrkurlzrxy, r=nnethercote
remove `P`

Previous work: rust-lang/rust#141603
MCP: https://github.com/rust-lang/compiler-team/issues/878

cc `@nnethercote`
2025-08-09 23:27:55 +00:00
Deadbeef
ad1113f87e remove P 2025-08-09 15:47:01 +08:00
Nicholas Nethercote
0239e46487 Fix some bad formatting in -Zmacro-stats output.
I also double-checked that everything looks good on some real-world
crates.
2025-08-08 14:51:24 +10:00
bors
c23f07d8c5 Auto merge of #144479 - cjgillot:incr-privacy-mod, r=petrochenkov
Perform check_private_in_public by module.

Based on https://github.com/rust-lang/rust/pull/116316
2025-08-02 01:59:11 +00:00
Nicholas Nethercote
e83c8cb26c Move ResolverOutputs out of rustc_middle.
It's not used in `rustc_middle`, and `rustc_resolve` is a better place
for it.
2025-07-31 11:50:23 +10:00
Camille GILLOT
a1f5a6d781 Perform check_private_in_public by module. 2025-07-26 21:21:04 +00:00
Guillaume Gomez
96340f6714 Stop compilation if macro expansion failed 2025-07-25 23:46:28 +02:00
Camille GILLOT
3301ac5f7b Integrate stable feature checking into a query. 2025-07-17 23:19:12 +00:00
Camille GILLOT
f7e0891423 Retire stability_index query. 2025-07-17 23:04:19 +00:00
bors
556d20a834 Auto merge of #143247 - cjgillot:metadata-no-red, r=petrochenkov
Avoid depending on forever-red DepNode when encoding metadata.

Split from https://github.com/rust-lang/rust/pull/114669 for perf

r? `@petrochenkov`
2025-07-04 10:23:18 +00:00
Camille GILLOT
992fa62118 Hash resolutions. 2025-07-02 09:14:34 +00:00
Matthias Krüger
f2231d5324
Rollup merge of #143228 - nnethercote:macro-stats-build-scripts, r=Kobzol
Handle build scripts better in `-Zmacro-stats` output.

Currently all build scripts are listed as `build_script_build` in the stats header. This commit uses `CARGO_PKG_NAME` to improve that.

I tried it on Bevy, it works well, giving output like this on the build script:
```
MACRO EXPANSION STATS: serde build script
```
and this on the crate itself:
```
MACRO EXPANSION STATS: serde
```

r? `@Kobzol`
2025-06-30 20:49:43 +02:00
Nicholas Nethercote
c3c995a275 Handle build scripts better in -Zmacro-stats output.
Currently all build scripts are listed as `build_script_build` in the
stats header. This commit uses `CARGO_PKG_NAME` to improve that.

I tried it on Bevy, it works well, giving output like this on the build
script:
```
MACRO EXPANSION STATS: serde build script
```
and this on the crate itself:
```
MACRO EXPANSION STATS: serde
```
2025-06-30 16:32:00 +10:00
Nicholas Nethercote
e0761a57ab Improve macro-stats printing.
By allowing long names to overlap with the "Uses" field when it has
spare space. This avoids unnecessary line breaks in the output.
2025-06-30 13:33:51 +10:00
Jubilee
b5631095cd
Rollup merge of #142934 - nnethercote:tweak-macro-stats, r=petrochenkov
Tweak `-Zmacro-stats` measurement.

It currently reports net size, i.e. size(output) - size(input). After some use I think this is sub-optimal, and it's better to just report size(output). Because for derive macros the input size is always 1, and for attribute macros it's almost always 1.

r? ```@petrochenkov```
2025-06-24 19:45:33 -07:00
Guillaume Gomez
e8dd3c356c
Rollup merge of #142944 - nnethercote:stats-tweaks, r=lqd
Stats output tweaks

Some improvements to `-Zinput-stats` and `-Zmeta-stat` inspired by the new `-Zmacro-stats`.

r? `@lqd`
2025-06-24 15:39:42 +02:00
Nicholas Nethercote
b2a57e6b42 Tweak -Zinput-stats and -Zmeta-stats output.
To make it match `-Zmacro-stats`, and work better if you have enabled it
for multiple crates.
- Print each crate's name.
- Print a `===` banner at the start and end for separation.
2025-06-24 13:07:14 +10:00
Nicholas Nethercote
8b1abd6578 Make stats code nicer.
Taking inspiration from `-Zmacro-stats`:
- Use "{prefix}" consistently.
- Use names for column widths.
- Write output in a single `eprint!` call, in an attempt to minimize
  interleaving of output from different rustc processes.
- Use `repeat` for the long `---` banners.
2025-06-24 13:05:51 +10:00
Nicholas Nethercote
c3200c3bb5 Tweak -Zmacro-stats measurement.
It currently reports net size, i.e. size(output) - size(input). After
some use I think this is sub-optimal, and it's better to just report
size(output). Because for derive macros the input size is always 1, and
for attribute macros it's almost always 1.
2025-06-24 08:42:14 +10:00
Jubilee
8ba69d0f95
Rollup merge of #142784 - Kobzol:timings-codegen, r=nnethercote
Add codegen timing section

And since we now start and end the sections also using separate functions, also add some light checking if we're generating the sections correctly.

I'm integrating `--timings` into Cargo, and I realized that the codegen timings would be quite useful for that. Frontend can be computed simply as `[start of compilation, start of codegen]` for now.

r? `@nnethercote`
2025-06-23 12:48:20 -07:00
Jakub Beránek
332ae3b7e6
Add codegen timing section 2025-06-23 08:50:17 +02:00
Jakub Beránek
31663db896
Rollup merge of #142767 - nnethercote:symbol-cleanups, r=petrochenkov
Some symbol and PathRoot cleanups

I'm looking into unifying how we join and print paths. Here are some preliminary cleanups.

r? ``@petrochenkov``
2025-06-20 20:03:24 +02:00
Trevor Gross
dd41c06e27
Rollup merge of #142687 - cjgillot:less-hir_crate, r=oli-obk
Reduce uses of `hir_crate`.

I tried rebasing my old incremental-HIR branch. This is a by-product, which is required if we want to get rid of `hir_crate` entirely.

The second commit is a drive-by cleanup. It can be pulled into its own PR.

r? ````@oli-obk````
2025-06-20 02:50:40 -04:00
Nicholas Nethercote
4a1f445142 Use a symbol for ExpansionConfig::crate_name.
This avoids some symbol interning and `to_string` conversions.
2025-06-20 13:17:39 +10:00
Camille Gillot
ede48910fd
Update compiler/rustc_interface/src/passes.rs
Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com>
2025-06-19 13:18:33 +02:00
Camille GILLOT
c6e77b3ba6 Reduce uses of hir_crate. 2025-06-18 15:46:19 +00:00
León Orell Valerian Liehr
0b249d3f85
Rollup merge of #141769 - bjorn3:codegen_metadata_module_rework, r=workingjubilee,saethlin
Move metadata object generation for dylibs to the linker code

This deduplicates some code between codegen backends and may in the future allow adding extra metadata that is only known at link time.

Prerequisite of https://github.com/rust-lang/rust/issues/96708.
2025-06-15 23:51:54 +02:00
Nicholas Nethercote
376cbc3787 Introduce -Zmacro-stats.
It collects data about macro expansions and prints them in a table after
expansion finishes. It's very useful for detecting macro bloat,
especially for proc macros.

Details:
- It measures code snippets by pretty-printing them and then measuring
  lines and bytes. This required a bunch of additional pretty-printing
  plumbing, in `rustc_ast_pretty` and `rustc_expand`.
- The measurement is done in `MacroExpander::expand_invoc`.
- The measurements are stored in `ExtCtxt::macro_stats`.
2025-06-12 21:17:17 +10:00
Oli Scherer
1b9d38dd08 Remove check_mod_loops query and run the checks per-body instead 2025-06-10 08:41:23 +00:00
bors
cdd545be1b Auto merge of #141950 - oli-obk:big-body-owner-loop, r=compiler-errors
Move coroutine_by_move_body_def_id into the big check_crate body owner loop

This avoids starting a parallel loop in sequence and instead runs all the queries for a specific DefId together.
2025-06-07 20:06:23 +00:00
bors
44f415c1d6 Auto merge of #141774 - oli-obk:naked-fn-queries, r=petrochenkov
Change per-module naked fn checks to happen during typeck instead

cc `@Lokathor` `@Amanieu` `@folkertdev`

just seems nicer this way
2025-06-06 18:22:10 +00:00
Matthias Krüger
b7150d4e63
Rollup merge of #141943 - nnethercote:rm-pre-expansion-ast-stats, r=compiler-errors
Remove pre-expansion AST stats.

They're very little value, because they only measure the top-level `main.rs` or `lib.rs` file. (Other `.rs` files don't get read and parsed until expansion occurs.)

I saw an example recently where the pre-expansion AST was 3KB in size and the post-expansion AST was 66MB.

I kept the "POST EXPANSION" in the output header, I think that's useful information to avoid possible confusion about when the measurement happens.

r? `@davidtwco`
2025-06-03 21:53:38 +02:00
bjorn3
0bd7aa1116 Move metadata object generation for dylibs to the linker code
This deduplicates some code between codegen backends and may in the
future allow adding extra metadata that is only known at link time.
2025-06-03 10:04:34 +00:00
bjorn3
badabab01f Only borrow EncodedMetadata in codegen_crate
And move passing it to the linker to the driver code.
2025-06-03 10:04:34 +00:00
Oli Scherer
8a0fdbd407 Move coroutine_by_move_body_def_id into the big check_crate body owner loop 2025-06-03 08:06:24 +00:00
Nicholas Nethercote
02a86dbd1d Remove pre-expansion AST stats.
They're very little value, because they only measure the top-level
`main.rs` or `lib.rs` file. (Other `.rs` files don't get read and parsed
until expansion occurs.)

I saw an example recently where the pre-expansion AST was 3KB in size
and the post-expansion AST was 66MB.

I kept the "POST EXPANSION" in the output header, I think that's useful
information to avoid possible confusion about when the measurement
happens.
2025-06-03 14:50:22 +10:00
Oli Scherer
685d1c9e29 Change a per-module query to just run on the items it internally filters for 2025-05-30 15:07:36 +00:00
Oli Scherer
c56a3093ea Merge coroutine obligation checking into borrowck parallel loop 2025-05-30 14:32:21 +00:00
bjorn3
96ac571445 Move -Zcrate-attr injection to just after crate root parsing
This way after_crate_root_parsing and -Zpretty will see them.
2025-05-21 14:32:40 +00:00
Andrew Zhogin
61059282eb Warning added when dependency crate has async drop types, and the feature is disabled 2025-05-19 21:38:07 +07:00
bors
16244bc37a Auto merge of #140856 - oli-obk:merge-queries2, r=nnethercote
Merge mir query analysis invocations

r? `@ghost`

same thing as https://github.com/rust-lang/rust/pull/140854 just a different set of queries

Doing this in general has some bad cache coherence issues because the query caches are laid out in Vec<QueryResult> lists per query where each index refers to a DefId in the same order as we're iterating. Iterating two or more lists at the same time does have cache issues, so I want to poke a bit at it to see if we can't merge just a few of them at a time.
2025-05-17 22:31:43 +00:00
Oli Scherer
e011c43bcf Merge mir query analysis invocations
The reasons I'm doing it is that

* merging those blocks allows for more parallelism as you don't run parallel blocks in sequence
* merging blocks allows merging analysis queries shrinking the dep graph
* should allow us to do more early aborting in case of errors and/or moving query calls from the analysis query into others that allow early aborting the others (and doing more tainting and stuff)
2025-05-14 08:04:56 +00:00
Oli Scherer
34976ac9fe Invoke a query only when it doesn't return immediately anyway 2025-05-13 08:55:32 +00:00
omahs
1caaa88700 Fix typos 2025-05-12 17:20:49 +00:00
Bryanskiy
14535312b5 Initial support for dynamically linked crates 2025-05-04 22:03:15 +03:00
bors
6e23095adf Auto merge of #140145 - Zoxc:job-server-proxy, r=SparrowLii
Add a jobserver proxy to ensure at least one token is always held

This adds a jobserver proxy to ensure at least one token is always held by `rustc`. Currently with `-Z threads` `rustc` can temporarily give up all its tokens, causing `cargo` to spawn additional `rustc` instances beyond the job limit.

The current behavior causes an issue with `cargo fix` which has a global lock preventing concurrent `rustc` instances, but it also holds a jobserver token, causing a deadlock when `rustc` gives up its token. That is fixed by this PR.

Fixes https://github.com/rust-lang/rust/issues/67385.
Fixes https://github.com/rust-lang/rust/issues/133873.
Fixes https://github.com/rust-lang/rust/issues/140093.
2025-05-01 04:11:52 +00:00
John Kåre Alsaker
ef9403371f Drop AST on a separate thread and prefetch hir_crate 2025-04-29 14:03:07 +02:00
John Kåre Alsaker
cff9efde74 Add a jobserver proxy to ensure at least one token is always held 2025-04-29 07:20:13 +02:00