Auto merge of #94066 - Mark-Simulacrum:factor-out-simple-def-kind, r=davidtwco
Remove SimpleDefKind Now that rustc_query_system depends on rustc_hir, we can just directly make use of the regular DefKind.
This commit is contained in:
commit
026d8ce7f5
5 changed files with 14 additions and 62 deletions
|
@ -44,8 +44,6 @@ pub use on_disk_cache::OnDiskCache;
|
|||
mod profiling_support;
|
||||
pub use self::profiling_support::alloc_self_profile_query_strings;
|
||||
|
||||
mod util;
|
||||
|
||||
fn describe_as_module(def_id: LocalDefId, tcx: TyCtxt<'_>) -> String {
|
||||
if def_id.is_top_level_module() {
|
||||
"top-level module".to_string()
|
||||
|
|
|
@ -290,13 +290,11 @@ macro_rules! define_queries {
|
|||
} else {
|
||||
Some(key.default_span(*tcx))
|
||||
};
|
||||
let def_id = key.key_as_def_id();
|
||||
let def_kind = def_id
|
||||
// Use `tcx.hir().opt_def_kind()` to reduce the chance of
|
||||
// accidentally triggering an infinite query loop.
|
||||
let def_kind = key.key_as_def_id()
|
||||
.and_then(|def_id| def_id.as_local())
|
||||
// Use `tcx.hir().opt_def_kind()` to reduce the chance of
|
||||
// accidentally triggering an infinite query loop.
|
||||
.and_then(|def_id| tcx.hir().opt_def_kind(def_id))
|
||||
.map(|def_kind| $crate::util::def_kind_to_simple_def_kind(def_kind));
|
||||
.and_then(|def_id| tcx.hir().opt_def_kind(def_id));
|
||||
let hash = || {
|
||||
let mut hcx = tcx.create_stable_hashing_context();
|
||||
let mut hasher = StableHasher::new();
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
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,
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue