From fe119fef2746bade402fb73dcba8cde49779654d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 22 Nov 2019 18:51:53 +0300 Subject: Hide data from public API --- crates/ra_hir/src/code_model.rs | 12 ++---------- crates/ra_hir/src/ty/infer.rs | 8 ++++---- crates/ra_hir/src/ty/lower.rs | 4 ++-- 3 files changed, 8 insertions(+), 16 deletions(-) (limited to 'crates') diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 1b65eefe5..af07b2c4d 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs @@ -10,7 +10,7 @@ use hir_def::{ adt::VariantData, body::scope::ExprScopes, builtin_type::BuiltinType, - data::{ConstData, TraitData}, + data::TraitData, nameres::per_ns::PerNs, resolver::{HasResolver, TypeNs}, type_ref::TypeRef, @@ -644,12 +644,8 @@ impl Const { Some(self.module(db).krate()) } - pub fn data(self, db: &impl HirDatabase) -> Arc { - db.const_data(self.id) - } - pub fn name(self, db: &impl HirDatabase) -> Option { - self.data(db).name.clone() + db.const_data(self.id).name.clone() } pub fn infer(self, db: &impl HirDatabase) -> Arc { @@ -695,10 +691,6 @@ impl Static { Some(self.module(db).krate()) } - pub fn data(self, db: &impl HirDatabase) -> Arc { - db.static_data(self.id) - } - pub fn infer(self, db: &impl HirDatabase) -> Arc { db.infer(self.into()) } diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs index 39976a359..471bdc387 100644 --- a/crates/ra_hir/src/ty/infer.rs +++ b/crates/ra_hir/src/ty/infer.rs @@ -69,10 +69,10 @@ pub fn infer_query(db: &impl HirDatabase, def: DefWithBody) -> Arc ctx.collect_const(&c.data(db)), - DefWithBody::Function(ref f) => ctx.collect_fn(&db.function_data(f.id)), - DefWithBody::Static(ref s) => ctx.collect_const(&s.data(db)), + match &def { + DefWithBody::Const(c) => ctx.collect_const(&db.const_data(c.id)), + DefWithBody::Function(f) => ctx.collect_fn(&db.function_data(f.id)), + DefWithBody::Static(s) => ctx.collect_const(&db.static_data(s.id)), } ctx.infer_body(); diff --git a/crates/ra_hir/src/ty/lower.rs b/crates/ra_hir/src/ty/lower.rs index ac7f3f775..2272510e8 100644 --- a/crates/ra_hir/src/ty/lower.rs +++ b/crates/ra_hir/src/ty/lower.rs @@ -639,7 +639,7 @@ fn type_for_fn(db: &impl HirDatabase, def: Function) -> Ty { /// Build the declared type of a const. fn type_for_const(db: &impl HirDatabase, def: Const) -> Ty { - let data = def.data(db); + let data = db.const_data(def.id); let resolver = def.id.resolver(db); Ty::from_hir(db, &resolver, &data.type_ref) @@ -647,7 +647,7 @@ fn type_for_const(db: &impl HirDatabase, def: Const) -> Ty { /// Build the declared type of a static. fn type_for_static(db: &impl HirDatabase, def: Static) -> Ty { - let data = def.data(db); + let data = db.static_data(def.id); let resolver = def.id.resolver(db); Ty::from_hir(db, &resolver, &data.type_ref) -- cgit v1.2.3