rust/compiler
Matthias Krüger 81cc29a425
Rollup merge of #145354 - cache-proc-derive-macros, r=petrochenkov
Cache derive proc macro expansion with incremental query

This is a revival of https://github.com/rust-lang/rust/pull/129102, originally implemented by @futile. Since it looks like they are not active currently, I'd like to push this work forward.

The first commit is squashed and rebased work from the original PR, with author attribution to futile. The rest of the commits are some additional comments that I created mostly for myself to understand what happens here. I also did some cleanups based on Vadim's review comments on the original PR, plus I refactored the TLS access a bit using `scoped_tls`.

The biggest issue, as usually, are tests... I tried using `#[rustc_clean(..., loaded_from_disk = "derive_macro_expansion")]`, but the problem is that since this query cannot recover the original key from its hash, and thus its fingerprintstyle is `FingerprintStyle::Opaque`, [this](2fef0a30ae/compiler/rustc_incremental/src/persist/dirty_clean.rs (L388)) crashes when I try to use `loaded_from_disk`. Any suggestions from someone who actually understands the query system would be welcome 😅

TODO: document the new unstable flag

On a no-op change re-check of `octocrab 0.49` (which has a ton of `serde` derive proc macro invocations), this saves ~0.6s out of ~6s (so a ~10% win) on my PC.

