Skip to content

Commit 10f63c0

Browse files
committed
Tweak query accessors
1 parent 34e6673 commit 10f63c0

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

compiler/rustc_middle/src/ty/query.rs

+7-13
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,11 @@ macro_rules! separate_provide_extern_default {
168168
}
169169

170170
macro_rules! opt_remap_env_constness {
171-
([][$name:ident]) => {};
172-
([(remap_env_constness) $($rest:tt)*][$name:ident]) => {
173-
let $name = $name.without_const();
171+
([][$name:expr]) => { $name };
172+
([(remap_env_constness) $($rest:tt)*][$name:expr]) => {
173+
$name.without_const()
174174
};
175-
([$other:tt $($modifiers:tt)*][$name:ident]) => {
175+
([$other:tt $($modifiers:tt)*][$name:expr]) => {
176176
opt_remap_env_constness!([$($modifiers)*][$name])
177177
};
178178
}
@@ -276,9 +276,7 @@ macro_rules! define_callbacks {
276276
$($(#[$attr])*
277277
#[inline(always)]
278278
pub fn $name(self, key: query_helper_param_ty!($($K)*)) {
279-
let key = key.into_query_param();
280-
opt_remap_env_constness!([$($modifiers)*][key]);
281-
279+
let key = opt_remap_env_constness!([$($modifiers)*][key]).into_query_param();
282280
match try_get_cached(self.tcx, &self.tcx.query_system.caches.$name, &key) {
283281
Some(_) => return,
284282
None => self.tcx.queries.$name(self.tcx, DUMMY_SP, key, QueryMode::Ensure),
@@ -301,9 +299,7 @@ macro_rules! define_callbacks {
301299
#[inline(always)]
302300
pub fn $name(self, key: query_helper_param_ty!($($K)*)) -> $V
303301
{
304-
let key = key.into_query_param();
305-
opt_remap_env_constness!([$($modifiers)*][key]);
306-
302+
let key = opt_remap_env_constness!([$($modifiers)*][key]).into_query_param();
307303
match try_get_cached(self.tcx, &self.tcx.query_system.caches.$name, &key) {
308304
Some(value) => value,
309305
None => self.tcx.queries.$name(self.tcx, self.span, key, QueryMode::Get).unwrap(),
@@ -394,9 +390,7 @@ macro_rules! define_feedable {
394390
$(#[$attr])*
395391
#[inline(always)]
396392
pub fn $name(self, value: query_provided::$name<'tcx>) -> $V {
397-
let key = self.key().into_query_param();
398-
opt_remap_env_constness!([$($modifiers)*][key]);
399-
393+
let key = opt_remap_env_constness!([$($modifiers)*][self.key()]).into_query_param();
400394
let tcx = self.tcx;
401395
let value = query_provided_to_value::$name(tcx, value);
402396
let cache = &tcx.query_system.caches.$name;

compiler/rustc_query_system/src/query/plumbing.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ where
330330
/// It returns the shard index and a lock guard to the shard,
331331
/// which will be used if the query is not in the cache and we need
332332
/// to compute it.
333-
#[inline]
333+
#[inline(always)]
334334
pub fn try_get_cached<Tcx, C>(tcx: Tcx, cache: &C, key: &C::Key) -> Option<C::Value>
335335
where
336336
C: QueryCache,

0 commit comments

Comments
 (0)