about summary refs log tree commit diff
path: root/compiler/rustc_query_impl/src/util.rs
diff options
context:
space:
mode:
authorNoah Lev <camelidcamel@gmail.com>2021-08-19 20:30:33 -0700
committerNoah Lev <camelidcamel@gmail.com>2021-08-27 14:50:51 -0700
commitcd0fc444fb0edb4df0bd8091706d3819313a9df4 (patch)
treea27934154a2d45e254f98fca1c13aa3bac3ea79d /compiler/rustc_query_impl/src/util.rs
parent2f48bfa88c1c742ed058fc8af096d8cedc138434 (diff)
downloadrust-cd0fc444fb0edb4df0bd8091706d3819313a9df4.tar.gz
rust-cd0fc444fb0edb4df0bd8091706d3819313a9df4.zip
Note that type aliases cannot be recursive
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,
+    }
+}