diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2022-02-16 18:06:50 -0500 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2022-02-17 18:08:45 -0500 |
| commit | ddda851fd542775d936eb7fe7e684bb6f2b4bbde (patch) | |
| tree | 0045a22d9f63cedd9aa6ce9f0637a3b35075182b /compiler/rustc_query_system/src | |
| parent | 393fdc10483da930cdbb00eabc3635030d2e776f (diff) | |
| download | rust-ddda851fd542775d936eb7fe7e684bb6f2b4bbde.tar.gz rust-ddda851fd542775d936eb7fe7e684bb6f2b4bbde.zip | |
Remove SimpleDefKind
Diffstat (limited to 'compiler/rustc_query_system/src')
| -rw-r--r-- | compiler/rustc_query_system/src/query/job.rs | 15 | ||||
| -rw-r--r-- | compiler/rustc_query_system/src/query/mod.rs | 31 |
2 files changed, 10 insertions, 36 deletions
diff --git a/compiler/rustc_query_system/src/query/job.rs b/compiler/rustc_query_system/src/query/job.rs index adf878a7f04..4588403925e 100644 --- a/compiler/rustc_query_system/src/query/job.rs +++ b/compiler/rustc_query_system/src/query/job.rs @@ -1,6 +1,7 @@ use crate::dep_graph::DepContext; use crate::query::plumbing::CycleError; -use crate::query::{QueryContext, QueryStackFrame, SimpleDefKind}; +use crate::query::{QueryContext, QueryStackFrame}; +use rustc_hir::def::DefKind; use rustc_data_structures::fx::FxHashMap; use rustc_errors::{struct_span_err, Diagnostic, DiagnosticBuilder, Handler, Level}; @@ -556,15 +557,13 @@ pub(crate) fn report_cycle<'a>( } if stack.iter().all(|entry| { - entry.query.def_kind.map_or(false, |def_kind| { - matches!(def_kind, SimpleDefKind::TyAlias | SimpleDefKind::TraitAlias) - }) + entry + .query + .def_kind + .map_or(false, |def_kind| matches!(def_kind, DefKind::TyAlias | DefKind::TraitAlias)) }) { if stack.iter().all(|entry| { - entry - .query - .def_kind - .map_or(false, |def_kind| matches!(def_kind, SimpleDefKind::TyAlias)) + entry.query.def_kind.map_or(false, |def_kind| matches!(def_kind, DefKind::TyAlias)) }) { err.note("type aliases cannot be recursive"); err.help("consider using a struct, enum, or union instead to break the cycle"); diff --git a/compiler/rustc_query_system/src/query/mod.rs b/compiler/rustc_query_system/src/query/mod.rs index 361ae3c4352..de64ebb6203 100644 --- a/compiler/rustc_query_system/src/query/mod.rs +++ b/compiler/rustc_query_system/src/query/mod.rs @@ -19,6 +19,7 @@ use crate::dep_graph::{DepNodeIndex, HasDepContext, SerializedDepNodeIndex}; use rustc_data_structures::sync::Lock; use rustc_data_structures::thin_vec::ThinVec; use rustc_errors::Diagnostic; +use rustc_hir::def::DefKind; use rustc_span::Span; /// Description of a frame in the query stack. @@ -29,46 +30,20 @@ pub struct QueryStackFrame { pub name: &'static str, pub description: String, span: Option<Span>, - /// The `DefKind` this query frame is associated with, if applicable. - /// - /// We can't use `rustc_hir::def::DefKind` because `rustc_hir` is not - /// available in `rustc_query_system`. Instead, we have a simplified - /// custom version of it, called [`SimpleDefKind`]. - def_kind: Option<SimpleDefKind>, + def_kind: Option<DefKind>, /// This hash is used to deterministically pick /// a query to remove cycles in the parallel compiler. #[cfg(parallel_compiler)] hash: u64, } -/// A simplified version of `rustc_hir::def::DefKind`. -/// -/// It was added to help improve cycle errors caused by recursive type aliases. -/// As of August 2021, `rustc_query_system` cannot depend on `rustc_hir` -/// because it would create a dependency cycle. So, instead, a simplified -/// version of `DefKind` was added to `rustc_query_system`. -/// -/// `DefKind`s are converted to `SimpleDefKind`s in `rustc_query_impl`. -#[derive(Debug, Copy, Clone)] -pub enum SimpleDefKind { - Struct, - Enum, - Union, - Trait, - TyAlias, - TraitAlias, - - // FIXME: add more from `rustc_hir::def::DefKind` and then remove `Other` - Other, -} - impl QueryStackFrame { #[inline] pub fn new( name: &'static str, description: String, span: Option<Span>, - def_kind: Option<SimpleDefKind>, + def_kind: Option<DefKind>, _hash: impl FnOnce() -> u64, ) -> Self { Self { |
