1
Fork 0

Query modifier

This commit is contained in:
Deadbeef 2021-12-06 19:47:54 +08:00
parent 8cd168f6a6
commit 42963f4d50
No known key found for this signature in database
GPG key ID: 6D017A96D8E6C2F9
5 changed files with 72 additions and 0 deletions

View file

@ -231,6 +231,16 @@ macro_rules! get_provider {
};
}
macro_rules! opt_remap_env_constness {
([][$name:ident]) => {};
([(remap_env_constness) $($rest:tt)*][$name:ident]) => {
let $name = $name.without_const();
};
([$other:tt $($modifiers:tt)*][$name:ident]) => {
opt_remap_env_constness!([$($modifiers)*][$name])
};
}
macro_rules! define_queries {
(<$tcx:tt>
$($(#[$attr:meta])*
@ -247,6 +257,7 @@ macro_rules! define_queries {
// Create an eponymous constructor for each query.
$(#[allow(nonstandard_style)] $(#[$attr])*
pub fn $name<$tcx>(tcx: QueryCtxt<$tcx>, key: query_keys::$name<$tcx>) -> QueryStackFrame {
opt_remap_env_constness!([$($modifiers)*][key]);
let kind = dep_graph::DepKind::$name;
let name = stringify!($name);
// Disable visible paths printing for performance reasons.
@ -521,6 +532,7 @@ macro_rules! define_queries_struct {
lookup: QueryLookup,
mode: QueryMode,
) -> Option<query_stored::$name<$tcx>> {
opt_remap_env_constness!([$($modifiers)*][key]);
let qcx = QueryCtxt { tcx, queries: self };
get_query::<queries::$name<$tcx>, _>(qcx, span, key, lookup, mode)
})*