Skip to content

Commit fd130cd

Browse files
committed
Rename eval_always query modifier to no_incremental
\`eval_always\` gives the impression that the query is evaluated every time it's called. (thus, evaluated always). Turns out this isn't the truth, it just affects how the dependency graph behaves with that node (i.e. not even trying to mark it green) This commit renames `eval_always` to `no_incremental`, I thought about `always_red_on_depgraph` or similar but I don't think that gatekeeping its use under minor details of how the dep graph works is that preferable.
1 parent 425a9c0 commit fd130cd

File tree

12 files changed

+89
-89
lines changed

12 files changed

+89
-89
lines changed

compiler/rustc_lint/src/expect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn check_expectations(tcx: TyCtxt<'_>, tool_filter: Option<Symbol>) {
3636
(attr_id, lint_index)
3737
}
3838
LintExpectationId::Stable { hir_id, attr_index, lint_index: Some(lint_index) } => {
39-
// We are an `eval_always` query, so looking at the attribute's `AttrId` is ok.
39+
// We are an `no_incremental` query, so looking at the attribute's `AttrId` is ok.
4040
let attr_id = tcx.hir_attrs(hir_id)[attr_index as usize].id();
4141

4242
(attr_id, lint_index)

compiler/rustc_macros/src/query.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ struct QueryModifiers {
108108
anon: Option<Ident>,
109109

110110
/// Always evaluate the query, ignoring its dependencies
111-
eval_always: Option<Ident>,
111+
no_incremental: Option<Ident>,
112112

113113
/// Whether the query has a call depth limit
114114
depth_limit: Option<Ident>,
@@ -141,7 +141,7 @@ fn parse_query_modifiers(input: ParseStream<'_>) -> Result<QueryModifiers> {
141141
let mut cycle_stash = None;
142142
let mut no_hash = None;
143143
let mut anon = None;
144-
let mut eval_always = None;
144+
let mut no_incremental = None;
145145
let mut depth_limit = None;
146146
let mut separate_provide_extern = None;
147147
let mut feedable = None;
@@ -199,8 +199,8 @@ fn parse_query_modifiers(input: ParseStream<'_>) -> Result<QueryModifiers> {
199199
try_insert!(no_hash = modifier);
200200
} else if modifier == "anon" {
201201
try_insert!(anon = modifier);
202-
} else if modifier == "eval_always" {
203-
try_insert!(eval_always = modifier);
202+
} else if modifier == "no_incremental" {
203+
try_insert!(no_incremental = modifier);
204204
} else if modifier == "depth_limit" {
205205
try_insert!(depth_limit = modifier);
206206
} else if modifier == "separate_provide_extern" {
@@ -225,7 +225,7 @@ fn parse_query_modifiers(input: ParseStream<'_>) -> Result<QueryModifiers> {
225225
cycle_stash,
226226
no_hash,
227227
anon,
228-
eval_always,
228+
no_incremental,
229229
depth_limit,
230230
separate_provide_extern,
231231
feedable,
@@ -372,7 +372,7 @@ pub(super) fn rustc_queries(input: TokenStream) -> TokenStream {
372372
cycle_stash,
373373
no_hash,
374374
anon,
375-
eval_always,
375+
no_incremental,
376376
depth_limit,
377377
separate_provide_extern,
378378
return_result_from_ensure_ok,
@@ -408,9 +408,9 @@ pub(super) fn rustc_queries(input: TokenStream) -> TokenStream {
408408
"Query {name} cannot be both `feedable` and `anon`."
409409
);
410410
assert!(
411-
modifiers.eval_always.is_none(),
411+
modifiers.no_incremental.is_none(),
412412
feedable.span(),
413-
"Query {name} cannot be both `feedable` and `eval_always`."
413+
"Query {name} cannot be both `feedable` and `no_incremental`."
414414
);
415415
feedable_queries.extend(quote! {
416416
[#attribute_stream] fn #name(#arg) #result,

compiler/rustc_middle/src/query/mod.rs

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
//! - `cycle_stash`: If a dependency cycle is detected, stash the error for later handling.
3434
//! - `no_hash`: Do not hash the query result for incremental compilation; just mark as dirty if recomputed.
3535
//! - `anon`: Make the query anonymous in the dependency graph (no dep node is created).
36-
//! - `eval_always`: Always evaluate the query, ignoring its dependencies and cached results.
36+
//! - `no_incremental`: Don't save the result to disk, just cache it for use exclusively in the same compilation.
3737
//! - `depth_limit`: Impose a recursion depth limit on the query to prevent stack overflows.
3838
//! - `separate_provide_extern`: Use separate provider functions for local and external crates.
3939
//! - `feedable`: Allow the query result to be set from another query ("fed" externally).
@@ -190,7 +190,7 @@ rustc_queries! {
190190
/// `rustc_interface::passes::write_dep_info` to make that work.
191191
query env_var_os(key: &'tcx OsStr) -> Option<&'tcx OsStr> {
192192
// Environment variables are global state
193-
eval_always
193+
no_incremental
194194
desc { "get the value of an environment variable" }
195195
}
196196

@@ -199,7 +199,7 @@ rustc_queries! {
199199
}
200200

201201
query resolver_for_lowering_raw(_: ()) -> (&'tcx Steal<(ty::ResolverAstLowering, Arc<ast::Crate>)>, &'tcx ty::ResolverGlobalCtxt) {
202-
eval_always
202+
no_incremental
203203
no_hash
204204
desc { "getting the resolver for lowering" }
205205
}
@@ -211,7 +211,7 @@ rustc_queries! {
211211
/// of rustc_middle::hir::source_map.
212212
query source_span(key: LocalDefId) -> Span {
213213
// Accesses untracked data
214-
eval_always
214+
no_incremental
215215
desc { "getting the source span" }
216216
}
217217

@@ -224,14 +224,14 @@ rustc_queries! {
224224
/// [`TyCtxt::hir_visit_all_item_likes_in_crate`].
225225
query hir_crate(key: ()) -> &'tcx Crate<'tcx> {
226226
arena_cache
227-
eval_always
227+
no_incremental
228228
desc { "getting the crate HIR" }
229229
}
230230

231231
/// All items in the crate.
232232
query hir_crate_items(_: ()) -> &'tcx rustc_middle::hir::ModuleItems {
233233
arena_cache
234-
eval_always
234+
no_incremental
235235
desc { "getting HIR crate items" }
236236
}
237237

@@ -397,7 +397,7 @@ rustc_queries! {
397397

398398
/// The root query triggering all analysis passes like typeck or borrowck.
399399
query analysis(key: ()) {
400-
eval_always
400+
no_incremental
401401
desc { "running analysis passes on this crate" }
402402
}
403403

@@ -416,7 +416,7 @@ rustc_queries! {
416416
/// was called. With the default `None` all registered lints will also
417417
/// be checked for expectation fulfillment.
418418
query check_expectations(key: Option<Symbol>) {
419-
eval_always
419+
no_incremental
420420
desc { "checking lint expectations (RFC 2383)" }
421421
}
422422

@@ -1386,7 +1386,7 @@ rustc_queries! {
13861386

13871387
/// Performs part of the privacy check and computes effective visibilities.
13881388
query effective_visibilities(_: ()) -> &'tcx EffectiveVisibilities {
1389-
eval_always
1389+
no_incremental
13901390
desc { "checking effective visibilities" }
13911391
}
13921392
query check_private_in_public(module_def_id: LocalModDefId) {
@@ -1791,14 +1791,14 @@ rustc_queries! {
17911791
}
17921792
query has_global_allocator(_: CrateNum) -> bool {
17931793
// This query depends on untracked global state in CStore
1794-
eval_always
1794+
no_incremental
17951795
fatal_cycle
17961796
desc { "checking if the crate has_global_allocator" }
17971797
separate_provide_extern
17981798
}
17991799
query has_alloc_error_handler(_: CrateNum) -> bool {
18001800
// This query depends on untracked global state in CStore
1801-
eval_always
1801+
no_incremental
18021802
fatal_cycle
18031803
desc { "checking if the crate has_alloc_error_handler" }
18041804
separate_provide_extern
@@ -1839,7 +1839,7 @@ rustc_queries! {
18391839
}
18401840

18411841
query extern_crate(def_id: CrateNum) -> Option<&'tcx ExternCrate> {
1842-
eval_always
1842+
no_incremental
18431843
desc { "getting crate's ExternCrateData" }
18441844
separate_provide_extern
18451845
}
@@ -2009,14 +2009,14 @@ rustc_queries! {
20092009
// compilation is enabled calculating this hash can freeze this structure too early in
20102010
// compilation and cause subsequent crashes when attempting to write to `definitions`
20112011
query crate_hash(_: CrateNum) -> Svh {
2012-
eval_always
2012+
no_incremental
20132013
desc { "looking up the hash a crate" }
20142014
separate_provide_extern
20152015
}
20162016

20172017
/// Gets the hash for the host proc macro. Used to support -Z dual-proc-macro.
20182018
query crate_host_hash(_: CrateNum) -> Option<Svh> {
2019-
eval_always
2019+
no_incremental
20202020
desc { "looking up the hash of a host version of a crate" }
20212021
separate_provide_extern
20222022
}
@@ -2025,15 +2025,15 @@ rustc_queries! {
20252025
/// For example, compiling the `foo` crate with `extra-filename=-a` creates a `libfoo-b.rlib` file.
20262026
query extra_filename(_: CrateNum) -> &'tcx String {
20272027
arena_cache
2028-
eval_always
2028+
no_incremental
20292029
desc { "looking up the extra filename for a crate" }
20302030
separate_provide_extern
20312031
}
20322032

20332033
/// Gets the paths where the crate came from in the file system.
20342034
query crate_extern_paths(_: CrateNum) -> &'tcx Vec<PathBuf> {
20352035
arena_cache
2036-
eval_always
2036+
no_incremental
20372037
desc { "looking up the paths for extern crates" }
20382038
separate_provide_extern
20392039
}
@@ -2144,7 +2144,7 @@ rustc_queries! {
21442144
}
21452145

21462146
query dep_kind(_: CrateNum) -> CrateDepKind {
2147-
eval_always
2147+
no_incremental
21482148
desc { "fetching what a dependency looks like" }
21492149
separate_provide_extern
21502150
}
@@ -2200,14 +2200,14 @@ rustc_queries! {
22002200
/// Returns the lang items defined in another crate by loading it from metadata.
22012201
query get_lang_items(_: ()) -> &'tcx LanguageItems {
22022202
arena_cache
2203-
eval_always
2203+
no_incremental
22042204
desc { "calculating the lang items map" }
22052205
}
22062206

22072207
/// Returns all diagnostic items defined in all crates.
22082208
query all_diagnostic_items(_: ()) -> &'tcx rustc_hir::diagnostic_items::DiagnosticItems {
22092209
arena_cache
2210-
eval_always
2210+
no_incremental
22112211
desc { "calculating the diagnostic items map" }
22122212
}
22132213

@@ -2244,45 +2244,45 @@ rustc_queries! {
22442244
desc { "calculating trimmed def paths" }
22452245
}
22462246
query missing_extern_crate_item(_: CrateNum) -> bool {
2247-
eval_always
2247+
no_incremental
22482248
desc { "seeing if we're missing an `extern crate` item for this crate" }
22492249
separate_provide_extern
22502250
}
22512251
query used_crate_source(_: CrateNum) -> &'tcx Arc<CrateSource> {
22522252
arena_cache
2253-
eval_always
2253+
no_incremental
22542254
desc { "looking at the source for a crate" }
22552255
separate_provide_extern
22562256
}
22572257

22582258
/// Returns the debugger visualizers defined for this crate.
2259-
/// NOTE: This query has to be marked `eval_always` because it reads data
2259+
/// NOTE: This query has to be marked `no_incremental` because it reads data
22602260
/// directly from disk that is not tracked anywhere else. I.e. it
22612261
/// represents a genuine input to the query system.
22622262
query debugger_visualizers(_: CrateNum) -> &'tcx Vec<DebuggerVisualizerFile> {
22632263
arena_cache
22642264
desc { "looking up the debugger visualizers for this crate" }
22652265
separate_provide_extern
2266-
eval_always
2266+
no_incremental
22672267
}
22682268

22692269
query postorder_cnums(_: ()) -> &'tcx [CrateNum] {
2270-
eval_always
2270+
no_incremental
22712271
desc { "generating a postorder list of CrateNums" }
22722272
}
22732273
/// Returns whether or not the crate with CrateNum 'cnum'
22742274
/// is marked as a private dependency
22752275
query is_private_dep(c: CrateNum) -> bool {
2276-
eval_always
2276+
no_incremental
22772277
desc { "checking whether crate `{}` is a private dependency", c }
22782278
separate_provide_extern
22792279
}
22802280
query allocator_kind(_: ()) -> Option<AllocatorKind> {
2281-
eval_always
2281+
no_incremental
22822282
desc { "getting the allocator kind for the current crate" }
22832283
}
22842284
query alloc_error_handler_kind(_: ()) -> Option<AllocatorKind> {
2285-
eval_always
2285+
no_incremental
22862286
desc { "alloc error handler kind for the current crate" }
22872287
}
22882288

@@ -2293,14 +2293,14 @@ rustc_queries! {
22932293
/// All available crates in the graph, including those that should not be user-facing
22942294
/// (such as private crates).
22952295
query crates(_: ()) -> &'tcx [CrateNum] {
2296-
eval_always
2296+
no_incremental
22972297
desc { "fetching all foreign CrateNum instances" }
22982298
}
22992299
// Crates that are loaded non-speculatively (not for diagnostics or doc links).
23002300
// FIXME: This is currently only used for collecting lang items, but should be used instead of
23012301
// `crates` in most other cases too.
23022302
query used_crates(_: ()) -> &'tcx [CrateNum] {
2303-
eval_always
2303+
no_incremental
23042304
desc { "fetching `CrateNum`s for all crates loaded non-speculatively" }
23052305
}
23062306

@@ -2356,7 +2356,7 @@ rustc_queries! {
23562356
}
23572357

23582358
query collect_and_partition_mono_items(_: ()) -> MonoItemPartitions<'tcx> {
2359-
eval_always
2359+
no_incremental
23602360
desc { "collect_and_partition_mono_items" }
23612361
}
23622362

@@ -2543,13 +2543,13 @@ rustc_queries! {
25432543
/// Returns the Rust target features for the current target. These are not always the same as LLVM target features!
25442544
query rust_target_features(_: CrateNum) -> &'tcx UnordMap<String, rustc_target::target_features::Stability> {
25452545
arena_cache
2546-
eval_always
2546+
no_incremental
25472547
desc { "looking up Rust target features" }
25482548
}
25492549

25502550
query implied_target_features(feature: Symbol) -> &'tcx Vec<Symbol> {
25512551
arena_cache
2552-
eval_always
2552+
no_incremental
25532553
desc { "looking up implied target features" }
25542554
}
25552555

@@ -2599,7 +2599,7 @@ rustc_queries! {
25992599
key: (ty::Predicate<'tcx>, WellFormedLoc)
26002600
) -> Option<&'tcx ObligationCause<'tcx>> {
26012601
arena_cache
2602-
eval_always
2602+
no_incremental
26032603
no_hash
26042604
desc { "performing HIR wf-checking for predicate `{:?}` at item `{:?}`", key.0, key.1 }
26052605
}
@@ -2608,7 +2608,7 @@ rustc_queries! {
26082608
/// `--target` and similar).
26092609
query global_backend_features(_: ()) -> &'tcx Vec<String> {
26102610
arena_cache
2611-
eval_always
2611+
no_incremental
26122612
desc { "computing the backend features for CLI flags" }
26132613
}
26142614

@@ -2631,13 +2631,13 @@ rustc_queries! {
26312631
}
26322632

26332633
query doc_link_resolutions(def_id: DefId) -> &'tcx DocLinkResMap {
2634-
eval_always
2634+
no_incremental
26352635
desc { "resolutions for documentation links for a module" }
26362636
separate_provide_extern
26372637
}
26382638

26392639
query doc_link_traits_in_scope(def_id: DefId) -> &'tcx [DefId] {
2640-
eval_always
2640+
no_incremental
26412641
desc { "traits in scope for documentation links for a module" }
26422642
separate_provide_extern
26432643
}

compiler/rustc_middle/src/query/plumbing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use crate::ty::TyCtxt;
2020

2121
pub struct DynamicQuery<'tcx, C: QueryCache> {
2222
pub name: &'static str,
23-
pub eval_always: bool,
23+
pub no_incremental: bool,
2424
pub dep_kind: DepKind,
2525
pub handle_cycle_error: HandleCycleError,
2626
// Offset of this query's state field in the QueryStates struct

compiler/rustc_query_impl/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ where
167167
}
168168

169169
#[inline(always)]
170-
fn eval_always(self) -> bool {
171-
self.dynamic.eval_always
170+
fn no_incremental(self) -> bool {
171+
self.dynamic.no_incremental
172172
}
173173

174174
#[inline(always)]

0 commit comments

Comments
 (0)