internal: move ExpandDatabase::proc_macros out of the query group#22641
Closed
ada4a wants to merge 3 commits into
Closed
internal: move ExpandDatabase::proc_macros out of the query group#22641ada4a wants to merge 3 commits into
ExpandDatabase::proc_macros out of the query group#22641ada4a wants to merge 3 commits into
Conversation
ada4a
commented
Jun 25, 2026
Comment on lines
-93
to
+104
| ProcMacros(map) | ||
| ProcMacros::try_get(db) | ||
| .unwrap_or_else(|| ProcMacros::new(db, Default::default())) | ||
| .set_by_crate(db) | ||
| .with_durability(durability) | ||
| .to(map); |
Contributor
Author
There was a problem hiding this comment.
The reason for this ugliness is twofold:
- I can't just do
ProcMacros::builder(map).durability(durability).new(db), becauseProcMacrosis marked as a singleton, and salsa complains (panics) if I create a new instance of it. - I can't just use
ProcMacros::get, because some tests panic with "Option::unwrapcalled onNone", which I assume means thatProcMacrosis sometimes not yet set by the time we call this method.
Let me know if I should add this justification as a comment to the code maybe
Veykril
reviewed
Jun 26, 2026
| set_all_crates_with_durability(&mut db, std::iter::empty(), Durability::HIGH); | ||
| CrateGraphBuilder::default().set_in_db(&mut db); | ||
| db.set_proc_macros_with_durability(Default::default(), Durability::MEDIUM); | ||
| _ = hir::ProcMacros::builder(Default::default()).durability(Durability::MEDIUM).new(&db); |
Member
There was a problem hiding this comment.
I think we can expose another function on ProcMacros here like init_default(&db, Durability::MEDIUM) or so, otherwise looks good to me
b0001bf to
f10b773
Compare
f10b773 to
5b8cf1a
Compare
Contributor
Author
|
Moved into #22639 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This required several non-trivial changes:
ProcMacros::gettoProcMacros::get_for_crate(feel free to suggest a better name), to avoid clashing with the new getter created by salsa.ProcMacroBuilder::buildto takedbanddurability, as it will need to buildProcMacrosinside the db. Also rename it tobuild_in, to reflect the change in functionality.ProcMacrosis now stored in the database directly, instead of being wrapped in anArc. This should be fine though, since itsby_cratefield is marked with#[returns(ref)].@rustbot blocked on #22639, but mostly for easier rebasing later
cc @Veykril