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.
Expansion-driven outline module parsing #69838
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
Expansion-driven outline module parsing #69838
Changes from all commits
bc75cba
2899a58
185c1d3
2db5d49
803de31
7108b7f
dfcefa4
ca098b1
53a633f
98e71cd
b9e1b26
8bab88f
463995f
59bf8a0
83a757a
f1ca996
ddcc8ec
3796fae
31ee8e0
a6cb04f
7d0e5bb
fe71342
41a0b3e
5ee4f6f
e301291
8caf688
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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 apparently broke Servo's
script
crate, or at least the copy on perf.rust-lang.org.cc @Mark-Simulacrum can you post some details?
IIUC, this can't be fixed locally either, because the
mod bar;
parsed byinclude!("directory/included.rs");
will be expanded later, so for expandingmod bar;
to loaddirectory/bar.rs
(which is apparently the old behavior? how are we not testing for it), we'd need to detect that aninclude!
happened, or something similar.EDIT: adjusted example to fit @Mark-Simulacrum's reproduction.
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.
cc @petrochenkov
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 is a minimal reproduction:
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.
I've just recalled a related issue - #58818.
Could you check whether this PR fixed it?
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.
FWIW, we have
Definitions::expansions_that_defined
that can link from themod bar;
item to the macro that produced it. Then we haveExpnData::parent
that can link from that macro to the macro that produced it (recursively).Perhaps using these data we can hack up something reproducing the old behavior.
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.
We can only detect
include
comparing the macro's name inExpnData
withsym::include
.fn expansion_cause
used in for a bunch of various stuff also hard-codes the nameinclude
like this, so it should be ok for now.(The proper fix is a flag in
struct SyntaxExtension
, other file-including built-in macros should have it as well.)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.
@petrochenkov So I tried two different approaches to set
ownership
before loading the external module. The first one was addingIncovation::is_current_expansion_macro_named
defined like so:and then using it in
flat_map_item
beforeparse_external_mod
happens:The log message here does trigger on @Mark-Simulacrum's regression test, but this doesn't fix the issue.
I also tweaked
SyntaxExtension
, adding a flagfoobar: bool
which is used infully_expand_fragment
:and which is set in
compile_macro
:The log message also triggers here, but also does nothing to fix the issue, as the approach is the same as the other mechanism.
I'm not sure why it doesn't work. :(
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.
Found a fix, PR up at #70184.