Skip to content
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

Use a single function for query manipulations #77833

Closed
wants to merge 10 commits into from
6 changes: 3 additions & 3 deletions compiler/rustc_macros/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,11 +500,11 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
::rustc_middle::dep_graph::DepKind::#name => {
if <#arg as DepNodeParams<TyCtxt<'_>>>::can_reconstruct_query_key() {
if let Some(key) = <#arg as DepNodeParams<TyCtxt<'_>>>::recover($tcx, $dep_node) {
force_query::<crate::ty::query::queries::#name<'_>, _>(
call_query::<crate::ty::query::queries::#name<'_>, _>(
$tcx,
key,
DUMMY_SP,
*$dep_node
key,
QueryCaller::Force(*$dep_node),
);
return true;
}
Expand Down
17 changes: 14 additions & 3 deletions compiler/rustc_middle/src/ty/query/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ macro_rules! define_queries_inner {
// HACK(eddyb) this is like the `impl QueryConfig for queries::$name`
// below, but using type aliases instead of associated types, to bypass
// the limitations around normalizing under HRTB - for example, this:
// `for<'tcx> fn(...) -> <queries::$name<'tcx> as QueryConfig<TyCtxt<'tcx>>>::Value`
// `for<'tcx> fn(...) -> <queries::$name<'tcx> as QueryConfig>::Value`
// doesn't currently normalize to `for<'tcx> fn(...) -> query_values::$name<'tcx>`.
// This is primarily used by the `provide!` macro in `rustc_metadata`.
#[allow(nonstandard_style, unused_lifetimes)]
Expand Down Expand Up @@ -413,7 +413,12 @@ macro_rules! define_queries_inner {
$($(#[$attr])*
#[inline(always)]
pub fn $name(self, key: query_helper_param_ty!($($K)*)) {
ensure_query::<queries::$name<'_>, _>(self.tcx, key.into_query_param())
call_query::<queries::$name<'_>, _>(
self.tcx,
DUMMY_SP,
key.into_query_param(),
QueryCaller::Ensure,
);
})*
}

Expand Down Expand Up @@ -496,7 +501,13 @@ macro_rules! define_queries_inner {
pub fn $name(self, key: query_helper_param_ty!($($K)*))
-> <queries::$name<$tcx> as QueryConfig>::Stored
{
get_query::<queries::$name<'_>, _>(self.tcx, self.span, key.into_query_param())
let ret = call_query::<queries::$name<'_>, _>(
self.tcx,
self.span,
key.into_query_param(),
QueryCaller::Get,
);
ret.unwrap()
})*
}

Expand Down
Loading