Commit graph

1391 commits

Author SHA1 Message Date
Chayim Refael Friedman
1c8a07cfd6 Cache trait solving across queries in the same revision
Caching trait solving can do a lot to speed. Unfortunately it also consume a huge amount of memory. Therefore, as part of the migration to the new solver Jack Huey disabled caching of trait solving (he made the query transparent).

The PR proposes a middle ground: do cache trait solving, but only for the same revision. This allows us to be safe because during a revision the inputs cannot change.

The result is hopefully much better performance to features that tend to do a bulk of trait solving, and also repeat the same query (e.g. inference then IDE features).

There is another limitation: results are only cached in the same thread, to remove the need for synchronization which will be expensive. More measurements are required to check whether it's better to use a synchronized global cache, or maybe stay with a thread-local cache but batch multiple feature requests (highlighting, inlay hints etc.) of the same file to the same thread.

Alongside the actual cache we store the revision, because we need to verify it (we can't eagerly clear caches when incrementing the revision), and also the address of the db to prevent multiple dbs from interleaving (this is mostly relevant in tests, although injected highlighting also uses a new db, therefore maybe it's better to move it to a separate thread).

This "games" analysis-stats to both be way faster and use way more memory; the former is because analysis-stats doesn't increment revisions, therefore all queries share the cache and hit ratio is way too good, the latter is because analysis-stats doesn't increment revisions and therefore the cache isn't cleared. Both are not representative of a typical IDE scenario.
2025-08-25 17:17:31 +03:00
Shoyu Vanilla
15ac6a21dd fix: Make lang items query properly filter out overwritten/excluded sysroots 2025-08-17 22:28:04 +09:00
Deadbeef
d9f67325ab fix errors after rebase 2025-08-13 15:33:08 +08:00
Deadbeef
82f174fbd9 Merge Trait and TraitAlias handling 2025-08-13 15:28:08 +08:00
jackh726
9418a3f2df Implement next trait solver 2025-08-09 16:08:58 +00:00
Lukas Wirth
8ce30264c8 cargo clippy --fix 2025-07-31 10:55:10 +02:00
Lukas Wirth
97593ea9c6
Merge pull request #20289 from ChayimFriedman2/expr-store-diags-macros
internal: Remove `ExpressionStoreDiagnostics::MacroError`, instead recreate it from the `MacroCallId`
2025-07-23 13:58:10 +00:00
Chayim Refael Friedman
963a1317e7 Remove ExpressionStoreDiagnostics::MacroError, instead recreate it from the MacroCallId
This simplifies the code and also makes us report parse error in macros too.
2025-07-23 16:27:07 +03:00
Chayim Refael Friedman
c7ceb39f67 Parse for<'a> [const]
And also refactor parsing of HRTB.
2025-07-22 16:24:42 +03:00
John Paul Adrian Glaubitz
25122d9289 hir-def: Don't apply x86_64-specific asserts on x32
This fixes the rustc build on x32 for which struct sizes differ.
2025-07-21 17:03:07 +02:00
Chayim Refael Friedman
b1914e420f Support cfg_select! 2025-07-20 11:56:45 +03:00
Andrey Nikolaev
2b861a7410
remove now useless [allow(unused_lifetimes)] 2025-07-13 05:43:05 -04:00
Chayim Refael Friedman
4b29a9d6ea
Merge pull request #20219 from ChayimFriedman2/expr-store-mem
Some checks are pending
metrics / build_metrics (push) Waiting to run
metrics / generate_final_metrics (push) Blocked by required conditions
metrics / other_metrics (diesel-1.4.8) (push) Blocked by required conditions
metrics / other_metrics (hyper-0.14.18) (push) Blocked by required conditions
metrics / other_metrics (ripgrep-13.0.0) (push) Blocked by required conditions
metrics / other_metrics (self) (push) Blocked by required conditions
metrics / other_metrics (webrender-2022) (push) Blocked by required conditions
rustdoc / rustdoc (push) Waiting to run
perf: Put the expression stuff in the expression store behind an `Option<Box>`
2025-07-11 14:25:39 +00:00
Shoyu Vanilla (Flint)
e9968fc555
Merge pull request #20210 from ChayimFriedman2/naked-asm-safe
fix: Inline asm fixes
2025-07-10 06:28:49 +00:00
Chayim Refael Friedman
ad708fdbd1 Put the expression stuff in the expression store behind an Option<Box>
And leave only the type stuff without it.

