Skip to content

Commit

Permalink
Drop has_params.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Oct 20, 2021
1 parent aa404c2 commit dc71433
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 40 deletions.
24 changes: 1 addition & 23 deletions compiler/rustc_middle/src/dep_graph/dep_node.rs
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -156,31 +146,27 @@ 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,

fingerprint_style: || FingerprintStyle::Unit,
};

pub const TraitSelect: DepKindStruct = DepKindStruct {
has_params: false,
is_anon: true,
is_eval_always: false,

fingerprint_style: || FingerprintStyle::Unit,
};

pub const CompileCodegenUnit: DepKindStruct = DepKindStruct {
has_params: true,
is_anon: false,
is_eval_always: false,

fingerprint_style: || FingerprintStyle::Opaque,
};

pub const CompileMonoItem: DepKindStruct = DepKindStruct {
has_params: true,
is_anon: false,
is_eval_always: false,

Expand All @@ -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)*);

Expand All @@ -204,7 +189,6 @@ pub mod dep_kind {
}

DepKindStruct {
has_params,
is_anon,
is_eval_always,
fingerprint_style,
Expand Down Expand Up @@ -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)),
}
}
Expand Down
13 changes: 1 addition & 12 deletions compiler/rustc_middle/src/dep_graph/mod.rs
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_query_system/src/dep_graph/dep_node.rs
Expand Up @@ -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() }
}

Expand Down
5 changes: 1 addition & 4 deletions compiler/rustc_query_system/src/dep_graph/mod.rs
Expand Up @@ -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,
Expand All @@ -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;

Expand Down

0 comments on commit dc71433

Please sign in to comment.