r? @petrochenkov
2026-01-16 13:57:45 +01:00
..
rustc Auto merge of #148925 - madsmtm:jemalloc-perf, r=Kobzol 2025-11-23 20:34:07 +00:00
rustc_abi Rollup merge of #149991 - Flakebi:gpu-kernel-cc, r=workingjubilee 2026-01-02 23:13:21 +01:00
rustc_arena Finish transition from semitransparent to semiopaque for rustc_macro_transparency 2026-01-08 19:14:45 +01:00
rustc_ast Implement incremental caching for derive macro expansions 2026-01-16 07:36:36 +01:00
rustc_ast_ir Implement &pin patterns and ref pin bindings 2025-11-10 09:57:08 +08:00
rustc_ast_lowering Auto merge of #151003 - matthiaskrgr:rollup-wvnF9sN, r=matthiaskrgr 2026-01-12 16:43:20 +00:00
rustc_ast_passes Auto merge of #150640 - AprilNEA:mgca-merge-associated-const-equality, r=BoxyUwU 2026-01-06 01:36:53 +00:00
rustc_ast_pretty rename eii-extern-target 2026-01-12 08:07:23 +01:00
rustc_attr_parsing Auto merge of #151056 - mejrs:do_not_recommend, r=JonathanBrouwer 2026-01-15 19:35:19 +00:00
rustc_baked_icu_data Unify the configuration of the compiler docs 2025-11-05 11:25:27 +00:00
rustc_borrowck remove borrowck handling for inline const patterns 2026-01-08 08:44:04 -08:00
rustc_builtin_macros Rollup merge of #151046 - semiopaque-eii-fix, r=jdonszelmann 2026-01-14 22:29:59 +01:00
rustc_codegen_cranelift Finish transition from semitransparent to semiopaque for rustc_macro_transparency 2026-01-08 19:14:45 +01:00
rustc_codegen_gcc Remove Deref/DerefMut impl for Providers. 2026-01-14 15:55:59 +11:00
rustc_codegen_llvm Rollup merge of #150607 - dispatch-ptr-intrinsic, r=workingjubilee 2026-01-15 19:35:46 -05:00
rustc_codegen_ssa Rollup merge of #150607 - dispatch-ptr-intrinsic, r=workingjubilee 2026-01-15 19:35:46 -05:00
rustc_const_eval Rollup merge of #151096 - rm-providers-deref, r=oli-obk 2026-01-14 11:05:42 +01:00
rustc_data_structures Auto merge of #149273 - bjorn3:crate_locator_improvements, r=petrochenkov 2025-12-14 09:16:11 +00:00
rustc_driver Unify the configuration of the compiler docs 2025-11-05 11:25:27 +00:00
rustc_driver_impl Rollup merge of #150840 - print-check-cfg-rework-output, r=nnethercote 2026-01-13 23:39:09 +01:00
rustc_error_codes Port #[instruction_set] to attribute parser 2025-12-31 03:01:05 +01:00
rustc_error_messages Remove unused pop_span_label method 2025-11-21 14:16:12 +00:00
rustc_errors remove fixme & update stderr files 2025-12-16 13:23:48 +00:00
rustc_expand Implement incremental caching for derive macro expansions 2026-01-16 07:36:36 +01:00
rustc_feature rename extern item to foreign item 2026-01-12 08:07:23 +01:00
rustc_fluent_macro move and rename proc_macro::tracked_{env::var,path::path} 2025-11-26 22:44:25 +01:00
rustc_fs_util Avoid using env::temp when linking a binary 2025-12-24 06:41:42 +00:00
rustc_graphviz change non-canonical clone impl to {*self}, fix some doc comments 2025-12-20 13:46:22 +00:00
rustc_hashes some cleanups in compiler 2025-10-12 08:08:30 +00:00
rustc_hir Rollup merge of #151082 - issue-141403, r=Kivooeo 2026-01-15 19:35:47 -05:00
rustc_hir_analysis Rollup merge of #151082 - issue-141403, r=Kivooeo 2026-01-15 19:35:47 -05:00
rustc_hir_id
rustc_hir_pretty Introduce hir::ConstArgKind::Array 2026-01-10 12:41:50 +09:00
rustc_hir_typeck Rollup merge of #150979 - typeck-pat, r=lcnr 2026-01-15 21:39:03 +11:00
rustc_incremental Implement incremental caching for derive macro expansions 2026-01-16 07:36:36 +01:00
rustc_index layout: Store inverse memory index in FieldsShape::Arbitrary 2025-12-18 22:25:34 +01:00
rustc_index_macros Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_infer Use the name var_kinds more. 2026-01-08 13:37:34 +11:00
rustc_interface Implement incremental caching for derive macro expansions 2026-01-16 07:36:36 +01:00
rustc_lexer lexer/parser: ensure deps use the same unicode version 2025-12-27 11:20:42 +01:00
rustc_lint Auto merge of #151056 - mejrs:do_not_recommend, r=JonathanBrouwer 2026-01-15 19:35:19 +00:00
rustc_lint_defs Auto merge of #151056 - mejrs:do_not_recommend, r=JonathanBrouwer 2026-01-15 19:35:19 +00:00
rustc_llvm Rollup merge of #150511 - Sa4dUs:offload-inline, r=ZuseZ4 2025-12-31 14:30:48 +01:00
rustc_log Restrict sysroot crate imports to those defined in this repo. 2025-10-15 13:17:25 +01:00
rustc_macros Rollup merge of #149400 - Skgland:tracked_mod, r=Amanieu 2025-12-09 17:36:48 +01:00
rustc_metadata Rollup merge of #151096 - rm-providers-deref, r=oli-obk 2026-01-14 11:05:42 +01:00
rustc_middle Rollup merge of #145354 - cache-proc-derive-macros, r=petrochenkov 2026-01-16 13:57:45 +01:00
rustc_mir_build Also remove pat_ty from TestKind::ScalarEq 2026-01-16 12:21:48 +11:00
rustc_mir_dataflow Clarify MoveData::init_loc_map. 2026-01-02 09:29:26 +11:00
rustc_mir_transform Auto merge of #150925 - dianqk:if-cmp, r=saethlin 2026-01-15 23:54:21 +00:00
rustc_monomorphize Remove Deref/DerefMut impl for Providers. 2026-01-14 15:55:59 +11:00
rustc_next_trait_solver Auto merge of #150859 - nnethercote:opt-Canonicalizer-flag-checks, r=lcnr 2026-01-13 17:36:45 +00:00
rustc_parse Rollup merge of #151099 - issue-84327-2, r=fmease 2026-01-14 22:30:00 +01:00
rustc_parse_format rustc_parse_format: improve diagnostics for unsupported python numeric grouping 2026-01-11 23:42:38 +05:30
rustc_passes Auto merge of #151056 - mejrs:do_not_recommend, r=JonathanBrouwer 2026-01-15 19:35:19 +00:00
rustc_pattern_analysis THIR patterns: Always use type str for string-constant-value nodes 2026-01-16 12:17:48 +11:00
rustc_privacy Unify the configuration of the compiler docs 2025-11-05 11:25:27 +00:00
rustc_proc_macro Update literal-escaper version to 0.0.7 2026-01-08 14:10:33 +01:00
rustc_public Auto merge of #148766 - cjgillot:mir-const-runtime-checks, r=RalfJung,saethlin 2025-12-22 06:58:28 +00:00
rustc_public_bridge Overhaul filename handling for cross-compiler consistency 2025-12-12 07:33:09 +01:00
rustc_query_impl Lock shards while collecting active jobs. 2025-11-14 09:01:22 +08:00
rustc_query_system Implement incremental caching for derive macro expansions 2026-01-16 07:36:36 +01:00
rustc_resolve Auto merge of #150982 - petrochenkov:modsplitfast2, r=JonathanBrouwer 2026-01-15 16:16:17 +00:00
rustc_sanitizers Port #[cfi_encoding] to attribute parser 2025-12-21 22:11:33 +01:00
rustc_serialize Allow internal_features lint in doc tests 2025-11-05 11:25:29 +00:00
rustc_session Implement incremental caching for derive macro expansions 2026-01-16 07:36:36 +01:00
rustc_span Rollup merge of #145354 - cache-proc-derive-macros, r=petrochenkov 2026-01-16 13:57:45 +01:00
rustc_symbol_mangling refactor destructure_const 2025-12-28 16:12:27 +00:00
rustc_target Rollup merge of #150966 - arch-powerpc64le, r=petrochenkov 2026-01-14 22:29:57 +01:00
rustc_thread_pool change non-canonical clone impl to {*self}, fix some doc comments 2025-12-20 13:46:22 +00:00
rustc_trait_selection Rollup merge of #151082 - issue-141403, r=Kivooeo 2026-01-15 19:35:47 -05:00
rustc_traits add const_of_item query and use it in normalization 2025-11-08 13:50:47 -05:00
rustc_transmute Clean up src/dst transmute mess. 2026-01-12 09:22:58 +11:00
rustc_ty_utils Remove redundant call to erase_and_anonymize_regions. 2026-01-12 09:22:58 +11:00
rustc_type_ir Rollup merge of #150861 - folding-cleanups, r=lcnr 2026-01-12 13:32:07 +01:00
rustc_type_ir_macros Provide an extended framework for type visit, for use in rust-analyzer 2025-12-16 01:47:28 +02:00
rustc_windows_rc [win] Use find-msvc-tools instead of cc to find the linker and rc on Windows 2025-09-19 12:00:30 -07:00