about summary refs log tree commit diff
path: root/compiler/rustc_query_impl/src/util.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-09-01 03:43:37 +0000
committerbors <bors@rust-lang.org>2021-09-01 03:43:37 +0000
commitc4f26b15e37101c54829efab456922a53e3103ad (patch)
treece7caaa6f4446a1faa1414554ef0f1715847a4f9 /compiler/rustc_query_impl/src/util.rs
parentc2a408840ad18f74280805535f0b7193528ff3df (diff)
parentd96234bed72e1935d8ab9a0c7a7e70027c86ad77 (diff)
downloadrust-c4f26b15e37101c54829efab456922a53e3103ad.tar.gz
rust-c4f26b15e37101c54829efab456922a53e3103ad.zip
Auto merge of #88121 - camelid:better-recursive-alias-error, r=estebank
Improve errors for recursive type aliases

Fixes #17539.
Diffstat (limited to 'compiler/rustc_query_impl/src/util.rs')
-rw-r--r--compiler/rustc_query_impl/src/util.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/compiler/rustc_query_impl/src/util.rs b/compiler/rustc_query_impl/src/util.rs
new file mode 100644
index 00000000000..517c107b5d9
--- /dev/null
+++ b/compiler/rustc_query_impl/src/util.rs
@@ -0,0 +1,18 @@
+use rustc_hir::def::DefKind;
+use rustc_query_system::query::SimpleDefKind;
+
+/// Convert a [`DefKind`] to a [`SimpleDefKind`].
+///
+/// *See [`SimpleDefKind`]'s docs for more information.*
+pub(crate) fn def_kind_to_simple_def_kind(def_kind: DefKind) -> SimpleDefKind {
+    match def_kind {
+        DefKind::Struct => SimpleDefKind::Struct,
+        DefKind::Enum => SimpleDefKind::Enum,
+        DefKind::Union => SimpleDefKind::Union,
+        DefKind::Trait => SimpleDefKind::Trait,
+        DefKind::TyAlias => SimpleDefKind::TyAlias,
+        DefKind::TraitAlias => SimpleDefKind::TraitAlias,
+
+        _ => SimpleDefKind::Other,
+    }
+}