Make ImplData's fields public

This commit is contained in:
Aleksey Kladov 2019-11-22 17:33:53 +03:00
parent b315f05cf1
commit 64df759418
4 changed files with 14 additions and 28 deletions

View File

@ -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,

View File

@ -18,11 +18,11 @@ impl HasSource for ImplBlock {
impl ImplBlock {
pub fn target_trait(&self, db: &impl DefDatabase) -> Option<TypeRef> {
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<AssocItem> {
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 {

View File

@ -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},

View File

@ -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<TypeRef>,
target_type: TypeRef,
items: Vec<AssocItemId>,
negative: bool,
pub target_trait: Option<TypeRef>,
pub target_type: TypeRef,
pub items: Vec<AssocItemId>,
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
}
}