Commit Graph

477 Commits

Author SHA1 Message Date
bors
adaa838976 Auto merge of #148035 - bjorn3:check_skip_codegen_crate, r=madsmtm
Skip codegen_crate call in check mode

This way we don't have to spawn the coordinator thread. Some errors will no longer be emitted with this in check mode. For example the check that `-Ctarget-cpu` is passed on targets that need this.

Suggested by `@saethlin`
2025-10-27 17:24:08 +00:00
Ben Kimock
775da711c6 Add a fast path for lowering trivial consts 2025-10-25 16:59:53 -04:00
bjorn3
5a8ffa4bef Skip codegen_crate call in check mode 2025-10-24 10:25:13 +00:00
Camille GILLOT
ca0379d6cd Diagnose liveness on MIR. 2025-10-11 20:50:21 +00:00
Camille Gillot
7a7cb05f11 Do not validate MIR if code does not type-check. 2025-09-28 15:59:21 +00:00
Ben Kimock
888679013d Add panic=immediate-abort 2025-09-21 13:12:18 -04:00
Marijn Schouten
54b15a66d8 fixes for numerous clippy warnings 2025-09-19 20:56:07 +00:00
Matthias Krüger
86d39a0673 Rollup merge of #146340 - fmease:frontmatter-containment, r=fee1-dead,Urgau
Strip frontmatter in fewer places

* Stop stripping frontmatter in `proc_macro::Literal::from_str` (RUST-146132)
* Stop stripping frontmatter in expr-ctxt (but not item-ctxt!) `include`s (RUST-145945)
* Stop stripping shebang (!) in `proc_macro::Literal::from_str`
  * Not a breaking change because it did compare spans already to ensure there wasn't extra whitespace or comments (`Literal::from_str("#!\n0")` already yields `Err(_)` thankfully!)
* Stop stripping frontmatter+shebang inside some rustdoc code where it doesn't make any observable difference (see self review comments)
* (Stop stripping frontmatter+shebang inside internal test code)

Fixes https://github.com/rust-lang/rust/issues/145945.
Fixes https://github.com/rust-lang/rust/issues/146132.

r? fee1-dead
2025-09-10 20:29:09 +02:00
León Orell Valerian Liehr
7a66925a81 Strip frontmatter in fewer places 2025-09-09 19:49:40 +02:00
Jana Dönszelmann
6087d89004 fixup limit handling code 2025-09-08 15:07:12 -07:00
lcnr
0edb22cdbf cleanup proof tree implementation and add cache 2025-08-29 09:35:37 +02:00
Jana Dönszelmann
59ceb02d65 Port crate name to the new attribute system 2025-08-24 09:20:57 +02:00
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