diff options
| author | Cameron Steffen <cam.steffen94@gmail.com> | 2022-08-15 14:11:11 -0500 | 
|---|---|---|
| committer | Cameron Steffen <cam.steffen94@gmail.com> | 2022-10-07 09:33:46 -0500 | 
| commit | ff940db666daeae83c6c71685901c6c14df17018 (patch) | |
| tree | c37efc001506d87ff4547fdd8cbe0cb5768515e0 /compiler/rustc_query_impl | |
| parent | e42c4d7218b2596276152c5eb1e69335621f3086 (diff) | |
| download | rust-ff940db666daeae83c6c71685901c6c14df17018.tar.gz rust-ff940db666daeae83c6c71685901c6c14df17018.zip | |
Rewrite representability
Diffstat (limited to 'compiler/rustc_query_impl')
| -rw-r--r-- | compiler/rustc_query_impl/src/keys.rs | 10 | ||||
| -rw-r--r-- | compiler/rustc_query_impl/src/plumbing.rs | 8 | 
2 files changed, 14 insertions, 4 deletions
| diff --git a/compiler/rustc_query_impl/src/keys.rs b/compiler/rustc_query_impl/src/keys.rs index cdbf734cdbe..8be2e2be86b 100644 --- a/compiler/rustc_query_impl/src/keys.rs +++ b/compiler/rustc_query_impl/src/keys.rs @@ -27,6 +27,10 @@ pub trait Key { fn key_as_def_id(&self) -> Option<DefId> { None } + + fn ty_adt_id(&self) -> Option<DefId> { + None + } } impl Key for () { @@ -407,6 +411,12 @@ impl<'tcx> Key for Ty<'tcx> { fn default_span(&self, _: TyCtxt<'_>) -> Span { DUMMY_SP } + fn ty_adt_id(&self) -> Option<DefId> { + match self.kind() { + ty::Adt(adt, _) => Some(adt.did()), + _ => None, + } + } } impl<'tcx> Key for TyAndLayout<'tcx> { diff --git a/compiler/rustc_query_impl/src/plumbing.rs b/compiler/rustc_query_impl/src/plumbing.rs index 2b3850bc0df..aaeaa3bd51d 100644 --- a/compiler/rustc_query_impl/src/plumbing.rs +++ b/compiler/rustc_query_impl/src/plumbing.rs @@ -318,13 +318,12 @@ pub(crate) fn create_query_frame< } else { Some(key.default_span(*tcx)) }; + let def_id = key.key_as_def_id(); let def_kind = if kind == dep_graph::DepKind::opt_def_kind { // Try to avoid infinite recursion. None } else { - key.key_as_def_id() - .and_then(|def_id| def_id.as_local()) - .and_then(|def_id| tcx.opt_def_kind(def_id)) + def_id.and_then(|def_id| def_id.as_local()).and_then(|def_id| tcx.opt_def_kind(def_id)) }; let hash = || { tcx.with_stable_hashing_context(|mut hcx| { @@ -334,8 +333,9 @@ pub(crate) fn create_query_frame< hasher.finish::<u64>() }) }; + let ty_adt_id = key.ty_adt_id(); - QueryStackFrame::new(name, description, span, def_kind, hash) + QueryStackFrame::new(name, description, span, def_id, def_kind, ty_adt_id, hash) } fn try_load_from_on_disk_cache<'tcx, Q>(tcx: TyCtxt<'tcx>, dep_node: DepNode) | 
