Privitize impls

This commit is contained in:
Aleksey Kladov 2019-12-20 16:55:38 +01:00
parent 7adb53319d
commit af42cb5981
4 changed files with 12 additions and 6 deletions

View file

@ -80,9 +80,9 @@ impl ChildBySource for ModuleId {
module_data.scope.declarations().for_each(|item| add_module_def(db, &mut res, item));
for &impl_ in module_data.scope.impls.iter() {
let src = impl_.lookup(db).source(db);
res[keys::IMPL].insert(src, impl_)
for imp in module_data.scope.impls() {
let src = imp.lookup(db).source(db);
res[keys::IMPL].insert(src, imp)
}
res

View file

@ -10,7 +10,7 @@ use crate::{per_ns::PerNs, BuiltinType, ImplId, LocalImportId, MacroDefId, Modul
#[derive(Debug, Default, PartialEq, Eq)]
pub struct ItemScope {
items: FxHashMap<Name, Resolution>,
pub(crate) impls: Vec<ImplId>,
impls: Vec<ImplId>,
/// Macros visible in current module in legacy textual scope
///
/// For macros invoked by an unqualified identifier like `bar!()`, `legacy_macros` will be searched in first.
@ -104,6 +104,10 @@ impl ItemScope {
self.legacy_macros.get(name).copied()
}
pub(crate) fn define_impl(&mut self, imp: ImplId) {
self.impls.push(imp)
}
pub(crate) fn push_res(
&mut self,
name: Name,

View file

@ -81,7 +81,7 @@ impl LangItems {
// Look for impl targets
let def_map = db.crate_def_map(module.krate);
let module_data = &def_map[module.local_id];
for &impl_block in module_data.scope.impls.iter() {
for impl_block in module_data.scope.impls() {
self.collect_lang_item(db, impl_block, LangItemTarget::ImplBlockId)
}

View file

@ -635,7 +635,9 @@ where
let impl_id =
ImplLoc { container, ast_id: AstId::new(self.file_id, ast_id) }
.intern(self.def_collector.db);
self.def_collector.def_map.modules[self.module_id].scope.impls.push(impl_id)
self.def_collector.def_map.modules[self.module_id]
.scope
.define_impl(impl_id)
}
}
}