From 64df759418a83fd05fab850b8351fcddbdd3ef63 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 22 Nov 2019 17:33:53 +0300 Subject: Make ImplData's fields public --- crates/ra_hir/src/code_model.rs | 2 +- crates/ra_hir/src/impl_block.rs | 8 ++++---- crates/ra_hir/src/ty/infer.rs | 2 +- crates/ra_hir_def/src/data.rs | 30 ++++++++---------------------- 4 files changed, 14 insertions(+), 28 deletions(-) diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index f426f8c9f..3daf7488e 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs @@ -10,9 +10,9 @@ use hir_def::{ adt::VariantData, body::scope::ExprScopes, builtin_type::BuiltinType, + data::TraitData, nameres::per_ns::PerNs, resolver::{HasResolver, TypeNs}, - traits::TraitData, type_ref::TypeRef, ContainerId, CrateModuleId, HasModule, ImplId, LocalEnumVariantId, LocalStructFieldId, Lookup, ModuleId, UnionId, diff --git a/crates/ra_hir/src/impl_block.rs b/crates/ra_hir/src/impl_block.rs index 774fa1d96..334eeebac 100644 --- a/crates/ra_hir/src/impl_block.rs +++ b/crates/ra_hir/src/impl_block.rs @@ -18,11 +18,11 @@ impl HasSource for ImplBlock { impl ImplBlock { pub fn target_trait(&self, db: &impl DefDatabase) -> Option { - db.impl_data(self.id).target_trait().cloned() + db.impl_data(self.id).target_trait.clone() } pub fn target_type(&self, db: &impl DefDatabase) -> TypeRef { - db.impl_data(self.id).target_type().clone() + db.impl_data(self.id).target_type.clone() } pub fn target_ty(&self, db: &impl HirDatabase) -> Ty { @@ -35,11 +35,11 @@ impl ImplBlock { } pub fn items(&self, db: &impl DefDatabase) -> Vec { - db.impl_data(self.id).items().iter().map(|it| (*it).into()).collect() + db.impl_data(self.id).items.iter().map(|it| (*it).into()).collect() } pub fn is_negative(&self, db: &impl DefDatabase) -> bool { - db.impl_data(self.id).is_negative() + db.impl_data(self.id).is_negative } pub fn module(&self, db: &impl DefDatabase) -> Module { diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs index 41a51283d..6e07ab86e 100644 --- a/crates/ra_hir/src/ty/infer.rs +++ b/crates/ra_hir/src/ty/infer.rs @@ -22,7 +22,7 @@ use ena::unify::{InPlaceUnificationTable, NoError, UnifyKey, UnifyValue}; use rustc_hash::FxHashMap; use hir_def::{ - function::FunctionData, + data::FunctionData, path::known, resolver::{HasResolver, Resolver, TypeNs}, type_ref::{Mutability, TypeRef}, diff --git a/crates/ra_hir_def/src/data.rs b/crates/ra_hir_def/src/data.rs index b73e0d0a7..ba47629db 100644 --- a/crates/ra_hir_def/src/data.rs +++ b/crates/ra_hir_def/src/data.rs @@ -1,3 +1,5 @@ +//! Contains basic data about various HIR declarations. + use std::sync::Arc; use hir_expand::{ @@ -135,10 +137,10 @@ impl TraitData { #[derive(Debug, Clone, PartialEq, Eq)] pub struct ImplData { - target_trait: Option, - target_type: TypeRef, - items: Vec, - negative: bool, + pub target_trait: Option, + pub target_type: TypeRef, + pub items: Vec, + pub is_negative: bool, } impl ImplData { @@ -148,7 +150,7 @@ impl ImplData { let target_trait = src.value.target_trait().map(TypeRef::from_ast); let target_type = TypeRef::from_ast_opt(src.value.target_type()); - let negative = src.value.is_negative(); + let is_negative = src.value.is_negative(); let items = if let Some(item_list) = src.value.item_list() { item_list @@ -184,23 +186,7 @@ impl ImplData { Vec::new() }; - let res = ImplData { target_trait, target_type, items, negative }; + let res = ImplData { target_trait, target_type, items, is_negative }; Arc::new(res) } - - pub fn target_trait(&self) -> Option<&TypeRef> { - self.target_trait.as_ref() - } - - pub fn target_type(&self) -> &TypeRef { - &self.target_type - } - - pub fn items(&self) -> &[AssocItemId] { - &self.items - } - - pub fn is_negative(&self) -> bool { - self.negative - } } -- cgit v1.2.3