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
provide
method; or add a new one if needed and ensure thatrustc_driver
is 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.