&self.crate_impl_blocks.impls[self.impl_id]
}
- pub fn target(&self) -> &TypeRef {
- &self.impl_data().impl_for
+ pub fn target_trait(&self) -> Option<&TypeRef> {
+ self.impl_data().target_trait.as_ref()
+ }
+
+ pub fn target_type(&self) -> &TypeRef {
+ &self.impl_data().target_type
}
pub fn items(&self) -> &[ImplItem] {
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ImplData {
- impl_for: TypeRef,
+ target_trait: Option<TypeRef>,
+ target_type: TypeRef,
items: Vec<ImplItem>,
}
module: &Module,
node: ast::ImplBlock,
) -> Self {
- let impl_for = TypeRef::from_ast_opt(node.target_type());
+ let target_trait = node.target_type().map(TypeRef::from_ast);
+ let target_type = TypeRef::from_ast_opt(node.target_type());
let file_id = module.source().file_id();
let items = if let Some(item_list) = node.item_list() {
item_list
} else {
Vec::new()
};
- ImplData { impl_for, items }
+ ImplData {
+ target_trait,
+ target_type,
+ items,
+ }
}
}
} else if let Some(float_ty) = primitive::FloatTy::from_name(name) {
return Ok(Ty::Float(float_ty));
} else if name.as_known_name() == Some(KnownName::Self_) {
- return Ty::from_hir_opt(db, module, None, impl_block.map(|i| i.target()));
+ return Ty::from_hir_opt(db, module, None, impl_block.map(|i| i.target_type()));
}
}
self.insert_type_vars(ty)
} else {
// TODO this should be handled by desugaring during HIR conversion
- let ty = self.make_ty_opt(self.impl_block.as_ref().map(|i| i.target()))?;
+ let ty = self.make_ty_opt(self.impl_block.as_ref().map(|i| i.target_type()))?;
let ty = match self_param.flavor() {
ast::SelfParamFlavor::Owned => ty,
ast::SelfParamFlavor::Ref => Ty::Ref(Arc::new(ty), Mutability::Shared),