mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-26 13:01:27 +03:00
Remove the anon query modifier
We still have some anon-task machinery for `DepKind::TraitSelect` tasks, but there are no longer any queries that use the `anon` modifier.
This commit is contained in:
@@ -140,7 +140,6 @@ struct CacheOnDiskIf {
|
||||
/// See `rustc_middle::query::modifiers` for documentation of each query modifier.
|
||||
struct QueryModifiers {
|
||||
// tidy-alphabetical-start
|
||||
anon: Option<Ident>,
|
||||
arena_cache: Option<Ident>,
|
||||
cache_on_disk_if: Option<CacheOnDiskIf>,
|
||||
depth_limit: Option<Ident>,
|
||||
@@ -159,7 +158,6 @@ fn parse_query_modifiers(input: ParseStream<'_>) -> Result<QueryModifiers> {
|
||||
let mut desc = None;
|
||||
let mut no_force = None;
|
||||
let mut no_hash = None;
|
||||
let mut anon = None;
|
||||
let mut eval_always = None;
|
||||
let mut depth_limit = None;
|
||||
let mut separate_provide_extern = None;
|
||||
@@ -195,8 +193,6 @@ macro_rules! try_insert {
|
||||
try_insert!(no_force = modifier);
|
||||
} else if modifier == "no_hash" {
|
||||
try_insert!(no_hash = modifier);
|
||||
} else if modifier == "anon" {
|
||||
try_insert!(anon = modifier);
|
||||
} else if modifier == "eval_always" {
|
||||
try_insert!(eval_always = modifier);
|
||||
} else if modifier == "depth_limit" {
|
||||
@@ -218,7 +214,6 @@ macro_rules! try_insert {
|
||||
desc,
|
||||
no_force,
|
||||
no_hash,
|
||||
anon,
|
||||
eval_always,
|
||||
depth_limit,
|
||||
separate_provide_extern,
|
||||
@@ -248,7 +243,6 @@ fn returns_error_guaranteed(ret_ty: &ReturnType) -> bool {
|
||||
fn make_modifiers_stream(query: &Query) -> proc_macro2::TokenStream {
|
||||
let QueryModifiers {
|
||||
// tidy-alphabetical-start
|
||||
anon,
|
||||
arena_cache,
|
||||
cache_on_disk_if,
|
||||
depth_limit,
|
||||
@@ -261,7 +255,6 @@ fn make_modifiers_stream(query: &Query) -> proc_macro2::TokenStream {
|
||||
// tidy-alphabetical-end
|
||||
} = &query.modifiers;
|
||||
|
||||
let anon = anon.is_some();
|
||||
let arena_cache = arena_cache.is_some();
|
||||
let cache_on_disk = cache_on_disk_if.is_some();
|
||||
let depth_limit = depth_limit.is_some();
|
||||
@@ -280,7 +273,6 @@ fn make_modifiers_stream(query: &Query) -> proc_macro2::TokenStream {
|
||||
query_name_span =>
|
||||
// Search for (QMODLIST) to find all occurrences of this query modifier list.
|
||||
// tidy-alphabetical-start
|
||||
anon: #anon,
|
||||
arena_cache: #arena_cache,
|
||||
cache_on_disk: #cache_on_disk,
|
||||
depth_limit: #depth_limit,
|
||||
@@ -396,7 +388,6 @@ macro_rules! doc_link {
|
||||
|
||||
doc_link!(
|
||||
// tidy-alphabetical-start
|
||||
anon,
|
||||
arena_cache,
|
||||
depth_limit,
|
||||
eval_always,
|
||||
@@ -487,11 +478,6 @@ fn #name(#key_ty) #return_ty
|
||||
});
|
||||
|
||||
if let Some(feedable) = &modifiers.feedable {
|
||||
assert!(
|
||||
modifiers.anon.is_none(),
|
||||
feedable.span(),
|
||||
"Query {name} cannot be both `feedable` and `anon`."
|
||||
);
|
||||
assert!(
|
||||
modifiers.eval_always.is_none(),
|
||||
feedable.span(),
|
||||
|
||||
@@ -94,10 +94,14 @@ pub const fn as_usize(&self) -> usize {
|
||||
pub struct DepNode {
|
||||
pub kind: DepKind,
|
||||
|
||||
/// This is _typically_ a hash of the query key, but sometimes not.
|
||||
/// If `kind` is a query method, then its "key fingerprint" is always a
|
||||
/// stable hash of the query key.
|
||||
///
|
||||
/// For example, `anon` nodes have a fingerprint that is derived from their
|
||||
/// dependencies instead of a key.
|
||||
/// For non-query nodes, the content of this field varies:
|
||||
/// - Some dep kinds always use a dummy `ZERO` fingerprint.
|
||||
/// - Some dep kinds use the stable hash of some relevant key-like value.
|
||||
/// - Some dep kinds use the `with_anon_task` mechanism, and set their key
|
||||
/// fingerprint to a hash derived from the task's dependencies.
|
||||
///
|
||||
/// In some cases the key value can be reconstructed from this fingerprint;
|
||||
/// see [`KeyFingerprintStyle`].
|
||||
|
||||
@@ -375,9 +375,8 @@ pub fn with_task<'tcx, A: Debug, R>(
|
||||
/// incorrectly marked green.
|
||||
///
|
||||
/// FIXME: This could perhaps return a `WithDepNode` to ensure that the
|
||||
/// user of this function actually performs the read; we'll have to see
|
||||
/// how to make that work with `anon` in `execute_job_incr`, though.
|
||||
pub fn with_anon_task_inner<'tcx, OP, R>(
|
||||
/// user of this function actually performs the read.
|
||||
fn with_anon_task_inner<'tcx, OP, R>(
|
||||
&self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
dep_kind: DepKind,
|
||||
|
||||
@@ -7,11 +7,6 @@
|
||||
|
||||
// tidy-alphabetical-start
|
||||
//
|
||||
/// # `anon` query modifier
|
||||
///
|
||||
/// Generate a dep node based not on the query key, but on the query's dependencies.
|
||||
pub(crate) struct anon;
|
||||
|
||||
/// # `arena_cache` query modifier
|
||||
///
|
||||
/// Query return values must impl `Copy` and be small, but some queries must return values that
|
||||
|
||||
@@ -77,8 +77,6 @@ pub enum EnsureMode {
|
||||
pub struct QueryVTable<'tcx, C: QueryCache> {
|
||||
pub name: &'static str,
|
||||
|
||||
/// True if this query has the `anon` modifier.
|
||||
pub anon: bool,
|
||||
/// True if this query has the `eval_always` modifier.
|
||||
pub eval_always: bool,
|
||||
/// True if this query has the `depth_limit` modifier.
|
||||
@@ -283,7 +281,6 @@ macro_rules! define_callbacks {
|
||||
fn $name:ident($($K:tt)*) -> $V:ty
|
||||
{
|
||||
// Search for (QMODLIST) to find all occurrences of this query modifier list.
|
||||
anon: $anon:literal,
|
||||
arena_cache: $arena_cache:literal,
|
||||
cache_on_disk: $cache_on_disk:literal,
|
||||
depth_limit: $depth_limit:literal,
|
||||
|
||||
@@ -96,7 +96,6 @@ pub(crate) fn Metadata<'tcx>() -> DepKindVTable<'tcx> {
|
||||
/// Shared implementation of the [`DepKindVTable`] constructor for queries.
|
||||
/// Called from macro-generated code for each query.
|
||||
pub(crate) fn make_dep_kind_vtable_for_query<'tcx, Q>(
|
||||
is_anon: bool,
|
||||
is_cache_on_disk: bool,
|
||||
is_eval_always: bool,
|
||||
is_no_force: bool,
|
||||
@@ -104,18 +103,10 @@ pub(crate) fn make_dep_kind_vtable_for_query<'tcx, Q>(
|
||||
where
|
||||
Q: GetQueryVTable<'tcx>,
|
||||
{
|
||||
let key_fingerprint_style = if is_anon {
|
||||
KeyFingerprintStyle::Opaque
|
||||
} else {
|
||||
<Q::Cache as QueryCache>::Key::key_fingerprint_style()
|
||||
};
|
||||
|
||||
// A query dep-node can only be forced or promoted if it can recover a key
|
||||
// from its key fingerprint.
|
||||
let key_fingerprint_style = <Q::Cache as QueryCache>::Key::key_fingerprint_style();
|
||||
let can_recover = key_fingerprint_style.is_maybe_recoverable();
|
||||
if is_anon {
|
||||
assert!(!can_recover);
|
||||
}
|
||||
|
||||
DepKindVTable {
|
||||
is_eval_always,
|
||||
@@ -135,7 +126,6 @@ macro_rules! define_dep_kind_vtables {
|
||||
fn $name:ident($K:ty) -> $V:ty
|
||||
{
|
||||
// Search for (QMODLIST) to find all occurrences of this query modifier list.
|
||||
anon: $anon:literal,
|
||||
arena_cache: $arena_cache:literal,
|
||||
cache_on_disk: $cache_on_disk:literal,
|
||||
depth_limit: $depth_limit:literal,
|
||||
@@ -168,7 +158,6 @@ fn $name:ident($K:ty) -> $V:ty
|
||||
$crate::dep_kind_vtables::make_dep_kind_vtable_for_query::<
|
||||
$crate::query_impl::$name::VTableGetter,
|
||||
>(
|
||||
$anon,
|
||||
$cache_on_disk,
|
||||
$eval_always,
|
||||
$no_force,
|
||||
|
||||
@@ -424,7 +424,7 @@ fn execute_job_incr<'tcx, C: QueryCache>(
|
||||
let dep_graph_data =
|
||||
tcx.dep_graph.data().expect("should always be present in incremental mode");
|
||||
|
||||
if !query.anon && !query.eval_always {
|
||||
if !query.eval_always {
|
||||
// `to_dep_node` is expensive for some `DepKind`s.
|
||||
let dep_node =
|
||||
dep_node_opt.get_or_insert_with(|| DepNode::construct(tcx, query.dep_kind, &key));
|
||||
@@ -451,13 +451,6 @@ fn execute_job_incr<'tcx, C: QueryCache>(
|
||||
let prof_timer = tcx.prof.query_provider();
|
||||
|
||||
let (result, dep_node_index) = start_query(job_id, query.depth_limit, || {
|
||||
if query.anon {
|
||||
// Call the query provider inside an anon task.
|
||||
return dep_graph_data.with_anon_task_inner(tcx, query.dep_kind, || {
|
||||
(query.invoke_provider_fn)(tcx, key)
|
||||
});
|
||||
}
|
||||
|
||||
// `to_dep_node` is expensive for some `DepKind`s.
|
||||
let dep_node =
|
||||
dep_node_opt.unwrap_or_else(|| DepNode::construct(tcx, query.dep_kind, &key));
|
||||
@@ -601,9 +594,6 @@ fn check_if_ensure_can_skip_execution<'tcx, C: QueryCache>(
|
||||
return EnsureCanSkip { skip_execution: false, dep_node: None };
|
||||
}
|
||||
|
||||
// Ensuring an anonymous query makes no sense
|
||||
assert!(!query.anon);
|
||||
|
||||
let dep_node = DepNode::construct(tcx, query.dep_kind, &key);
|
||||
|
||||
let serialized_dep_node_index = match tcx.dep_graph.try_mark_green(tcx, &dep_node) {
|
||||
@@ -703,8 +693,6 @@ pub(crate) fn force_query<'tcx, C: QueryCache>(
|
||||
return;
|
||||
}
|
||||
|
||||
debug_assert!(!query.anon);
|
||||
|
||||
ensure_sufficient_stack(|| {
|
||||
try_execute_query::<C, true>(query, tcx, DUMMY_SP, key, Some(dep_node))
|
||||
});
|
||||
|
||||
@@ -16,7 +16,6 @@ macro_rules! define_queries {
|
||||
fn $name:ident($K:ty) -> $V:ty
|
||||
{
|
||||
// Search for (QMODLIST) to find all occurrences of this query modifier list.
|
||||
anon: $anon:literal,
|
||||
arena_cache: $arena_cache:literal,
|
||||
cache_on_disk: $cache_on_disk:literal,
|
||||
depth_limit: $depth_limit:literal,
|
||||
@@ -133,7 +132,6 @@ pub(crate) fn make_query_vtable<'tcx>(incremental: bool)
|
||||
|
||||
QueryVTable {
|
||||
name: stringify!($name),
|
||||
anon: $anon,
|
||||
eval_always: $eval_always,
|
||||
depth_limit: $depth_limit,
|
||||
feedable: $feedable,
|
||||
|
||||
@@ -485,13 +485,6 @@ respect to incremental compilation:
|
||||
For example, it makes no sense to store values from upstream
|
||||
crates in the cache because they are already available in the upstream crate's metadata.
|
||||
|
||||
- `anon` - This attribute makes the system use "anonymous" dep-nodes for the given query.
|
||||
An anonymous dep-node is not identified by the corresponding query key.
|
||||
Instead, its ID is computed from the IDs of its dependencies.
|
||||
This allows the red-green system to do its change detection even if there is no
|
||||
query key available for a given dep-node -- something which is needed for
|
||||
handling trait selection because it is not based on queries.
|
||||
|
||||
[mod]: ../query.html#adding-a-new-kind-of-query
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user