Skip to content

Commit

Permalink
Avoid trivial lambdas.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Oct 20, 2021
1 parent 6162529 commit 88c6d3d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions compiler/rustc_middle/src/ty/query.rs
Expand Up @@ -102,6 +102,10 @@ impl TyCtxt<'tcx> {
}
}

/// Helper for `TyCtxtEnsure` to avoid a closure.
#[inline(always)]
fn noop<T>(_: &T) {}

macro_rules! query_helper_param_ty {
(DefId) => { impl IntoQueryParam<DefId> };
($K:ty) => { $K };
Expand Down Expand Up @@ -165,7 +169,7 @@ macro_rules! define_callbacks {
#[inline(always)]
pub fn $name(self, key: query_helper_param_ty!($($K)*)) {
let key = key.into_query_param();
let cached = try_get_cached(self.tcx, &self.tcx.query_caches.$name, &key, |_| {});
let cached = try_get_cached(self.tcx, &self.tcx.query_caches.$name, &key, noop);

let lookup = match cached {
Ok(()) => return,
Expand All @@ -192,9 +196,7 @@ macro_rules! define_callbacks {
pub fn $name(self, key: query_helper_param_ty!($($K)*)) -> query_stored::$name<$tcx>
{
let key = key.into_query_param();
let cached = try_get_cached(self.tcx, &self.tcx.query_caches.$name, &key, |value| {
value.clone()
});
let cached = try_get_cached(self.tcx, &self.tcx.query_caches.$name, &key, Clone::clone);

let lookup = match cached {
Ok(value) => return value,
Expand Down

0 comments on commit 88c6d3d

Please sign in to comment.