fix: Always cache macro expansions' root node in Semantics#18117
fix: Always cache macro expansions' root node in Semantics#18117bors merged 1 commit intorust-lang:masterfrom
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.
this idea behind this is to inline setting both to prevent mismatches, right?
There was a problem hiding this comment.
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.