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

Tweak query accessors #108478

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 7 additions & 13 deletions compiler/rustc_middle/src/ty/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,11 @@ macro_rules! separate_provide_extern_default {
}

macro_rules! opt_remap_env_constness {
([][$name:ident]) => {};
([(remap_env_constness) $($rest:tt)*][$name:ident]) => {
let $name = $name.without_const();
([][$name:expr]) => { $name };
([(remap_env_constness) $($rest:tt)*][$name:expr]) => {
$name.without_const()
};
([$other:tt $($modifiers:tt)*][$name:ident]) => {
([$other:tt $($modifiers:tt)*][$name:expr]) => {
opt_remap_env_constness!([$($modifiers)*][$name])
};
}
Expand Down Expand Up @@ -276,9 +276,7 @@ macro_rules! define_callbacks {
$($(#[$attr])*
#[inline(always)]
pub fn $name(self, key: query_helper_param_ty!($($K)*)) {
let key = key.into_query_param();
opt_remap_env_constness!([$($modifiers)*][key]);

let key = opt_remap_env_constness!([$($modifiers)*][key]).into_query_param();
match try_get_cached(self.tcx, &self.tcx.query_system.caches.$name, &key) {
Some(_) => return,
None => self.tcx.queries.$name(self.tcx, DUMMY_SP, key, QueryMode::Ensure),
Expand All @@ -301,9 +299,7 @@ macro_rules! define_callbacks {
#[inline(always)]
pub fn $name(self, key: query_helper_param_ty!($($K)*)) -> $V
{
let key = key.into_query_param();
opt_remap_env_constness!([$($modifiers)*][key]);

let key = opt_remap_env_constness!([$($modifiers)*][key]).into_query_param();
match try_get_cached(self.tcx, &self.tcx.query_system.caches.$name, &key) {
Some(value) => value,
None => self.tcx.queries.$name(self.tcx, self.span, key, QueryMode::Get).unwrap(),
Expand Down Expand Up @@ -394,9 +390,7 @@ macro_rules! define_feedable {
$(#[$attr])*
#[inline(always)]
pub fn $name(self, value: query_provided::$name<'tcx>) -> $V {
let key = self.key().into_query_param();
opt_remap_env_constness!([$($modifiers)*][key]);

let key = opt_remap_env_constness!([$($modifiers)*][self.key()]).into_query_param();
let tcx = self.tcx;
let value = query_provided_to_value::$name(tcx, value);
let cache = &tcx.query_system.caches.$name;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_query_system/src/query/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ where
/// It returns the shard index and a lock guard to the shard,
/// which will be used if the query is not in the cache and we need
/// to compute it.
#[inline]
#[inline(always)]
pub fn try_get_cached<Tcx, C>(tcx: Tcx, cache: &C, key: &C::Key) -> Option<C::Value>
where
C: QueryCache,
Expand Down