Rename trait DepNodeParams to DepNodeKey
This commit is contained in:
parent
7b01330133
commit
4429f0916c
8 changed files with 29 additions and 26 deletions
|
|
@ -2,12 +2,12 @@ use rustc_data_structures::fingerprint::Fingerprint;
|
|||
use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE, LocalDefId, LocalModDefId, ModDefId};
|
||||
use rustc_hir::definitions::DefPathHash;
|
||||
use rustc_hir::{HirId, ItemLocalId, OwnerId};
|
||||
use rustc_query_system::dep_graph::{DepContext, DepNode, DepNodeParams, FingerprintStyle};
|
||||
use rustc_query_system::dep_graph::{DepContext, DepNode, DepNodeKey, FingerprintStyle};
|
||||
|
||||
use crate::dep_graph::DepNodeExt;
|
||||
use crate::ty::TyCtxt;
|
||||
|
||||
impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for () {
|
||||
impl<'tcx> DepNodeKey<TyCtxt<'tcx>> for () {
|
||||
#[inline(always)]
|
||||
fn fingerprint_style() -> FingerprintStyle {
|
||||
FingerprintStyle::Unit
|
||||
|
|
@ -24,7 +24,7 @@ impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for () {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for DefId {
|
||||
impl<'tcx> DepNodeKey<TyCtxt<'tcx>> for DefId {
|
||||
#[inline(always)]
|
||||
fn fingerprint_style() -> FingerprintStyle {
|
||||
FingerprintStyle::DefPathHash
|
||||
|
|
@ -46,7 +46,7 @@ impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for DefId {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for LocalDefId {
|
||||
impl<'tcx> DepNodeKey<TyCtxt<'tcx>> for LocalDefId {
|
||||
#[inline(always)]
|
||||
fn fingerprint_style() -> FingerprintStyle {
|
||||
FingerprintStyle::DefPathHash
|
||||
|
|
@ -68,7 +68,7 @@ impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for LocalDefId {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for OwnerId {
|
||||
impl<'tcx> DepNodeKey<TyCtxt<'tcx>> for OwnerId {
|
||||
#[inline(always)]
|
||||
fn fingerprint_style() -> FingerprintStyle {
|
||||
FingerprintStyle::DefPathHash
|
||||
|
|
@ -90,7 +90,7 @@ impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for OwnerId {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for CrateNum {
|
||||
impl<'tcx> DepNodeKey<TyCtxt<'tcx>> for CrateNum {
|
||||
#[inline(always)]
|
||||
fn fingerprint_style() -> FingerprintStyle {
|
||||
FingerprintStyle::DefPathHash
|
||||
|
|
@ -113,7 +113,7 @@ impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for CrateNum {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for (DefId, DefId) {
|
||||
impl<'tcx> DepNodeKey<TyCtxt<'tcx>> for (DefId, DefId) {
|
||||
#[inline(always)]
|
||||
fn fingerprint_style() -> FingerprintStyle {
|
||||
FingerprintStyle::Opaque
|
||||
|
|
@ -140,7 +140,7 @@ impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for (DefId, DefId) {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for HirId {
|
||||
impl<'tcx> DepNodeKey<TyCtxt<'tcx>> for HirId {
|
||||
#[inline(always)]
|
||||
fn fingerprint_style() -> FingerprintStyle {
|
||||
FingerprintStyle::HirId
|
||||
|
|
@ -183,7 +183,7 @@ impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for HirId {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for ModDefId {
|
||||
impl<'tcx> DepNodeKey<TyCtxt<'tcx>> for ModDefId {
|
||||
#[inline(always)]
|
||||
fn fingerprint_style() -> FingerprintStyle {
|
||||
FingerprintStyle::DefPathHash
|
||||
|
|
@ -205,7 +205,7 @@ impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for ModDefId {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for LocalModDefId {
|
||||
impl<'tcx> DepNodeKey<TyCtxt<'tcx>> for LocalModDefId {
|
||||
#[inline(always)]
|
||||
fn fingerprint_style() -> FingerprintStyle {
|
||||
FingerprintStyle::DefPathHash
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
//! Helper functions that serve as the immediate implementation of
|
||||
//! `tcx.$query(..)` and its variations.
|
||||
|
||||
use rustc_query_system::dep_graph::{DepKind, DepNodeParams};
|
||||
use rustc_query_system::dep_graph::{DepKind, DepNodeKey};
|
||||
use rustc_query_system::query::{QueryCache, QueryMode, try_get_cached};
|
||||
use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span};
|
||||
|
||||
|
|
@ -86,7 +86,7 @@ pub(crate) fn query_feed<'tcx, Cache>(
|
|||
value: Cache::Value,
|
||||
) where
|
||||
Cache: QueryCache,
|
||||
Cache::Key: DepNodeParams<TyCtxt<'tcx>>,
|
||||
Cache::Key: DepNodeKey<TyCtxt<'tcx>>,
|
||||
{
|
||||
let format_value = query_vtable.format_value;
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ use rustc_middle::ty::codec::TyEncoder;
|
|||
use rustc_middle::ty::print::with_reduced_queries;
|
||||
use rustc_middle::ty::tls::{self, ImplicitCtxt};
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
use rustc_query_system::dep_graph::{DepNodeParams, FingerprintStyle, HasDepContext};
|
||||
use rustc_query_system::dep_graph::{DepNodeKey, FingerprintStyle, HasDepContext};
|
||||
use rustc_query_system::ich::StableHashingContext;
|
||||
use rustc_query_system::query::{
|
||||
QueryCache, QueryContext, QueryDispatcher, QueryJobId, QueryMap, QuerySideEffect,
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ impl DepNode {
|
|||
pub fn construct<Tcx, Key>(tcx: Tcx, kind: DepKind, arg: &Key) -> DepNode
|
||||
where
|
||||
Tcx: super::DepContext,
|
||||
Key: DepNodeParams<Tcx>,
|
||||
Key: DepNodeKey<Tcx>,
|
||||
{
|
||||
let hash = arg.to_fingerprint(tcx);
|
||||
let dep_node = DepNode { kind, hash: hash.into() };
|
||||
|
|
@ -167,13 +167,15 @@ impl fmt::Debug for DepNode {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait DepNodeParams<Tcx: DepContext>: fmt::Debug + Sized {
|
||||
/// Trait for query keys as seen by dependency-node tracking.
|
||||
pub trait DepNodeKey<Tcx: DepContext>: fmt::Debug + Sized {
|
||||
fn fingerprint_style() -> FingerprintStyle;
|
||||
|
||||
/// This method turns the parameters of a DepNodeConstructor into an opaque
|
||||
/// Fingerprint to be used in DepNode.
|
||||
/// Not all DepNodeParams support being turned into a Fingerprint (they
|
||||
/// don't need to if the corresponding DepNode is anonymous).
|
||||
/// This method turns a query key into an opaque `Fingerprint` to be used
|
||||
/// in `DepNode`.
|
||||
///
|
||||
/// Not all `DepNodeKey` impls support being turned into a `Fingerprint`
|
||||
/// (they don't need to if the corresponding `DepNode` is anonymous).
|
||||
fn to_fingerprint(&self, _: Tcx) -> Fingerprint {
|
||||
panic!("Not implemented. Accidentally called on anonymous node?")
|
||||
}
|
||||
|
|
@ -189,7 +191,8 @@ pub trait DepNodeParams<Tcx: DepContext>: fmt::Debug + Sized {
|
|||
fn recover(tcx: Tcx, dep_node: &DepNode) -> Option<Self>;
|
||||
}
|
||||
|
||||
impl<Tcx: DepContext, T> DepNodeParams<Tcx> for T
|
||||
// Blanket impl of `DepNodeKey`, which is specialized by other impls elsewhere.
|
||||
impl<Tcx: DepContext, T> DepNodeKey<Tcx> for T
|
||||
where
|
||||
T: for<'a> HashStable<StableHashingContext<'a>> + fmt::Debug,
|
||||
{
|
||||
|
|
@ -239,7 +242,7 @@ pub struct DepKindVTable<Tcx: DepContext> {
|
|||
|
||||
/// Indicates whether and how the query key can be recovered from its hashed fingerprint.
|
||||
///
|
||||
/// The [`DepNodeParams`] trait determines the fingerprint style for each key type.
|
||||
/// The [`DepNodeKey`] trait determines the fingerprint style for each key type.
|
||||
pub fingerprint_style: FingerprintStyle,
|
||||
|
||||
/// The red/green evaluation system will try to mark a specific DepNode in the
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ mod serialized;
|
|||
|
||||
use std::panic;
|
||||
|
||||
pub use dep_node::{DepKind, DepKindVTable, DepNode, DepNodeParams, WorkProductId};
|
||||
pub use dep_node::{DepKind, DepKindVTable, DepNode, DepNodeKey, WorkProductId};
|
||||
pub(crate) use graph::DepGraphData;
|
||||
pub use graph::{DepGraph, DepNodeIndex, TaskDepsRef, WorkProduct, WorkProductMap, hash_result};
|
||||
pub use query::DepGraphQuery;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use rustc_data_structures::fingerprint::Fingerprint;
|
|||
use rustc_span::ErrorGuaranteed;
|
||||
|
||||
use super::QueryStackFrameExtra;
|
||||
use crate::dep_graph::{DepKind, DepNode, DepNodeParams, HasDepContext, SerializedDepNodeIndex};
|
||||
use crate::dep_graph::{DepKind, DepNode, DepNodeKey, HasDepContext, SerializedDepNodeIndex};
|
||||
use crate::ich::StableHashingContext;
|
||||
use crate::query::caches::QueryCache;
|
||||
use crate::query::{CycleError, CycleErrorHandling, DepNodeIndex, QueryContext, QueryState};
|
||||
|
|
@ -33,7 +33,7 @@ pub trait QueryDispatcher<'tcx>: Copy + 'tcx {
|
|||
|
||||
// `Key` and `Value` are `Copy` instead of `Clone` to ensure copying them stays cheap,
|
||||
// but it isn't necessary.
|
||||
type Key: DepNodeParams<DepContextOf<'tcx, Self>> + Eq + Hash + Copy + Debug;
|
||||
type Key: DepNodeKey<DepContextOf<'tcx, Self>> + Eq + Hash + Copy + Debug;
|
||||
type Value: Copy;
|
||||
|
||||
type Cache: QueryCache<Key = Self::Key, Value = Self::Value>;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ use tracing::instrument;
|
|||
|
||||
use super::{QueryDispatcher, QueryStackDeferred, QueryStackFrameExtra};
|
||||
use crate::dep_graph::{
|
||||
DepContext, DepGraphData, DepNode, DepNodeIndex, DepNodeParams, HasDepContext,
|
||||
DepContext, DepGraphData, DepNode, DepNodeIndex, DepNodeKey, HasDepContext,
|
||||
};
|
||||
use crate::ich::StableHashingContext;
|
||||
use crate::query::caches::QueryCache;
|
||||
|
|
|
|||
|
|
@ -540,7 +540,7 @@ macro_rules! typed_def_id {
|
|||
}
|
||||
|
||||
// N.B.: when adding new typed `DefId`s update the corresponding trait impls in
|
||||
// `rustc_middle::dep_graph::def_node` for `DepNodeParams`.
|
||||
// `rustc_middle::dep_graph::dep_node_key` for `DepNodeKey`.
|
||||
typed_def_id! { ModDefId, LocalModDefId }
|
||||
|
||||
impl LocalModDefId {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue