-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix: Always cache macro expansions' root node in Semantics #18117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Previously some expansions were not cached, but were cached in the expansion cache, which caused panics when later queries tried to lookup the node from the expansion cache.
2c9c45c
to
35e171a
Compare
pub(super) fn get_or_insert_expansion( | ||
&mut self, | ||
sema: &SemanticsImpl<'_>, | ||
macro_file: MacroFileId, | ||
) -> &ExpansionInfo { | ||
self.expansion_info_cache.entry(macro_file).or_insert_with(|| { | ||
let exp_info = macro_file.expansion_info(sema.db.upcast()); | ||
|
||
let InMacroFile { file_id, value } = exp_info.expanded(); | ||
sema.cache(value, file_id.into()); | ||
|
||
exp_info | ||
}) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this idea behind this is to inline setting both to prevent mismatches, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Without this it's only matter of time until the next panic; this ensures panic of this form will never come again.
Thanks! |
☀️ Test successful - checks-actions |
1 similar comment
☀️ Test successful - checks-actions |
👀 Test was successful, but fast-forwarding failed: 422 Changes must be made through a pull request. |
☔ The latest upstream changes (presumably #18117) made this pull request unmergeable. Please resolve the merge conflicts. |
What? That's this pull request 😕 |
Previously some expansions were not cached, but were cached in the expansion cache, which caused panics when later queries tried to lookup the node from the expansion cache.
Fixes #18089.