mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-21 22:34:05 +00:00
Remove dead load_cached
code in rustc_query
This commit is contained in:
parent
8da754ef00
commit
112419c9f0
@ -91,9 +91,6 @@ struct QueryModifiers {
|
||||
/// Cache the query to disk if the `Block` returns true.
|
||||
cache: Option<(Option<Pat>, Block)>,
|
||||
|
||||
/// Custom code to load the query from disk.
|
||||
load_cached: Option<(Ident, Ident, Block)>,
|
||||
|
||||
/// A cycle error for this query aborting the compilation with a fatal error.
|
||||
fatal_cycle: Option<Ident>,
|
||||
|
||||
@ -120,7 +117,6 @@ struct QueryModifiers {
|
||||
}
|
||||
|
||||
fn parse_query_modifiers(input: ParseStream<'_>) -> Result<QueryModifiers> {
|
||||
let mut load_cached = None;
|
||||
let mut arena_cache = None;
|
||||
let mut cache = None;
|
||||
let mut desc = None;
|
||||
@ -173,16 +169,6 @@ fn parse_query_modifiers(input: ParseStream<'_>) -> Result<QueryModifiers> {
|
||||
};
|
||||
let block = input.parse()?;
|
||||
try_insert!(cache = (args, block));
|
||||
} else if modifier == "load_cached" {
|
||||
// Parse a load_cached modifier like:
|
||||
// `load_cached(tcx, id) { tcx.on_disk_cache.try_load_query_result(tcx, id) }`
|
||||
let args;
|
||||
parenthesized!(args in input);
|
||||
let tcx = args.parse()?;
|
||||
args.parse::<Token![,]>()?;
|
||||
let id = args.parse()?;
|
||||
let block = input.parse()?;
|
||||
try_insert!(load_cached = (tcx, id, block));
|
||||
} else if modifier == "arena_cache" {
|
||||
try_insert!(arena_cache = modifier);
|
||||
} else if modifier == "fatal_cycle" {
|
||||
@ -209,7 +195,6 @@ fn parse_query_modifiers(input: ParseStream<'_>) -> Result<QueryModifiers> {
|
||||
return Err(input.error("no description provided"));
|
||||
};
|
||||
Ok(QueryModifiers {
|
||||
load_cached,
|
||||
arena_cache,
|
||||
cache,
|
||||
desc,
|
||||
@ -259,20 +244,6 @@ fn add_query_description_impl(query: &Query, impls: &mut proc_macro2::TokenStrea
|
||||
|
||||
// Find out if we should cache the query on disk
|
||||
let cache = if let Some((args, expr)) = modifiers.cache.as_ref() {
|
||||
let try_load_from_disk = if let Some((tcx, id, block)) = modifiers.load_cached.as_ref() {
|
||||
// Use custom code to load the query from disk
|
||||
quote! {
|
||||
const TRY_LOAD_FROM_DISK: Option<fn(QueryCtxt<'tcx>, SerializedDepNodeIndex) -> Option<Self::Value>>
|
||||
= Some(|#tcx, #id| { #block });
|
||||
}
|
||||
} else {
|
||||
// Use the default code to load the query from disk
|
||||
quote! {
|
||||
const TRY_LOAD_FROM_DISK: Option<fn(QueryCtxt<'tcx>, SerializedDepNodeIndex) -> Option<Self::Value>>
|
||||
= Some(|tcx, id| tcx.on_disk_cache().as_ref()?.try_load_query_result(*tcx, id));
|
||||
}
|
||||
};
|
||||
|
||||
let tcx = args.as_ref().map(|t| quote! { #t }).unwrap_or_else(|| quote! { _ });
|
||||
// expr is a `Block`, meaning that `{ #expr }` gets expanded
|
||||
// to `{ { stmts... } }`, which triggers the `unused_braces` lint.
|
||||
@ -283,12 +254,10 @@ fn add_query_description_impl(query: &Query, impls: &mut proc_macro2::TokenStrea
|
||||
#expr
|
||||
}
|
||||
|
||||
#try_load_from_disk
|
||||
const TRY_LOAD_FROM_DISK: Option<fn(QueryCtxt<'tcx>, SerializedDepNodeIndex) -> Option<Self::Value>>
|
||||
= Some(|tcx, id| tcx.on_disk_cache().as_ref()?.try_load_query_result(*tcx, id));
|
||||
}
|
||||
} else {
|
||||
if modifiers.load_cached.is_some() {
|
||||
panic!("load_cached modifier on query `{}` without a cache modifier", name);
|
||||
}
|
||||
quote! {
|
||||
#[inline]
|
||||
fn cache_on_disk(_: TyCtxt<'tcx>, _: &Self::Key) -> bool {
|
||||
|
Loading…
Reference in New Issue
Block a user