Introduce query_stored module.

This commit is contained in:
Camille GILLOT 2021-01-17 14:57:07 +01:00
parent 8684e9e47d
commit 4b42a6d90b
1 changed files with 12 additions and 8 deletions

View File

@ -342,14 +342,20 @@ macro_rules! define_queries {
$(pub type $name<$tcx> = $V;)*
}
#[allow(nonstandard_style, unused_lifetimes)]
pub mod query_stored {
use super::*;
$(pub type $name<$tcx> = <
query_storage!([$($modifiers)*][$($K)*, $V])
as QueryStorage
>::Stored;)*
}
$(impl<$tcx> QueryConfig for queries::$name<$tcx> {
type Key = $($K)*;
type Value = $V;
type Stored = <
query_storage!([$($modifiers)*][$($K)*, $V])
as QueryStorage
>::Stored;
type Stored = query_stored::$name<$tcx>;
const NAME: &'static str = stringify!($name);
}
@ -442,8 +448,7 @@ macro_rules! define_queries {
$($(#[$attr])*
#[inline(always)]
#[must_use]
pub fn $name(self, key: query_helper_param_ty!($($K)*))
-> <queries::$name<$tcx> as QueryConfig>::Stored
pub fn $name(self, key: query_helper_param_ty!($($K)*)) -> query_stored::$name<$tcx>
{
self.at(DUMMY_SP).$name(key.into_query_param())
})*
@ -481,8 +486,7 @@ macro_rules! define_queries {
impl TyCtxtAt<$tcx> {
$($(#[$attr])*
#[inline(always)]
pub fn $name(self, key: query_helper_param_ty!($($K)*))
-> <queries::$name<$tcx> as QueryConfig>::Stored
pub fn $name(self, key: query_helper_param_ty!($($K)*)) -> query_stored::$name<$tcx>
{
get_query::<queries::$name<'_>, _>(self.tcx, self.span, key.into_query_param(), QueryMode::Get).unwrap()
})*