This is because most expression stores don't have anything but types (e.g. generics, fields, signatures) so this saves a lot of memory.

This saves 58mb on `analysis-stats .`.
2025-07-10 05:18:43 +03:00
Chayim Refael Friedman
95c04c4503 Make global_asm!() work
Because apparently, we were not accepting inline asm in item position, completely breaking it.
2025-07-09 18:55:27 +03:00
Chayim Refael Friedman
bd8087e86e Differentiate between asm!(), global_asm!() and naked_asm!(), and make only asm!() unsafe 2025-07-09 17:37:27 +03:00
Chayim Refael Friedman
edb804a100 Don't hash the SyntaxKind in the ast id
There is no need to, it's already stored in the `kind`.
2025-07-09 17:21:45 +03:00
Chayim Refael Friedman
87cddda2d8 Always bump in the parser in err_and_bump()
Even when at curly braces, otherwise the parser can get stuck.

This has happened in the past in #18625, but it was just worked around instead of handling the root of the problem. Now this happened again in #20171. IMO we can't let `err_and_bump()` not bump, that's too confusing and invites errors. We can (as I did) workaround the worse recovery instead.
2025-07-06 03:21:43 +03:00
Lukas Wirth
638e49b0fc Skip unnecessary eq work in BodySourceMap 2025-07-04 11:36:06 +02:00
Chayim Refael Friedman
9c4a7705b1 Fix some things with builtin derives
1. Err on unions on derive where it's required.
 2. Err on `#[derive(Default)]` on enums without `#[default]` variant.
 3. Don't add where bounds `T: Default` when expanding `Default` on enums (structs need that, enums not).

