Skip to main content

rustc_middle/query/
modifiers.rs

1//! This contains documentation which is linked from query modifiers used in the `rustc_queries!` proc macro.
2//!
3//! The dummy items in this module are used to enable hover documentation for
4//! modifier names in the query list, and to allow find-all-references to list
5//! all queries that use a particular modifier.
6#![allow(unused, non_camel_case_types)]
7
8// tidy-alphabetical-start
9//
10/// # `arena_cache` query modifier
11///
12/// Query return values must impl `Copy` and be small, but some queries must return values that
13/// doesn't meet those criteria. Queries marked with this modifier have their values allocated in
14/// an arena and the query returns a reference to the value. There are two cases.
15/// - If the provider function returns `T` then the query will return `&'tcx T`.
16/// - If the provider function returns `Option<T>` then the query will return `Option<&'tcx T>`.
17///
18/// The query plumbing takes care of the arenas and the type manipulations.
19pub(crate) struct arena_cache;
20
21/// # `cache_on_disk` query modifier
22///
23/// The query's return values are cached to disk, and can be loaded by subsequent
24/// sessions if the corresponding dep node is green.
25///
26/// If the [`separate_provide_extern`] modifier is also present, values will only
27/// be cached to disk for "local" keys, because values for external crates should
28/// be loadable from crate metadata instead.
29pub(crate) struct cache_on_disk;
30
31/// # `depth_limit` query modifier
32///
33/// Impose a recursion call depth limit on the query to prevent stack overflow.
34pub(crate) struct depth_limit;
35
36/// # `desc { ... }` query modifier
37///
38/// The human-readable description of the query, for diagnostics and profiling. Required for every
39/// query. The block should contain a `format!`-style string literal followed by optional
40/// arguments. The query key identifier is available for use within the block, as is `tcx`.
41pub(crate) struct desc;
42
43/// # `eval_always` query modifier
44///
45/// Queries with this modifier do not track their dependencies, and are treated as always having a
46/// red (dirty) dependency instead. This is necessary for queries that interact with state that
47/// isn't tracked by the query system.
48///
49/// It can also improve performance for queries that are so likely to be dirtied by any change that
50/// it's not worth tracking their actual dependencies at all.
51///
52/// As with all queries, the return value is still cached in memory for the rest of the compiler
53/// session.
54pub(crate) struct eval_always;
55
56/// # `feedable` query modifier
57///
58/// Generate a `feed` method to set the query's value from another query.
59pub(crate) struct feedable;
60
61/// # `handle_cycle_error` query modifier
62///
63/// The default behaviour for a query cycle is to emit a cycle error and halt
64/// compilation. Queries with this modifier will instead use a custom handler,
65/// which must be provided at `rustc_query_impl::handle_cycle_error::$name`,
66/// where `$name` is the query name.
67pub(crate) struct handle_cycle_error;
68
69/// # `no_force` query modifier
70///
71/// Dep nodes of queries with this modifier will never be "forced" when trying
72/// to mark their dependents green, even if their key is recoverable from the
73/// key fingerprint.
74///
75/// Used by some queries with custom cycle-handlers to ensure that if a cycle
76/// occurs, all of the relevant query calls will be on the query stack.
77pub(crate) struct no_force;
78
79/// # `no_hash` query modifier
80///
81/// Do not hash the query's return value for incremental compilation. If the value needs to be
82/// recomputed, always mark its node as red (dirty).
83pub(crate) struct no_hash;
84
85/// # `separate_provide_extern` query modifier
86///
87/// Use separate query provider functions for local and extern crates.
88///
89/// Also affects the [`cache_on_disk`] modifier.
90pub(crate) struct separate_provide_extern;
91
92// tidy-alphabetical-end