mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
Hide data from public API
This commit is contained in:
parent
d4f4ae0dd8
commit
fe119fef27
3 changed files with 8 additions and 16 deletions
|
@ -10,7 +10,7 @@ use hir_def::{
|
||||||
adt::VariantData,
|
adt::VariantData,
|
||||||
body::scope::ExprScopes,
|
body::scope::ExprScopes,
|
||||||
builtin_type::BuiltinType,
|
builtin_type::BuiltinType,
|
||||||
data::{ConstData, TraitData},
|
data::TraitData,
|
||||||
nameres::per_ns::PerNs,
|
nameres::per_ns::PerNs,
|
||||||
resolver::{HasResolver, TypeNs},
|
resolver::{HasResolver, TypeNs},
|
||||||
type_ref::TypeRef,
|
type_ref::TypeRef,
|
||||||
|
@ -644,12 +644,8 @@ impl Const {
|
||||||
Some(self.module(db).krate())
|
Some(self.module(db).krate())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn data(self, db: &impl HirDatabase) -> Arc<ConstData> {
|
|
||||||
db.const_data(self.id)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn name(self, db: &impl HirDatabase) -> Option<Name> {
|
pub fn name(self, db: &impl HirDatabase) -> Option<Name> {
|
||||||
self.data(db).name.clone()
|
db.const_data(self.id).name.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn infer(self, db: &impl HirDatabase) -> Arc<InferenceResult> {
|
pub fn infer(self, db: &impl HirDatabase) -> Arc<InferenceResult> {
|
||||||
|
@ -695,10 +691,6 @@ impl Static {
|
||||||
Some(self.module(db).krate())
|
Some(self.module(db).krate())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn data(self, db: &impl HirDatabase) -> Arc<ConstData> {
|
|
||||||
db.static_data(self.id)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn infer(self, db: &impl HirDatabase) -> Arc<InferenceResult> {
|
pub fn infer(self, db: &impl HirDatabase) -> Arc<InferenceResult> {
|
||||||
db.infer(self.into())
|
db.infer(self.into())
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,10 +69,10 @@ pub fn infer_query(db: &impl HirDatabase, def: DefWithBody) -> Arc<InferenceResu
|
||||||
let resolver = DefWithBodyId::from(def).resolver(db);
|
let resolver = DefWithBodyId::from(def).resolver(db);
|
||||||
let mut ctx = InferenceContext::new(db, def, resolver);
|
let mut ctx = InferenceContext::new(db, def, resolver);
|
||||||
|
|
||||||
match def {
|
match &def {
|
||||||
DefWithBody::Const(ref c) => ctx.collect_const(&c.data(db)),
|
DefWithBody::Const(c) => ctx.collect_const(&db.const_data(c.id)),
|
||||||
DefWithBody::Function(ref f) => ctx.collect_fn(&db.function_data(f.id)),
|
DefWithBody::Function(f) => ctx.collect_fn(&db.function_data(f.id)),
|
||||||
DefWithBody::Static(ref s) => ctx.collect_const(&s.data(db)),
|
DefWithBody::Static(s) => ctx.collect_const(&db.static_data(s.id)),
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.infer_body();
|
ctx.infer_body();
|
||||||
|
|
|
@ -639,7 +639,7 @@ fn type_for_fn(db: &impl HirDatabase, def: Function) -> Ty {
|
||||||
|
|
||||||
/// Build the declared type of a const.
|
/// Build the declared type of a const.
|
||||||
fn type_for_const(db: &impl HirDatabase, def: Const) -> Ty {
|
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);
|
let resolver = def.id.resolver(db);
|
||||||
|
|
||||||
Ty::from_hir(db, &resolver, &data.type_ref)
|
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.
|
/// Build the declared type of a static.
|
||||||
fn type_for_static(db: &impl HirDatabase, def: Static) -> Ty {
|
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);
|
let resolver = def.id.resolver(db);
|
||||||
|
|
||||||
Ty::from_hir(db, &resolver, &data.type_ref)
|
Ty::from_hir(db, &resolver, &data.type_ref)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue