-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
[Draft] Move query definitions into rustc_query_system
#78275
[Draft] Move query definitions into rustc_query_system
#78275
Conversation
…directly for DepKind.
…raph and DepNodeData now use DepKind instead of `<K: DepKindExt>`
r? @oli-obk (rust_highfive has picked a reviewer for you, use r? to override) |
@rustbot modify labels: +A-query-system +I-compiletime +T-compiler |
This will have no effect, |
macro_rules! query_description_stream { | ||
// capture all needed `use` statements. | ||
($($uses:tt)*) => { | ||
$($uses)* |
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.
You can surround thins expansion by an ad-hoc module to avoid polluting the namespace.
FWIW, when I created |
I currently don't have much time to work on this, so I'll close it for now. |
FWIW, the proc macro takes 350ms to execute. |
... and out of
rustc_middle
, to improve bootstrap times. (cc #65031)The goal here is to allow future simplifications of the query system, and to make
rustc_middle
smaller, so thatx.py check
andx.py build
is more parallel.The important part are the first two commits:
The query definitions in the
rustc_queries!
proc macro generates severalmacro_rules
macros that are invoked in different parts ofrustc_middle
. The change here is that one of them,query_description_stream!
, now gets all the neededuse
statements as an input, rather than relying that they are defined at the top of the file. This makes it possible to move the query definitions intorustc_query_system
although types likeHirId
orDefId
aren't available there.The rest of this PR demonstrates one simplification that this schema enables:
DepKind
doesn't depend on the query parameter types that are not accessible inrustc_query_system
, so one of the macros generated byrustc_queries!
can be invoked inrustc_query_system
directly to generate theDepKind
enum. This enables removing (most of) theDepKind
trait and thus removing the generic argument in a bunch of places. (Basically every<D>
in #77871.) This doesn't fully work yet, because eg.DepKind::debug
needs the globalImplicitTyCxt
.I guess this is an alternative approach to #70951, or maybe a first step to that. (My next todo is reading that PR.) CC rust-lang/compiler-team#277
Can I get your opinions on this approach, @cjgillot and maybe @eddyb and @oli-obk ? Is this a direction worth pursuing?
This PR is more a proof-of-concept and needs cleanup:
git move
on the query definitions file to not lose historyrustc_queries!
takes, so we know the actual improvement here.