Drop has_params.

This commit is contained in:
Camille GILLOT 2021-10-16 21:24:10 +02:00
parent aa404c24dd
commit dc7143367c
4 changed files with 4 additions and 40 deletions

View File

@ -75,9 +75,6 @@ pub use rustc_query_system::dep_graph::{DepContext, DepNodeParams};
/// of the `DepKind`. Overall, this allows to implement `DepContext` using this manual
/// jump table instead of large matches.
pub struct DepKindStruct {
/// Whether the DepNode has parameters (query keys).
pub(super) has_params: bool,
/// Anonymous queries cannot be replayed from one compiler invocation to the next.
/// When their result is needed, it is recomputed. They are useful for fine-grained
/// dependency tracking, and caching within one compiler invocation.
@ -115,13 +112,6 @@ impl DepKind {
}
}
// erase!() just makes tokens go away. It's used to specify which macro argument
// is repeated (i.e., which sub-expression of the macro we are in) but don't need
// to actually use any of the arguments.
macro_rules! erase {
($x:tt) => {{}};
}
macro_rules! is_anon_attr {
(anon) => {
true
@ -156,7 +146,6 @@ pub mod dep_kind {
// We use this for most things when incr. comp. is turned off.
pub const Null: DepKindStruct = DepKindStruct {
has_params: false,
is_anon: false,
is_eval_always: false,
@ -164,7 +153,6 @@ pub mod dep_kind {
};
pub const TraitSelect: DepKindStruct = DepKindStruct {
has_params: false,
is_anon: true,
is_eval_always: false,
@ -172,7 +160,6 @@ pub mod dep_kind {
};
pub const CompileCodegenUnit: DepKindStruct = DepKindStruct {
has_params: true,
is_anon: false,
is_eval_always: false,
@ -180,7 +167,6 @@ pub mod dep_kind {
};
pub const CompileMonoItem: DepKindStruct = DepKindStruct {
has_params: true,
is_anon: false,
is_eval_always: false,
@ -193,7 +179,6 @@ pub mod dep_kind {
$variant:ident $(( $tuple_arg_ty:ty $(,)? ))*
,)*) => (
$(pub const $variant: DepKindStruct = {
const has_params: bool = $({ erase!($tuple_arg_ty); true } |)* false;
const is_anon: bool = contains_anon_attr!($($attrs)*);
const is_eval_always: bool = contains_eval_always_attr!($($attrs)*);
@ -204,7 +189,6 @@ pub mod dep_kind {
}
DepKindStruct {
has_params,
is_anon,
is_eval_always,
fingerprint_style,
@ -350,13 +334,7 @@ impl DepNodeExt for DepNode {
match kind.fingerprint_style() {
FingerprintStyle::Opaque => Err(()),
FingerprintStyle::Unit => {
if !kind.has_params {
Ok(DepNode::new_no_params(kind))
} else {
Err(())
}
}
FingerprintStyle::Unit => Ok(DepNode::new_no_params(kind)),
FingerprintStyle::DefPathHash => Ok(DepNode::from_def_path_hash(def_path_hash, kind)),
}
}

View File

@ -34,19 +34,8 @@ impl rustc_query_system::dep_graph::DepKind for DepKind {
self.is_eval_always
}
#[inline(always)]
fn has_params(&self) -> bool {
self.has_params
}
fn debug_node(node: &DepNode, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", node.kind)?;
if !node.kind.has_params && !node.kind.is_anon {
return Ok(());
}
write!(f, "(")?;
write!(f, "{:?}(", node.kind)?;
ty::tls::with_opt(|opt_tcx| {
if let Some(tcx) = opt_tcx {

View File

@ -61,7 +61,7 @@ impl<K: DepKind> DepNode<K> {
/// that the DepNode corresponding to the given DepKind actually
/// does not require any parameters.
pub fn new_no_params(kind: K) -> DepNode<K> {
debug_assert!(!kind.has_params());
debug_assert_eq!(kind.fingerprint_style(), FingerprintStyle::Unit);
DepNode { kind, hash: Fingerprint::ZERO.into() }
}

View File

@ -51,7 +51,7 @@ impl<T: DepContext> HasDepContext for T {
}
/// Describes the contents of the fingerprint generated by a given query.
#[derive(PartialEq, Eq, Copy, Clone)]
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
pub enum FingerprintStyle {
/// The fingerprint is actually a DefPathHash.
DefPathHash,
@ -78,9 +78,6 @@ pub trait DepKind: Copy + fmt::Debug + Eq + Hash + Send + Encodable<FileEncoder>
/// Return whether this kind always require evaluation.
fn is_eval_always(&self) -> bool;
/// Return whether this kind requires additional parameters to be executed.
fn has_params(&self) -> bool;
/// Implementation of `std::fmt::Debug` for `DepNode`.
fn debug_node(node: &DepNode<Self>, f: &mut fmt::Formatter<'_>) -> fmt::Result;