Skip to content

Instructions for adding a new query #1299

Open

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:

  1. first, you have to specify the query name and arguments; and then,
  2. you have to supply query providers where needed.

and

So, to add a query:

  1. Add an entry to rustc_queries! using the format above.
  2. Link the provider by modifying the appropriate provide method; or add a new one if needed and ensure that rustc_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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions