Skip to content

Commit ccc8d00

Browse files
committed
Move some more code from rustc_middle to rustc_query_system
1 parent f3f91bb commit ccc8d00

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

compiler/rustc_middle/src/dep_graph/dep_node.rs

+1-14
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ macro_rules! define_dep_nodes {
8686
$( $( #[$attr] )* $variant),*
8787
}
8888

89-
fn dep_kind_from_label_string(label: &str) -> Result<DepKind, ()> {
89+
pub(super) fn dep_kind_from_label_string(label: &str) -> Result<DepKind, ()> {
9090
match label {
9191
$(stringify!($variant) => Ok(DepKind::$variant),)*
9292
_ => Err(()),
@@ -141,11 +141,6 @@ static_assert_size!(DepNode, 18);
141141
static_assert_size!(DepNode, 24);
142142

143143
pub trait DepNodeExt: Sized {
144-
/// Construct a DepNode from the given DepKind and DefPathHash. This
145-
/// method will assert that the given DepKind actually requires a
146-
/// single DefId/DefPathHash parameter.
147-
fn from_def_path_hash(tcx: TyCtxt<'_>, def_path_hash: DefPathHash, kind: DepKind) -> Self;
148-
149144
/// Extracts the DefId corresponding to this DepNode. This will work
150145
/// if two conditions are met:
151146
///
@@ -170,14 +165,6 @@ pub trait DepNodeExt: Sized {
170165
}
171166

172167
impl DepNodeExt for DepNode {
173-
/// Construct a DepNode from the given DepKind and DefPathHash. This
174-
/// method will assert that the given DepKind actually requires a
175-
/// single DefId/DefPathHash parameter.
176-
fn from_def_path_hash(tcx: TyCtxt<'_>, def_path_hash: DefPathHash, kind: DepKind) -> DepNode {
177-
debug_assert!(tcx.fingerprint_style(kind) == FingerprintStyle::DefPathHash);
178-
DepNode { kind, hash: def_path_hash.0.into() }
179-
}
180-
181168
/// Extracts the DefId corresponding to this DepNode. This will work
182169
/// if two conditions are met:
183170
///

compiler/rustc_query_system/src/dep_graph/dep_node.rs

+12
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ use crate::ich::StableHashingContext;
4747

4848
use rustc_data_structures::fingerprint::{Fingerprint, PackedFingerprint};
4949
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
50+
use rustc_hir::definitions::DefPathHash;
5051
use std::fmt;
5152
use std::hash::Hash;
5253

@@ -88,6 +89,17 @@ impl<K: DepKind> DepNode<K> {
8889

8990
dep_node
9091
}
92+
93+
/// Construct a DepNode from the given DepKind and DefPathHash. This
94+
/// method will assert that the given DepKind actually requires a
95+
/// single DefId/DefPathHash parameter.
96+
pub fn from_def_path_hash<Ctxt>(tcx: Ctxt, def_path_hash: DefPathHash, kind: K) -> Self
97+
where
98+
Ctxt: super::DepContext<DepKind = K>,
99+
{
100+
debug_assert!(tcx.fingerprint_style(kind) == FingerprintStyle::DefPathHash);
101+
DepNode { kind, hash: def_path_hash.0.into() }
102+
}
91103
}
92104

93105
impl<K: DepKind> fmt::Debug for DepNode<K> {

0 commit comments

Comments
 (0)