From 11f86641829273e2b2b7023c2028bb475fce58ee Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Fri, 11 Dec 2020 13:49:32 +0100 Subject: Add Lifetimes to the HIR --- crates/hir_ty/src/utils.rs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'crates/hir_ty/src/utils.rs') diff --git a/crates/hir_ty/src/utils.rs b/crates/hir_ty/src/utils.rs index e3e244268..af880c065 100644 --- a/crates/hir_ty/src/utils.rs +++ b/crates/hir_ty/src/utils.rs @@ -2,11 +2,10 @@ //! query, but can't be computed directly from `*Data` (ie, which need a `db`). use std::sync::Arc; -use hir_def::generics::WherePredicateTarget; use hir_def::{ adt::VariantData, db::DefDatabase, - generics::{GenericParams, TypeParamData, TypeParamProvenance}, + generics::{GenericParams, TypeParamData, TypeParamProvenance, WherePredicateTypeTarget}, path::Path, resolver::{HasResolver, TypeNs}, type_ref::TypeRef, @@ -27,14 +26,19 @@ fn direct_super_traits(db: &dyn DefDatabase, trait_: TraitId) -> Vec { generic_params .where_predicates .iter() - .filter_map(|pred| match &pred.target { - WherePredicateTarget::TypeRef(TypeRef::Path(p)) if p == &Path::from(name![Self]) => { - pred.bound.as_path() - } - WherePredicateTarget::TypeParam(local_id) if Some(*local_id) == trait_self => { - pred.bound.as_path() - } - _ => None, + .filter_map(|pred| match pred { + hir_def::generics::WherePredicate::TypeBound { target, bound } => match target { + WherePredicateTypeTarget::TypeRef(TypeRef::Path(p)) + if p == &Path::from(name![Self]) => + { + bound.as_path() + } + WherePredicateTypeTarget::TypeParam(local_id) if Some(*local_id) == trait_self => { + bound.as_path() + } + _ => None, + }, + hir_def::generics::WherePredicate::Lifetime { .. } => None, }) .filter_map(|path| match resolver.resolve_path_in_type_ns_fully(db, path.mod_path()) { Some(TypeNs::TraitId(t)) => Some(t), -- cgit v1.2.3