mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Rollup merge of #153009 - nnethercote:rm-define_feedable, r=oli-obk
Remove `rustc_feedable_queries` and `define_feedable` macros. The can be folded into `rustc_with_all_queries` and `define_callbacks`. Details in individual commits. r? @oli-obk
This commit is contained in:
@@ -399,7 +399,6 @@ pub(super) fn rustc_queries(input: TokenStream) -> TokenStream {
|
||||
|
||||
let mut query_stream = quote! {};
|
||||
let mut helpers = HelperTokenStreams::default();
|
||||
let mut feedable_queries = quote! {};
|
||||
let mut analyzer_stream = quote! {};
|
||||
let mut errors = quote! {};
|
||||
|
||||
@@ -480,10 +479,6 @@ fn #name(#key_ty) #return_ty,
|
||||
feedable.span(),
|
||||
"Query {name} cannot be both `feedable` and `eval_always`."
|
||||
);
|
||||
feedable_queries.extend(quote! {
|
||||
[#modifiers_stream]
|
||||
fn #name(#key_ty) #return_ty,
|
||||
});
|
||||
}
|
||||
|
||||
add_to_analyzer_stream(&query, &mut analyzer_stream);
|
||||
@@ -514,11 +509,6 @@ macro_rules! rustc_with_all_queries {
|
||||
}
|
||||
}
|
||||
}
|
||||
macro_rules! rustc_feedable_queries {
|
||||
( $macro:ident! ) => {
|
||||
$macro!(#feedable_queries);
|
||||
}
|
||||
}
|
||||
|
||||
// Add hints for rust-analyzer
|
||||
mod _analyzer_hints {
|
||||
|
||||
@@ -825,7 +825,7 @@
|
||||
/// Returns the explicitly user-written *predicates* of the definition given by `DefId`
|
||||
/// that must be proven true at usage sites (and which can be assumed at definition site).
|
||||
///
|
||||
/// You should probably use [`Self::predicates_of`] unless you're looking for
|
||||
/// You should probably use [`TyCtxt::predicates_of`] unless you're looking for
|
||||
/// predicates with explicit spans for diagnostics purposes.
|
||||
query explicit_predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> {
|
||||
desc { "computing explicit predicates of `{}`", tcx.def_path_str(key) }
|
||||
@@ -2780,4 +2780,3 @@
|
||||
}
|
||||
|
||||
rustc_with_all_queries! { define_callbacks! }
|
||||
rustc_feedable_queries! { define_feedable! }
|
||||
|
||||
@@ -383,6 +383,17 @@ macro_rules! if_return_result_from_ensure_ok {
|
||||
};
|
||||
}
|
||||
|
||||
// Expands to `$item` if the `feedable` modifier is present.
|
||||
macro_rules! item_if_feedable {
|
||||
([] $($item:tt)*) => {};
|
||||
([(feedable) $($rest:tt)*] $($item:tt)*) => {
|
||||
$($item)*
|
||||
};
|
||||
([$other:tt $($modifiers:tt)*] $($item:tt)*) => {
|
||||
item_if_feedable! { [$($modifiers)*] $($item)* }
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! define_callbacks {
|
||||
(
|
||||
// You might expect the key to be `$K:ty`, but it needs to be `$($K:tt)*` so that
|
||||
@@ -577,6 +588,30 @@ pub fn $name(self, key: query_helper_param_ty!($($K)*)) -> $V {
|
||||
)*
|
||||
}
|
||||
|
||||
$(
|
||||
item_if_feedable! {
|
||||
[$($modifiers)*]
|
||||
impl<'tcx, K: $crate::query::IntoQueryParam<$name::Key<'tcx>> + Copy>
|
||||
TyCtxtFeed<'tcx, K>
|
||||
{
|
||||
$(#[$attr])*
|
||||
#[inline(always)]
|
||||
pub fn $name(self, value: $name::ProvidedValue<'tcx>) {
|
||||
let key = self.key().into_query_param();
|
||||
let erased_value = $name::provided_to_erased(self.tcx, value);
|
||||
$crate::query::inner::query_feed(
|
||||
self.tcx,
|
||||
dep_graph::DepKind::$name,
|
||||
&self.tcx.query_system.query_vtables.$name,
|
||||
&self.tcx.query_system.caches.$name,
|
||||
key,
|
||||
erased_value,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
)*
|
||||
|
||||
/// Holds a `QueryVTable` for each query.
|
||||
///
|
||||
/// ("Per" just makes this pluralized name more visually distinct.)
|
||||
@@ -666,39 +701,6 @@ pub struct QueryEngine {
|
||||
};
|
||||
}
|
||||
|
||||
// Note: `$V` is unused but present so this can be called by `rustc_with_all_queries`.
|
||||
macro_rules! define_feedable {
|
||||
(
|
||||
$(
|
||||
$(#[$attr:meta])*
|
||||
[$($modifiers:tt)*]
|
||||
fn $name:ident($K:ty) -> $V:ty,
|
||||
)*
|
||||
) => {
|
||||
$(
|
||||
impl<'tcx, K: $crate::query::IntoQueryParam<$K> + Copy> TyCtxtFeed<'tcx, K> {
|
||||
$(#[$attr])*
|
||||
#[inline(always)]
|
||||
pub fn $name(self, value: $name::ProvidedValue<'tcx>) {
|
||||
let key = self.key().into_query_param();
|
||||
|
||||
let tcx = self.tcx;
|
||||
let erased_value = $name::provided_to_erased(tcx, value);
|
||||
|
||||
$crate::query::inner::query_feed(
|
||||
tcx,
|
||||
dep_graph::DepKind::$name,
|
||||
&tcx.query_system.query_vtables.$name,
|
||||
&tcx.query_system.caches.$name,
|
||||
key,
|
||||
erased_value,
|
||||
);
|
||||
}
|
||||
}
|
||||
)*
|
||||
}
|
||||
}
|
||||
|
||||
// Each of these queries corresponds to a function pointer field in the
|
||||
// `Providers` struct for requesting a value of that type, and a method
|
||||
// on `tcx: TyCtxt` (and `tcx.at(span)`) for doing that request in a way
|
||||
|
||||
Reference in New Issue
Block a user