fix: Failed to lookup MACRO_CALL@... in this Semantics due to include! - #22933
Conversation
| let InMacroFile { file_id, value } = exp_info.expanded(); | ||
| Self::cache(&mut self.root_to_file_cache, value, file_id.into()); | ||
|
|
||
| // Ensure that the cache contains syntax nodes from the macro call site. |
There was a problem hiding this comment.
The problem is not in this method. The problem is in whatever calls it but doesn't have the macro node in the Semantics.
There was a problem hiding this comment.
This is actually specific to include! I think, because its arg is a different file than the macro call resides in
There was a problem hiding this comment.
Aha, yep, all the crashes I can see were with include!().
I've rewritten the comments accordingly and added an explicit if macro_file.is_include_macro(db) check to make this explicit.
There was a problem hiding this comment.
yea that seems like the better solution for now
SemanticsImpl::find_file assumes that its caches always contain the file that
has the current SyntaxNode.
For macros `foo!()` we only have two files to worry about: the macro
call site and the macro definition site. Hoewver, for
include!("foo.rs") we also need to consider the included file.
Ensure that the file cache is consistently populated for include!()
invocations macro expansion, and add a test.
AI disclosure: GPT-5.5 used to minimise a repro from a real project
and write the initial implementation. Comments and commit message are
entirely mine.
5af94fb to
0c11196
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
SemanticsImpl::find_file assumes that its caches always contain the file that
has the current SyntaxNode.
For macros
foo!()we only have two files to worry about: the macrocall site and the macro definition site. Hoewver, for
include!("foo.rs")we also need to consider the included file.Ensure that the file cache is consistently populated for
include!()invocations macro expansion, and add a test.
AI disclosure: GPT-5.5 used to minimise a repro from a real project
and write the initial implementation. Comments and commit message are
entirely mine.