Skip to content

Commit

Permalink
Remove unnecessary TRY_LOAD_FROM_DISK constant
Browse files Browse the repository at this point in the history
  • Loading branch information
jyn514 committed Sep 10, 2022
1 parent 9273782 commit 0a9d7db
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 9 deletions.
1 change: 0 additions & 1 deletion compiler/rustc_query_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ pub use rustc_query_system::query::{deadlock, QueryContext};
mod keys;
use keys::Key;

use rustc_query_system::dep_graph::SerializedDepNodeIndex;
pub use rustc_query_system::query::QueryConfig;
pub(crate) use rustc_query_system::query::{QueryDescription, QueryVTable};

Expand Down
5 changes: 1 addition & 4 deletions compiler/rustc_query_impl/src/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,6 @@ macro_rules! define_queries {
impl<'tcx> QueryDescription<QueryCtxt<'tcx>> for queries::$name<'tcx> {
rustc_query_description! { $name }

const TRY_LOAD_FROM_DISK: Option<fn(QueryCtxt<'tcx>, SerializedDepNodeIndex) -> Option<Self::Value>>
= should_ever_cache_on_disk!([$($modifiers)*]);

type Cache = query_storage::$name<'tcx>;

#[inline(always)]
Expand Down Expand Up @@ -445,7 +442,7 @@ macro_rules! define_queries {
hash_result: hash_result!([$($modifiers)*]),
handle_cycle_error: handle_cycle_error!([$($modifiers)*]),
compute,
try_load_from_disk: if cache_on_disk { Self::TRY_LOAD_FROM_DISK } else { None },
try_load_from_disk: if cache_on_disk { should_ever_cache_on_disk!([$($modifiers)*]) } else { None },
}
}

Expand Down
5 changes: 1 addition & 4 deletions compiler/rustc_query_system/src/query/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ pub struct QueryVTable<CTX: QueryContext, K, V> {
pub compute: fn(CTX::DepContext, K) -> V,
pub hash_result: Option<fn(&mut StableHashingContext<'_>, &V) -> Fingerprint>,
pub handle_cycle_error: HandleCycleError,
// NOTE: this is not quite the same as `Q::TRY_LOAD_FROM_DISK`; it can also be `None` if
// `cache_on_disk` returned false for this key.
// NOTE: this is also `None` if `cache_on_disk()` returns false, not just if it's unsupported by the query
pub try_load_from_disk: Option<fn(CTX, SerializedDepNodeIndex) -> Option<V>>,
}

Expand All @@ -48,8 +47,6 @@ impl<CTX: QueryContext, K, V> QueryVTable<CTX, K, V> {
}

pub trait QueryDescription<CTX: QueryContext>: QueryConfig {
const TRY_LOAD_FROM_DISK: Option<fn(CTX, SerializedDepNodeIndex) -> Option<Self::Value>>;

type Cache: QueryCache<Key = Self::Key, Stored = Self::Stored, Value = Self::Value>;

fn describe(tcx: CTX, key: Self::Key) -> String;
Expand Down

0 comments on commit 0a9d7db

Please sign in to comment.