Also, because I was annoyed by that, in minicore, add a way to filter on multiple flags in the line-filter (`// :`). This is required for the `Debug` and `Hash` derives, because the derive should be in the prelude but the trait not.
2025-07-03 23:05:56 +03:00
Lukas Wirth
8029c731ed Bump salsa 2025-07-03 10:05:16 +02:00
Chayim Refael Friedman
a6c1fa01d9
Merge pull request #20100 from ShoyuVanilla/ignore-sized-hierarchy
Some checks are pending
metrics / build_metrics (push) Waiting to run
metrics / other_metrics (diesel-1.4.8) (push) Blocked by required conditions
metrics / other_metrics (hyper-0.14.18) (push) Blocked by required conditions
metrics / other_metrics (ripgrep-13.0.0) (push) Blocked by required conditions
metrics / other_metrics (self) (push) Blocked by required conditions
metrics / other_metrics (webrender-2022) (push) Blocked by required conditions
metrics / generate_final_metrics (push) Blocked by required conditions
rustdoc / rustdoc (push) Waiting to run
Backport new sized-hierarchy trait bounds in old ways
2025-06-26 20:37:18 +00:00
Shoyu Vanilla
953e9d1c36 Backport new sized-hierarchy trait bounds in old ways 2025-06-26 23:22:26 +09:00
Lukas Wirth
468726178f Bring back the firewall query 2025-06-26 14:12:57 +02:00
Lukas Wirth
889d84a1be Salsa idiomize VariantFields query 2025-06-26 12:55:55 +02:00
Lukas Wirth
ad3a2d7280
Merge pull request #20088 from Veykril/push-qrslvzzlqqoz
De-arc trait items query
2025-06-25 08:19:32 +00:00
Lukas Wirth
f25912c6f9 De-arc trait items query 2025-06-25 10:09:21 +02:00
Lukas Wirth
c43e7c71de Short circuit a couple hir-ty/lower queries 2025-06-24 20:04:43 +02:00
Lukas Wirth
95dce2be51
Merge pull request #20062 from ChayimFriedman2/doctests
minor: Don't run doctests
2025-06-24 06:47:24 +00:00
Shoyu Vanilla
254c6ec8e1 fix: Use ROOT hygiene for args inside new format_args! expansion 2025-06-24 01:10:32 +09:00
Chayim Refael Friedman
de312d0c71 Don't run doctests 2025-06-23 00:50:22 +03:00
Shoyu Vanilla
4f8767d790 Minic rustc's new format_args! expansion 2025-06-22 13:22:28 +09:00
Lukas Wirth
6301c35cf3 Revert "Turn BlockId into a #[salsa::tracked]"
This reverts commit 8643a858db.
2025-06-19 07:40:01 +02:00
Chayim Refael Friedman
a207299344
Merge pull request #20000 from tadeokondrak/lifetime-repeat-macro
Some checks failed
metrics / build_metrics (push) Waiting to run
metrics / other_metrics (diesel-1.4.8) (push) Blocked by required conditions
metrics / other_metrics (hyper-0.14.18) (push) Blocked by required conditions
metrics / other_metrics (ripgrep-13.0.0) (push) Blocked by required conditions
metrics / other_metrics (self) (push) Blocked by required conditions
metrics / other_metrics (webrender-2022) (push) Blocked by required conditions
metrics / generate_final_metrics (push) Blocked by required conditions
rustdoc / rustdoc (push) Waiting to run
autopublish / publish (push) Has been cancelled
release / dist (aarch64-apple-darwin) (push) Has been cancelled
release / dist (x86_64-apple-darwin) (push) Has been cancelled
release / dist (aarch64-unknown-linux-gnu) (push) Has been cancelled
release / dist (arm-unknown-linux-gnueabihf) (push) Has been cancelled
release / dist (x86_64-unknown-linux-gnu) (push) Has been cancelled
release / dist (aarch64-pc-windows-msvc) (push) Has been cancelled
release / dist (x86_64-pc-windows-msvc) (push) Has been cancelled
release / dist (i686-pc-windows-msvc) (push) Has been cancelled
release / dist (x86_64-unknown-linux-musl) (push) Has been cancelled
release / publish (push) Has been cancelled
Allow lifetime repeats in macros: $($x)'a*
2025-06-15 16:34:42 +00:00
Tadeo Kondrak
2070e9a8f3 Use is_any_identifier in pretty_print_macro_expansion 2025-06-15 18:23:18 +02:00
Tadeo Kondrak
12226b704a Fix spacing for LIFETIME_IDENT near keywords and literals in test output 2025-06-15 17:43:45 +02:00
Lukas Wirth
b3768cdc0e Optimize private visibility resolution 2025-06-15 10:25:45 +02:00
Lukas Wirth
e129cdc202 Optimize pub(crate) visibility resolution 2025-06-15 10:25:45 +02:00
Lukas Wirth
4b38ea5abd Unify assoc item visibility queries 2025-06-15 10:01:34 +02:00
Lukas Wirth
bceeb6a3c7 Idiomatic salsa use for extern block abi query 2025-06-15 10:01:04 +02:00
Lukas Wirth
4e392f82cb Idiomatic salsa use for impl items query 2025-06-15 09:40:02 +02:00
Lukas Wirth
155ef3de60 Replace unnecessary use of MacroDefId with MacroId 2025-06-15 09:16:45 +02:00
Lukas Wirth
aa2d234426 Idiomatic salsa use for enum variants query 2025-06-15 09:03:44 +02:00
Lukas Wirth
f68512af65 Cleanup incremental tests 2025-06-15 08:07:49 +02:00
Tadeo Kondrak
a7c09532a0 Allow lifetime repeats in macros: $($x)'a*
This works in rustc. This change isn't motivated by any real code.
I just learned about it and decided to see why it doesn't work with
rust-analyzer.
2025-06-13 18:13:01 -06:00
Lukas Wirth
8643a858db Turn BlockId into a #[salsa::tracked] 2025-06-13 17:30:04 +02:00
Lukas Wirth
9f051ee104 Use ThinVec in ItemScope in a couple places 2025-06-13 15:34:03 +02:00
Lukas Wirth
b9ce647cf1 Bring back EMPTY item tree deduplication 2025-06-13 14:51:23 +02:00
Lukas Wirth
bd002fe65c
Merge pull request #19982 from Veykril/push-uptnmqtlylsx
Simplify and optimize `ItemTree`
2025-06-13 11:16:24 +00:00