Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_data_structures/src/steal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl<T> Steal<T> {

#[track_caller]
pub fn steal(&self) -> T {
let value_ref = &mut *self.value.try_write().expect("stealing value which is locked");
let mut value_ref = self.value.write();
let value = value_ref.take();
value.expect("attempt to steal from stolen value")
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/dep_graph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ pub use dep_node::{DepKind, DepNode, DepNodeExt, dep_kinds, label_strs};
pub(crate) use dep_node::{make_compile_codegen_unit, make_compile_mono_item, make_metadata};
pub use rustc_query_system::dep_graph::debug::{DepNodeFilter, EdgeFilter};
pub use rustc_query_system::dep_graph::{
DepContext, DepGraphQuery, DepNodeIndex, Deps, SerializedDepGraph, SerializedDepNodeIndex,
TaskDepsRef, WorkProduct, WorkProductId, WorkProductMap, hash_result,
DepContext, DepGraphQuery, DepNodeIndex, Deps, MarkFrame, SerializedDepGraph,
SerializedDepNodeIndex, TaskDepsRef, WorkProduct, WorkProductId, WorkProductMap, hash_result,
};

pub type DepGraph = rustc_query_system::dep_graph::DepGraph<DepsType>;
Expand Down
25 changes: 15 additions & 10 deletions compiler/rustc_query_impl/src/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use rustc_hir::limit::Limit;
use rustc_index::Idx;
use rustc_middle::bug;
use rustc_middle::dep_graph::{
self, DepContext, DepKind, DepKindStruct, DepNode, DepNodeIndex, SerializedDepNodeIndex,
dep_kinds,
self, DepContext, DepKind, DepKindStruct, DepNode, DepNodeIndex, MarkFrame,
SerializedDepNodeIndex, dep_kinds,
};
use rustc_middle::query::Key;
use rustc_middle::query::on_disk_cache::{
Expand Down Expand Up @@ -489,7 +489,12 @@ where
value
}

fn force_from_dep_node<'tcx, Q>(query: Q, tcx: TyCtxt<'tcx>, dep_node: DepNode) -> bool
fn force_from_dep_node<'tcx, Q>(
query: Q,
tcx: TyCtxt<'tcx>,
dep_node: DepNode,
frame: &MarkFrame<'_>,
) -> bool
where
Q: QueryConfig<QueryCtxt<'tcx>>,
{
Expand All @@ -512,7 +517,7 @@ where
);

if let Some(key) = Q::Key::recover(tcx, &dep_node) {
force_query(query, QueryCtxt::new(tcx), key, dep_node);
force_query(query, QueryCtxt::new(tcx), key, dep_node, frame);
true
} else {
false
Expand Down Expand Up @@ -540,8 +545,8 @@ where
is_anon,
is_eval_always,
fingerprint_style,
force_from_dep_node: Some(|tcx, dep_node, _| {
force_from_dep_node(Q::config(tcx), tcx, dep_node)
force_from_dep_node: Some(|tcx, dep_node, _, frame| {
force_from_dep_node(Q::config(tcx), tcx, dep_node, frame)
}),
try_load_from_on_disk_cache: Some(|tcx, dep_node| {
try_load_from_on_disk_cache(Q::config(tcx), tcx, dep_node)
Expand Down Expand Up @@ -853,7 +858,7 @@ macro_rules! define_queries {
is_anon: false,
is_eval_always: false,
fingerprint_style: FingerprintStyle::Unit,
force_from_dep_node: Some(|_, dep_node, _| bug!("force_from_dep_node: encountered {:?}", dep_node)),
force_from_dep_node: Some(|_, dep_node, _, _| bug!("force_from_dep_node: encountered {:?}", dep_node)),
try_load_from_on_disk_cache: None,
name: &"Null",
}
Expand All @@ -865,7 +870,7 @@ macro_rules! define_queries {
is_anon: false,
is_eval_always: false,
fingerprint_style: FingerprintStyle::Unit,
force_from_dep_node: Some(|_, dep_node, _| bug!("force_from_dep_node: encountered {:?}", dep_node)),
force_from_dep_node: Some(|_, dep_node, _, _| bug!("force_from_dep_node: encountered {:?}", dep_node)),
try_load_from_on_disk_cache: None,
name: &"Red",
}
Expand All @@ -876,7 +881,7 @@ macro_rules! define_queries {
is_anon: false,
is_eval_always: false,
fingerprint_style: FingerprintStyle::Unit,
force_from_dep_node: Some(|tcx, _, prev_index| {
force_from_dep_node: Some(|tcx, _, prev_index, _| {
tcx.dep_graph.force_diagnostic_node(QueryCtxt::new(tcx), prev_index);
true
}),
Expand All @@ -890,7 +895,7 @@ macro_rules! define_queries {
is_anon: true,
is_eval_always: false,
fingerprint_style: FingerprintStyle::Opaque,
force_from_dep_node: Some(|_, _, _| bug!("cannot force an anon node")),
force_from_dep_node: Some(|_, _, _, _| bug!("cannot force an anon node")),
try_load_from_on_disk_cache: None,
name: &"AnonZeroDeps",
}
Expand Down
11 changes: 9 additions & 2 deletions compiler/rustc_query_system/src/dep_graph/dep_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ use rustc_hir::definitions::DefPathHash;
use rustc_macros::{Decodable, Encodable};

use super::{DepContext, FingerprintStyle, SerializedDepNodeIndex};
use crate::dep_graph::graph::MarkFrame;
use crate::ich::StableHashingContext;

/// This serves as an index into arrays built by `make_dep_kind_array`.
Expand Down Expand Up @@ -276,8 +277,14 @@ pub struct DepKindStruct<Tcx: DepContext> {
/// with kind `MirValidated`, we know that the GUID/fingerprint of the `DepNode`
/// is actually a `DefPathHash`, and can therefore just look up the corresponding
/// `DefId` in `tcx.def_path_hash_to_def_id`.
pub force_from_dep_node:
Option<fn(tcx: Tcx, dep_node: DepNode, prev_index: SerializedDepNodeIndex) -> bool>,
pub force_from_dep_node: Option<
fn(
tcx: Tcx,
dep_node: DepNode,
prev_index: SerializedDepNodeIndex,
frame: &MarkFrame<'_>,
) -> bool,
>,

/// Invoke a query to put the on-disk cached value in memory.
pub try_load_from_on_disk_cache: Option<fn(Tcx, DepNode)>,
Expand Down
Loading
Loading