@@ -29,24 +29,53 @@ pub struct QueryStackFrame {
2929 pub name : & ' static str ,
3030 pub description : String ,
3131 span : Option < Span > ,
32+ /// The `DefKind` this query frame is associated with, if applicable.
33+ ///
34+ /// We can't use `rustc_hir::def::DefKind` because `rustc_hir` is not
35+ /// available in `rustc_query_system`. Instead, we have a simplified
36+ /// custom version of it, called [`SimpleDefKind`].
37+ def_kind : Option < SimpleDefKind > ,
3238 /// This hash is used to deterministically pick
3339 /// a query to remove cycles in the parallel compiler.
3440 #[ cfg( parallel_compiler) ]
3541 hash : u64 ,
3642}
3743
44+ /// A simplified version of `rustc_hir::def::DefKind`.
45+ ///
46+ /// It was added to help improve cycle errors caused by recursive type aliases.
47+ /// As of August 2021, `rustc_query_system` cannot depend on `rustc_hir`
48+ /// because it would create a dependency cycle. So, instead, a simplified
49+ /// version of `DefKind` was added to `rustc_query_system`.
50+ ///
51+ /// `DefKind`s are converted to `SimpleDefKind`s in `rustc_query_impl`.
52+ #[ derive( Debug , Copy , Clone ) ]
53+ pub enum SimpleDefKind {
54+ Struct ,
55+ Enum ,
56+ Union ,
57+ Trait ,
58+ TyAlias ,
59+ TraitAlias ,
60+
61+ // FIXME: add more from `rustc_hir::def::DefKind` and then remove `Other`
62+ Other ,
63+ }
64+
3865impl QueryStackFrame {
3966 #[ inline]
4067 pub fn new (
4168 name : & ' static str ,
4269 description : String ,
4370 span : Option < Span > ,
71+ def_kind : Option < SimpleDefKind > ,
4472 _hash : impl FnOnce ( ) -> u64 ,
4573 ) -> Self {
4674 Self {
4775 name,
4876 description,
4977 span,
78+ def_kind,
5079 #[ cfg( parallel_compiler) ]
5180 hash : _hash ( ) ,
5281 }
0 commit comments