Skip to content

Commit 1732f04

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 4056082 commit 1732f04

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

@@ -1409,7 +1409,7 @@ rustc_queries! {
14091409

14101410
/// Performs part of the privacy check and computes effective visibilities.
14111411
query effective_visibilities(_: ()) -> &'tcx EffectiveVisibilities {
1412-
eval_always
1412+
no_incremental
14131413
desc { "checking effective visibilities" }
14141414
}
14151415
query check_private_in_public(module_def_id: LocalModDefId) {
@@ -1814,14 +1814,14 @@ rustc_queries! {
18141814
}
18151815
query has_global_allocator(_: CrateNum) -> bool {
18161816
// This query depends on untracked global state in CStore
1817-
eval_always
1817+
no_incremental
18181818
fatal_cycle
18191819
desc { "checking if the crate has_global_allocator" }
18201820
separate_provide_extern
18211821
}
18221822
query has_alloc_error_handler(_: CrateNum) -> bool {
18231823
// This query depends on untracked global state in CStore
1824-
eval_always
1824+
no_incremental
18251825
fatal_cycle
18261826
desc { "checking if the crate has_alloc_error_handler" }
18271827
separate_provide_extern
@@ -1862,7 +1862,7 @@ rustc_queries! {
18621862
}
18631863

18641864
query extern_crate(def_id: CrateNum) -> Option<&'tcx ExternCrate> {
1865-
eval_always
1865+
no_incremental
18661866
desc { "getting crate's ExternCrateData" }
18671867
separate_provide_extern
18681868
}
@@ -2033,14 +2033,14 @@ rustc_queries! {
20332033
// compilation is enabled calculating this hash can freeze this structure too early in
20342034
// compilation and cause subsequent crashes when attempting to write to `definitions`
20352035
query crate_hash(_: CrateNum) -> Svh {
2036-
eval_always
2036+
no_incremental
20372037
desc { "looking up the hash a crate" }
20382038
separate_provide_extern
20392039
}
20402040

20412041
/// Gets the hash for the host proc macro. Used to support -Z dual-proc-macro.
20422042
query crate_host_hash(_: CrateNum) -> Option<Svh> {
2043-
eval_always
2043+
no_incremental
20442044
desc { "looking up the hash of a host version of a crate" }
20452045
separate_provide_extern
20462046
}
@@ -2049,15 +2049,15 @@ rustc_queries! {
20492049
/// For example, compiling the `foo` crate with `extra-filename=-a` creates a `libfoo-b.rlib` file.
20502050
query extra_filename(_: CrateNum) -> &'tcx String {
20512051
arena_cache
2052-
eval_always
2052+
no_incremental
20532053
desc { "looking up the extra filename for a crate" }
20542054
separate_provide_extern
20552055
}
20562056

20572057
/// Gets the paths where the crate came from in the file system.
20582058
query crate_extern_paths(_: CrateNum) -> &'tcx Vec<PathBuf> {
20592059
arena_cache
2060-
eval_always
2060+
no_incremental
20612061
desc { "looking up the paths for extern crates" }
20622062
separate_provide_extern
20632063
}
@@ -2168,7 +2168,7 @@ rustc_queries! {
21682168
}
21692169

21702170
query dep_kind(_: CrateNum) -> CrateDepKind {
2171-
eval_always
2171+
no_incremental
21722172
desc { "fetching what a dependency looks like" }
21732173
separate_provide_extern
21742174
}
@@ -2224,14 +2224,14 @@ rustc_queries! {
22242224
/// Returns the lang items defined in another crate by loading it from metadata.
22252225
query get_lang_items(_: ()) -> &'tcx LanguageItems {
22262226
arena_cache
2227-
eval_always
2227+
no_incremental
22282228
desc { "calculating the lang items map" }
22292229
}
22302230

22312231
/// Returns all diagnostic items defined in all crates.
22322232
query all_diagnostic_items(_: ()) -> &'tcx rustc_hir::diagnostic_items::DiagnosticItems {
22332233
arena_cache
2234-
eval_always
2234+
no_incremental
22352235
desc { "calculating the diagnostic items map" }
22362236
}
22372237

@@ -2268,45 +2268,45 @@ rustc_queries! {
22682268
desc { "calculating trimmed def paths" }
22692269
}
22702270
query missing_extern_crate_item(_: CrateNum) -> bool {
2271-
eval_always
2271+
no_incremental
22722272
desc { "seeing if we're missing an `extern crate` item for this crate" }
22732273
separate_provide_extern
22742274
}
22752275
query used_crate_source(_: CrateNum) -> &'tcx Arc<CrateSource> {
22762276
arena_cache
2277-
eval_always
2277+
no_incremental
22782278
desc { "looking at the source for a crate" }
22792279
separate_provide_extern
22802280
}
22812281

