diff options
| author | Jacob Pratt <jacob@jhpratt.dev> | 2025-07-04 05:47:28 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-04 05:47:28 +0200 |
| commit | 9852aceb4fa6d8cadc338003c1cdf0b8246cc733 (patch) | |
| tree | c4b0bbbc029619cd6c14fb3e6e1d9a693db893a7 /compiler/rustc_pattern_analysis/src | |
| parent | 01fe1c0b0eae46a168fa8f81cc9001bf2c37a8f7 (diff) | |
| parent | 3b7f9f9d1b75cb98d8bd09cdedf2ded13283abf8 (diff) | |
| download | rust-9852aceb4fa6d8cadc338003c1cdf0b8246cc733.tar.gz rust-9852aceb4fa6d8cadc338003c1cdf0b8246cc733.zip | |
Rollup merge of #143394 - workingjubilee:reorganize-hir-analysis-provide-fn, r=compiler-errors
compiler: Document and reduce `fn provide`s in hir crates I found it hard to follow all these tiny micro-indirections. Much like you shouldn't pass around `&u32` if you can help it, you probably shouldn't use an indirection if the indirection overhead itself is literally bigger than the amount of data you are organizing. Generally a new `fn provide` amounts to around 3 LOC: - the signature with opening brace - the `rustc_middle::query::Providers` import - an end brace I am not even counting the cost in time and thought to go find the other `provide`, read it, understand, "Ah, yes, these functions", and then go to those. Thus I say we should collapse indirections of `provide` for modules that only export 1~2 queries. For higher-count indirections, I left them as-is, as I don't understand the crate well enough to judge their worth. Then I dropped a pointer to the actual module of interest for all these instances of the same function. I think documenting them is important because the comment that it relates to the query system makes it obvious that they have **nothing** to do with the rest of the module's logic and I can carry on ignoring them. Actively doing so is another cognitive cost, but much more minimal. There is also a small correctness issue in that all of these functions are technically mutating state. It's not a huge deal, but it's still easier to check all these mutations do not overlap if we have less instances of `fn provide` to check.
Diffstat (limited to 'compiler/rustc_pattern_analysis/src')
0 files changed, 0 insertions, 0 deletions
