summary refs log tree commit diff
path: root/compiler/rustc_query_system
diff options
context:
space:
mode:
authorCameron Steffen <cam.steffen94@gmail.com>2022-08-15 14:11:11 -0500
committerCameron Steffen <cam.steffen94@gmail.com>2022-10-07 09:33:46 -0500
commitff940db666daeae83c6c71685901c6c14df17018 (patch)
treec37efc001506d87ff4547fdd8cbe0cb5768515e0 /compiler/rustc_query_system
parente42c4d7218b2596276152c5eb1e69335621f3086 (diff)
downloadrust-ff940db666daeae83c6c71685901c6c14df17018.tar.gz
rust-ff940db666daeae83c6c71685901c6c14df17018.zip
Rewrite representability
Diffstat (limited to 'compiler/rustc_query_system')
-rw-r--r--compiler/rustc_query_system/src/query/job.rs6
-rw-r--r--compiler/rustc_query_system/src/query/mod.rs9
-rw-r--r--compiler/rustc_query_system/src/query/plumbing.rs11
-rw-r--r--compiler/rustc_query_system/src/values.rs5
4 files changed, 20 insertions, 11 deletions
diff --git a/compiler/rustc_query_system/src/query/job.rs b/compiler/rustc_query_system/src/query/job.rs
index 64aba4703ca..ed65393f57e 100644
--- a/compiler/rustc_query_system/src/query/job.rs
+++ b/compiler/rustc_query_system/src/query/job.rs
@@ -551,7 +551,7 @@ pub fn deadlock(query_map: QueryMap, registry: &rayon_core::Registry) {
 #[cold]
 pub(crate) fn report_cycle<'a>(
     sess: &'a Session,
-    CycleError { usage, cycle: stack }: CycleError,
+    CycleError { usage, cycle: stack }: &CycleError,
 ) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
     assert!(!stack.is_empty());
 
@@ -569,10 +569,10 @@ pub(crate) fn report_cycle<'a>(
     }
 
     let mut cycle_usage = None;
-    if let Some((span, query)) = usage {
+    if let Some((span, ref query)) = *usage {
         cycle_usage = Some(crate::error::CycleUsage {
             span: query.default_span(span),
-            usage: query.description,
+            usage: query.description.to_string(),
         });
     }
 
diff --git a/compiler/rustc_query_system/src/query/mod.rs b/compiler/rustc_query_system/src/query/mod.rs
index 7a96c53b604..118703fc0d4 100644
--- a/compiler/rustc_query_system/src/query/mod.rs
+++ b/compiler/rustc_query_system/src/query/mod.rs
@@ -18,6 +18,7 @@ use crate::dep_graph::{DepNodeIndex, HasDepContext, SerializedDepNodeIndex};
 use rustc_data_structures::sync::Lock;
 use rustc_errors::Diagnostic;
 use rustc_hir::def::DefKind;
+use rustc_span::def_id::DefId;
 use rustc_span::Span;
 use thin_vec::ThinVec;
 
@@ -29,7 +30,9 @@ pub struct QueryStackFrame {
     pub name: &'static str,
     pub description: String,
     span: Option<Span>,
-    def_kind: Option<DefKind>,
+    pub def_id: Option<DefId>,
+    pub def_kind: Option<DefKind>,
+    pub ty_adt_id: Option<DefId>,
     /// This hash is used to deterministically pick
     /// a query to remove cycles in the parallel compiler.
     #[cfg(parallel_compiler)]
@@ -42,14 +45,18 @@ impl QueryStackFrame {
         name: &'static str,
         description: String,
         span: Option<Span>,
+        def_id: Option<DefId>,
         def_kind: Option<DefKind>,
+        ty_adt_id: Option<DefId>,
         _hash: impl FnOnce() -> u64,
     ) -> Self {
         Self {
             name,
             description,
             span,
+            def_id,
             def_kind,
+            ty_adt_id,
             #[cfg(parallel_compiler)]
             hash: _hash(),
         }
diff --git a/compiler/rustc_query_system/src/query/plumbing.rs b/compiler/rustc_query_system/src/query/plumbing.rs
index 8179a674afa..15b89daa6db 100644
--- a/compiler/rustc_query_system/src/query/plumbing.rs
+++ b/compiler/rustc_query_system/src/query/plumbing.rs
@@ -119,7 +119,7 @@ where
 #[inline(never)]
 fn mk_cycle<CTX, V, R>(
     tcx: CTX,
-    error: CycleError,
+    cycle_error: CycleError,
     handler: HandleCycleError,
     cache: &dyn crate::query::QueryStorage<Value = V, Stored = R>,
 ) -> R
@@ -128,13 +128,14 @@ where
     V: std::fmt::Debug + Value<CTX::DepContext>,
     R: Clone,
 {
-    let error = report_cycle(tcx.dep_context().sess(), error);
-    let value = handle_cycle_error(*tcx.dep_context(), error, handler);
+    let error = report_cycle(tcx.dep_context().sess(), &cycle_error);
+    let value = handle_cycle_error(*tcx.dep_context(), &cycle_error, error, handler);
     cache.store_nocache(value)
 }
 
 fn handle_cycle_error<CTX, V>(
     tcx: CTX,
+    cycle_error: &CycleError,
     mut error: DiagnosticBuilder<'_, ErrorGuaranteed>,
     handler: HandleCycleError,
 ) -> V
@@ -146,7 +147,7 @@ where
     match handler {
         Error => {
             error.emit();
-            Value::from_cycle_error(tcx)
+            Value::from_cycle_error(tcx, &cycle_error.cycle)
         }
         Fatal => {
             error.emit();
@@ -155,7 +156,7 @@ where
         }
         DelayBug => {
             error.delay_as_bug();
-            Value::from_cycle_error(tcx)
+            Value::from_cycle_error(tcx, &cycle_error.cycle)
         }
     }
 }
diff --git a/compiler/rustc_query_system/src/values.rs b/compiler/rustc_query_system/src/values.rs
index aeef66f86da..67fbf14e612 100644
--- a/compiler/rustc_query_system/src/values.rs
+++ b/compiler/rustc_query_system/src/values.rs
@@ -1,11 +1,12 @@
 use crate::dep_graph::DepContext;
+use crate::query::QueryInfo;
 
 pub trait Value<CTX: DepContext>: Sized {
-    fn from_cycle_error(tcx: CTX) -> Self;
+    fn from_cycle_error(tcx: CTX, cycle: &[QueryInfo]) -> Self;
 }
 
 impl<CTX: DepContext, T> Value<CTX> for T {
-    default fn from_cycle_error(tcx: CTX) -> T {
+    default fn from_cycle_error(tcx: CTX, _: &[QueryInfo]) -> T {
         tcx.sess().abort_if_errors();
         // Ideally we would use `bug!` here. But bug! is only defined in rustc_middle, and it's
         // non-trivial to define it earlier.