From d8f5192d99886c89418879cc7d81ba298b0596db Mon Sep 17 00:00:00 2001 From: adamrk Date: Sat, 20 Jun 2020 11:53:55 +0200 Subject: Get Output assoc type by name --- crates/ra_hir_ty/src/infer/expr.rs | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'crates/ra_hir_ty') diff --git a/crates/ra_hir_ty/src/infer/expr.rs b/crates/ra_hir_ty/src/infer/expr.rs index 359befe4f..171330274 100644 --- a/crates/ra_hir_ty/src/infer/expr.rs +++ b/crates/ra_hir_ty/src/infer/expr.rs @@ -10,7 +10,7 @@ use hir_def::{ resolver::resolver_for_expr, AdtId, AssocContainerId, FieldId, Lookup, }; -use hir_expand::name::Name; +use hir_expand::name::{name, Name}; use ra_syntax::ast::RangeOp; use crate::{ @@ -70,18 +70,8 @@ impl<'a> InferenceContext<'a> { .filter_map(|f| f.get_id(self.db, krate)) .collect(); let fn_once_trait = FnTrait::FnOnce.get_id(self.db, krate)?; - let output_assoc_type = match self - .db - .trait_data(fn_once_trait) - .associated_types() - .collect::>() - .as_slice() - { - [output] => *output, - _ => { - return None; - } - }; + let output_assoc_type = + self.db.trait_data(fn_once_trait).associated_type_by_name(&name![Output])?; for fn_trait in fn_traits { let generic_params = generics(self.db.upcast(), fn_trait.into()); if generic_params.len() != 2 { -- cgit v1.2.3