diff options
Diffstat (limited to 'compiler/rustc_middle/src')
| -rw-r--r-- | compiler/rustc_middle/src/arena.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/dep_graph/dep_node.rs | 11 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/dep_graph/mod.rs | 15 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/context.rs | 2 |
4 files changed, 19 insertions, 11 deletions
diff --git a/compiler/rustc_middle/src/arena.rs b/compiler/rustc_middle/src/arena.rs index 4a027cb7ebe..420c500a7de 100644 --- a/compiler/rustc_middle/src/arena.rs +++ b/compiler/rustc_middle/src/arena.rs @@ -100,6 +100,8 @@ macro_rules! arena_types { // This is used to decode the &'tcx [Span] for InlineAsm's line_spans. [decode] span: rustc_span::Span, [decode] used_trait_imports: rustc_data_structures::fx::FxHashSet<rustc_hir::def_id::LocalDefId>, + + [] dep_kind: rustc_middle::dep_graph::DepKindStruct, ], $tcx); ) } diff --git a/compiler/rustc_middle/src/dep_graph/dep_node.rs b/compiler/rustc_middle/src/dep_graph/dep_node.rs index ee0b4ec7a60..cd7bd56182d 100644 --- a/compiler/rustc_middle/src/dep_graph/dep_node.rs +++ b/compiler/rustc_middle/src/dep_graph/dep_node.rs @@ -87,7 +87,7 @@ pub struct DepKindStruct { /// Whether the query key can be recovered from the hashed fingerprint. /// See [DepNodeParams] trait for the behaviour of each key type. - pub fingerprint_style: fn() -> FingerprintStyle, + pub fingerprint_style: FingerprintStyle, /// The red/green evaluation system will try to mark a specific DepNode in the /// dependency graph as green by recursively trying to mark the dependencies of @@ -131,10 +131,10 @@ pub struct DepKindStruct { /// then `force_from_dep_node()` should not fail for it. Otherwise, you can just /// add it to the "We don't have enough information to reconstruct..." group in /// the match below. - pub force_from_dep_node: fn(tcx: TyCtxt<'_>, dep_node: &DepNode) -> bool, + pub force_from_dep_node: Option<fn(tcx: TyCtxt<'_>, dep_node: DepNode) -> bool>, /// Invoke a query to put the on-disk cached value in memory. - pub try_load_from_on_disk_cache: fn(TyCtxt<'_>, &DepNode), + pub try_load_from_on_disk_cache: Option<fn(TyCtxt<'_>, DepNode)>, } impl DepKind { @@ -145,8 +145,7 @@ impl DepKind { if data.is_anon { return FingerprintStyle::Opaque; } - - (data.fingerprint_style)() + data.fingerprint_style } } @@ -159,7 +158,7 @@ macro_rules! define_dep_nodes { ) => ( #[macro_export] macro_rules! make_dep_kind_array { - ($mod:ident) => {[ $(($mod::$variant),)* ]}; + ($mod:ident) => {[ $($mod::$variant()),* ]}; } /// This enum serves as an index into arrays built by `make_dep_kind_array`. diff --git a/compiler/rustc_middle/src/dep_graph/mod.rs b/compiler/rustc_middle/src/dep_graph/mod.rs index 8ac3cef9040..79d7ca32f35 100644 --- a/compiler/rustc_middle/src/dep_graph/mod.rs +++ b/compiler/rustc_middle/src/dep_graph/mod.rs @@ -100,7 +100,7 @@ impl<'tcx> DepContext for TyCtxt<'tcx> { self.query_kind(kind).is_eval_always } - fn try_force_from_dep_node(&self, dep_node: &DepNode) -> bool { + fn try_force_from_dep_node(&self, dep_node: DepNode) -> bool { debug!("try_force_from_dep_node({:?}) --- trying to force", dep_node); // We must avoid ever having to call `force_from_dep_node()` for a @@ -122,11 +122,18 @@ impl<'tcx> DepContext for TyCtxt<'tcx> { ); let cb = self.query_kind(dep_node.kind); - (cb.force_from_dep_node)(*self, dep_node) + if let Some(f) = cb.force_from_dep_node { + f(*self, dep_node); + true + } else { + false + } } - fn try_load_from_on_disk_cache(&self, dep_node: &DepNode) { + fn try_load_from_on_disk_cache(&self, dep_node: DepNode) { let cb = self.query_kind(dep_node.kind); - (cb.try_load_from_on_disk_cache)(*self, dep_node) + if let Some(f) = cb.try_load_from_on_disk_cache { + f(*self, dep_node) + } } } diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index b00a2c65575..8240273acad 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -1186,7 +1186,7 @@ impl<'tcx> TyCtxt<'tcx> { } } - pub fn query_kind(self, k: DepKind) -> &'tcx DepKindStruct { + crate fn query_kind(self, k: DepKind) -> &'tcx DepKindStruct { &self.query_kinds[k as usize] } |