22822282
/// Returns the debugger visualizers defined for this crate.
2283-
/// NOTE: This query has to be marked `eval_always` because it reads data
2283+
/// NOTE: This query has to be marked `no_incremental` because it reads data
22842284
/// directly from disk that is not tracked anywhere else. I.e. it
22852285
/// represents a genuine input to the query system.
22862286
query debugger_visualizers(_: CrateNum) -> &'tcx Vec<DebuggerVisualizerFile> {
22872287
arena_cache
22882288
desc { "looking up the debugger visualizers for this crate" }
22892289
separate_provide_extern
2290-
eval_always
2290+
no_incremental
22912291
}
22922292

22932293
query postorder_cnums(_: ()) -> &'tcx [CrateNum] {
2294-
eval_always
2294+
no_incremental
22952295
desc { "generating a postorder list of CrateNums" }
22962296
}
22972297
/// Returns whether or not the crate with CrateNum 'cnum'
22982298
/// is marked as a private dependency
22992299
query is_private_dep(c: CrateNum) -> bool {
2300-
eval_always
2300+
no_incremental
23012301
desc { "checking whether crate `{}` is a private dependency", c }
23022302
separate_provide_extern
23032303
}
23042304
query allocator_kind(_: ()) -> Option<AllocatorKind> {
2305-
eval_always
2305+
no_incremental
23062306
desc { "getting the allocator kind for the current crate" }
23072307
}
23082308
query alloc_error_handler_kind(_: ()) -> Option<AllocatorKind> {
2309-
eval_always
2309+
no_incremental
23102310
desc { "alloc error handler kind for the current crate" }
23112311
}
23122312

@@ -2317,14 +2317,14 @@ rustc_queries! {
23172317
/// All available crates in the graph, including those that should not be user-facing
23182318
/// (such as private crates).
23192319
query crates(_: ()) -> &'tcx [CrateNum] {
2320-
eval_always
2320+
no_incremental
23212321
desc { "fetching all foreign CrateNum instances" }
23222322
}
23232323
// Crates that are loaded non-speculatively (not for diagnostics or doc links).
23242324
// FIXME: This is currently only used for collecting lang items, but should be used instead of
23252325
// `crates` in most other cases too.
23262326
query used_crates(_: ()) -> &'tcx [CrateNum] {
2327-
eval_always
2327+
no_incremental
23282328
desc { "fetching `CrateNum`s for all crates loaded non-speculatively" }
23292329
}
23302330

@@ -2380,7 +2380,7 @@ rustc_queries! {
23802380
}
23812381

23822382
query collect_and_partition_mono_items(_: ()) -> MonoItemPartitions<'tcx> {
2383-
eval_always
2383+
no_incremental
23842384
desc { "collect_and_partition_mono_items" }
23852385
}
23862386

@@ -2575,13 +2575,13 @@ rustc_queries! {
25752575
/// Returns the Rust target features for the current target. These are not always the same as LLVM target features!
25762576
query rust_target_features(_: CrateNum) -> &'tcx UnordMap<String, rustc_target::target_features::Stability> {
25772577
arena_cache
2578-
eval_always
2578+
no_incremental
25792579
desc { "looking up Rust target features" }
25802580
}
25812581

25822582
query implied_target_features(feature: Symbol) -> &'tcx Vec<Symbol> {
25832583
arena_cache
2584-
eval_always
2584+
no_incremental
25852585
desc { "looking up implied target features" }
25862586
}
25872587

@@ -2631,7 +2631,7 @@ rustc_queries! {
26312631
key: (ty::Predicate<'tcx>, WellFormedLoc)
26322632
) -> Option<&'tcx ObligationCause<'tcx>> {
26332633
arena_cache
2634-
eval_always
2634+
no_incremental
26352635
no_hash
26362636
desc { "performing HIR wf-checking for predicate `{:?}` at item `{:?}`", key.0, key.1 }
26372637
}
@@ -2640,7 +2640,7 @@ rustc_queries! {
26402640
/// `--target` and similar).
26412641
query global_backend_features(_: ()) -> &'tcx Vec<String> {
26422642
arena_cache
2643-
eval_always
2643+
no_incremental
26442644
desc { "computing the backend features for CLI flags" }
26452645
}
26462646

@@ -2663,13 +2663,13 @@ rustc_queries! {
26632663
}
26642664

26652665
query doc_link_resolutions(def_id: DefId) -> &'tcx DocLinkResMap {
2666-
eval_always
2666+
no_incremental
26672667
desc { "resolutions for documentation links for a module" }
26682668
separate_provide_extern
26692669
}
26702670

26712671
query doc_link_traits_in_scope(def_id: DefId) -> &'tcx [DefId] {
2672-
eval_always
2672+
no_incremental
26732673
desc { "traits in scope for documentation links for a module" }
26742674
separate_provide_extern
26752675
}

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)