rust-lang / rust-lang/rustc-dev-guide
Instructions for adding a new query
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 1.9k
- Forks
- 613
- Avg merge
- 17h 24m
- Merged PRs (30d)
- 39
Description
Summary of issue
We have a good start on documenting adding a new query: https://rustc-dev-guide.rust-lang.org/query.html#adding-a-new-kind-of-query. However, I think there's room for greater clarity.
☞ After reading this section, I know where to define a query. I want to know where and how to implement one.
Details
Currently, this section of the guide has two summaries of the process:
So suppose you want to add a new kind of query, how do you do so? Well, defining a query takes place in two steps:
- first, you have to specify the query name and arguments; and then,
- you have to supply query providers where needed.
and
So, to add a query:
- Add an entry to
rustc_queries!using the format above.- Link the provider by modifying the appropriate
providemethod; or add a new one if needed and ensure thatrustc_driveris invoking it.
Where are these providers?
How do I find "the appropriate provide method" for a new query? Do I always need to create a new one for a new query? Or can I sometimes reuse ("modify") an existing one?
The section immediately before this one gives information on Providers, but does not say how to add a new one.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the adding-a-new-kind-of-query and Providers sections of query.html, then trace the rustc_queries! entry, provider methods, and rustc_driver invocation mentioned there. Update the guide to identify provider locations and explain when to modify an existing provide method versus add one, including how to ensure it is invoked.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers, documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100