-
Notifications
You must be signed in to change notification settings - Fork 563
Refinement of Providers into Providers and ExternProviders #2469
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
base: main
Are you sure you want to change the base?
Conversation
|
first commit for |
This comment has been minimized.
This comment has been minimized.
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn> Co-authored-by: Boxy <rust@boxyuwu.dev>
0997ff5 to
72110fd
Compare
| #### Adding a new provider | ||
|
|
||
| Suppose you want to add a new query called `fubar`. You would: | ||
| Suppose you want to add a new query called `fubar`. This section focuses on wiring up the providers; for how to declare the query itself in the big `rustc_queries!` macro, see [Adding a new query](#adding-a-new-query) below. |
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.
Here, I add some explanations to hint that how to add a query is put below.
| 1. Decide which crate "owns" the query (for example `rustc_hir_analysis`, `rustc_mir_build`, or another `rustc_*` crate). | ||
| 2. In that crate, look for an existing `provide` function: | ||
| ```rust,ignore | ||
| pub fn provide(providers: &mut query::Providers) { | ||
| // existing assignments | ||
| } | ||
| ``` | ||
| If it exists, you will extend it to set the field for your new query. If the crate does not yet have a `provide` function, add one and make sure it is included in `DEFAULT_QUERY_PROVIDERS` in the `rustc_interface` crate so that it actually gets called during initialization (see the discussion above). |
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.
Some more deatils: if there is a existing..., else ...
|
@rustbot ready |
Refined some vague concepts and pseudo-code in Query System
In the past, we only used vague concepts like local and extern to differentiate between different queries. however the code has more detailed
ProvidersandExternProvidersto differentiate between them, so we should mention both of them in the documentation as well.It is also important to indicate that
rustc_middle::util::Providersis made up ofProvidersandExternProvidersin the query mod.This PR also updates the example of registering a new Provider to consider
ExternProviders.r? @tshepang