Remove TaggedQueryKey::def_kind

This commit is contained in:
John Kåre Alsaker
2026-03-14 15:21:13 +01:00
parent 0312931d8c
commit e6098df4d0
2 changed files with 16 additions and 30 deletions
+16 -6
View File
@@ -481,13 +481,23 @@ pub(crate) fn create_cycle_error<'tcx>(
usage: usage.tagged_key.description(tcx),
});
let alias = if frames
.iter()
.all(|frame| frame.tagged_key.def_kind(tcx) == Some(DefKind::TyAlias))
{
let is_all_def_kind = |def_kind| {
// Trivial type alias and trait alias cycles consists of `type_of` and
// `explicit_implied_predicates_of` queries, so we just check just these here.
frames.iter().all(|frame| match frame.tagged_key {
TaggedQueryKey::type_of(def_id)
| TaggedQueryKey::explicit_implied_predicates_of(def_id)
if tcx.def_kind(def_id) == def_kind =>
{
true
}
_ => false,
})
};
let alias = if is_all_def_kind(DefKind::TyAlias) {
Some(crate::error::Alias::Ty)
} else if frames.iter().all(|frame| frame.tagged_key.def_kind(tcx) == Some(DefKind::TraitAlias))
{
} else if is_all_def_kind(DefKind::TraitAlias) {
Some(crate::error::Alias::Trait)
} else {
None