Skip to content

Commit 5b08aad

Browse files
authored
Rollup merge of #69475 - Zoxc:no-no-force, r=michaelwoerister
Remove the `no_force` query attribute This removes the `no_force` query attribute and instead uses the `DepNodeParams` trait to find out if a query can be forced. Also the `analysis` query is moved to the query macro. r? @eddyb
2 parents 3dbade6 + 2f12009 commit 5b08aad

File tree

7 files changed

+161
-237
lines changed

7 files changed

+161
-237
lines changed

src/librustc/dep_graph/dep_node.rs

+25-25
Original file line numberDiff line numberDiff line change
@@ -360,33 +360,9 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx>
360360
[anon] TraitSelect,
361361

362362
[] CompileCodegenUnit(Symbol),
363-
364-
[eval_always] Analysis(CrateNum),
365363
]);
366364

367-
pub trait RecoverKey<'tcx>: Sized {
368-
fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self>;
369-
}
370-
371-
impl RecoverKey<'tcx> for CrateNum {
372-
fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
373-
dep_node.extract_def_id(tcx).map(|id| id.krate)
374-
}
375-
}
376-
377-
impl RecoverKey<'tcx> for DefId {
378-
fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
379-
dep_node.extract_def_id(tcx)
380-
}
381-
}
382-
383-
impl RecoverKey<'tcx> for DefIndex {
384-
fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
385-
dep_node.extract_def_id(tcx).map(|id| id.index)
386-
}
387-
}
388-
389-
trait DepNodeParams<'tcx>: fmt::Debug {
365+
pub(crate) trait DepNodeParams<'tcx>: fmt::Debug + Sized {
390366
const CAN_RECONSTRUCT_QUERY_KEY: bool;
391367

392368
/// This method turns the parameters of a DepNodeConstructor into an opaque
@@ -400,6 +376,14 @@ trait DepNodeParams<'tcx>: fmt::Debug {
400376
fn to_debug_str(&self, _: TyCtxt<'tcx>) -> String {
401377
format!("{:?}", self)
402378
}
379+
380+
/// This method tries to recover the query key from the given `DepNode`,
381+
/// something which is needed when forcing `DepNode`s during red-green
382+
/// evaluation. The query system will only call this method if
383+
/// `CAN_RECONSTRUCT_QUERY_KEY` is `true`.
384+
/// It is always valid to return `None` here, in which case incremental
385+
/// compilation will treat the query as having changed instead of forcing it.
386+
fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self>;
403387
}
404388

405389
impl<'tcx, T> DepNodeParams<'tcx> for T
@@ -420,6 +404,10 @@ where
420404
default fn to_debug_str(&self, _: TyCtxt<'tcx>) -> String {
421405
format!("{:?}", *self)
422406
}
407+
408+
default fn recover(_: TyCtxt<'tcx>, _: &DepNode) -> Option<Self> {
409+
None
410+
}
423411
}
424412

425413
impl<'tcx> DepNodeParams<'tcx> for DefId {
@@ -432,6 +420,10 @@ impl<'tcx> DepNodeParams<'tcx> for DefId {
432420
fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String {
433421
tcx.def_path_str(*self)
434422
}
423+
424+
fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
425+
dep_node.extract_def_id(tcx)
426+
}
435427
}
436428

437429
impl<'tcx> DepNodeParams<'tcx> for DefIndex {
@@ -444,6 +436,10 @@ impl<'tcx> DepNodeParams<'tcx> for DefIndex {
444436
fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String {
445437
tcx.def_path_str(DefId::local(*self))
446438
}
439+
440+
fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
441+
dep_node.extract_def_id(tcx).map(|id| id.index)
442+
}
447443
}
448444

449445
impl<'tcx> DepNodeParams<'tcx> for CrateNum {
@@ -457,6 +453,10 @@ impl<'tcx> DepNodeParams<'tcx> for CrateNum {
457453
fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String {
458454
tcx.crate_name(*self).to_string()
459455
}
456+
457+
fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
458+
dep_node.extract_def_id(tcx).map(|id| id.krate)
459+
}
460460
}
461461

462462
impl<'tcx> DepNodeParams<'tcx> for (DefId, DefId) {

src/librustc/dep_graph/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ mod query;
66
mod safe;
77
mod serialized;
88

9-
pub use self::dep_node::{label_strs, DepConstructor, DepKind, DepNode, RecoverKey, WorkProductId};
9+
pub(crate) use self::dep_node::DepNodeParams;
10+
pub use self::dep_node::{label_strs, DepConstructor, DepKind, DepNode, WorkProductId};
1011
pub use self::graph::WorkProductFileKind;
1112
pub use self::graph::{hash_result, DepGraph, DepNodeColor, DepNodeIndex, TaskDeps, WorkProduct};
1213
pub use self::prev::PreviousDepGraph;

0 commit comments

Comments
 (0)