458: dont reexport module id r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2019-01-08 13:36:13 +00:00
commit 562b448f9e
4 changed files with 13 additions and 9 deletions

View File

@ -3,7 +3,8 @@ use ra_syntax::{ast, SyntaxNode, AstNode, TreePtr};
use crate::{ use crate::{
Module, ModuleSource, Problem, Module, ModuleSource, Problem,
Crate, DefId, DefLoc, DefKind, Name, Path, PathKind, PerNs, Def, ModuleId, Crate, DefId, DefLoc, DefKind, Name, Path, PathKind, PerNs, Def,
module_tree::ModuleId,
nameres::ModuleScope, nameres::ModuleScope,
db::HirDatabase, db::HirDatabase,
}; };

View File

@ -2,7 +2,10 @@ use ra_db::{SourceRootId, LocationIntener, Cancelable, FileId};
use ra_syntax::{TreePtr, SyntaxKind, SyntaxNode, SourceFile, AstNode, ast}; use ra_syntax::{TreePtr, SyntaxKind, SyntaxNode, SourceFile, AstNode, ast};
use ra_arena::{Arena, RawId, impl_arena_id}; use ra_arena::{Arena, RawId, impl_arena_id};
use crate::{HirDatabase, PerNs, ModuleId, Def, Function, Struct, Enum, ImplBlock, Crate}; use crate::{
HirDatabase, PerNs, Def, Function, Struct, Enum, ImplBlock, Crate,
module_tree::ModuleId,
};
use crate::code_model_api::Module; use crate::code_model_api::Module;

View File

@ -47,7 +47,6 @@ pub use self::{
name::Name, name::Name,
ids::{HirFileId, DefId, DefLoc, MacroCallId, MacroCallLoc}, ids::{HirFileId, DefId, DefLoc, MacroCallId, MacroCallLoc},
macros::{MacroDef, MacroInput, MacroExpansion}, macros::{MacroDef, MacroInput, MacroExpansion},
module_tree::ModuleId,
nameres::{ItemMap, PerNs, Namespace, Resolution}, nameres::{ItemMap, PerNs, Namespace, Resolution},
function::{Function, FnSignature, FnScopes, ScopesWithSyntaxMapping}, function::{Function, FnSignature, FnScopes, ScopesWithSyntaxMapping},
ty::Ty, ty::Ty,

View File

@ -6,22 +6,23 @@ use relative_path::RelativePath;
use test_utils::assert_eq_text; use test_utils::assert_eq_text;
use crate::{ use crate::{
self as hir, ItemMap, Resolution,
db::HirDatabase, db::HirDatabase,
mock::MockDatabase, mock::MockDatabase,
module_tree::ModuleId,
}; };
fn item_map(fixture: &str) -> (Arc<hir::ItemMap>, hir::ModuleId) { fn item_map(fixture: &str) -> (Arc<ItemMap>, ModuleId) {
let (db, pos) = MockDatabase::with_position(fixture); let (db, pos) = MockDatabase::with_position(fixture);
let source_root = db.file_source_root(pos.file_id); let source_root = db.file_source_root(pos.file_id);
let module = hir::source_binder::module_from_position(&db, pos) let module = crate::source_binder::module_from_position(&db, pos)
.unwrap() .unwrap()
.unwrap(); .unwrap();
let module_id = module.def_id.loc(&db).module_id; let module_id = module.def_id.loc(&db).module_id;
(db.item_map(source_root).unwrap(), module_id) (db.item_map(source_root).unwrap(), module_id)
} }
fn check_module_item_map(map: &hir::ItemMap, module_id: hir::ModuleId, expected: &str) { fn check_module_item_map(map: &ItemMap, module_id: ModuleId, expected: &str) {
let mut lines = map.per_module[&module_id] let mut lines = map.per_module[&module_id]
.items .items
.iter() .iter()
@ -37,7 +38,7 @@ fn check_module_item_map(map: &hir::ItemMap, module_id: hir::ModuleId, expected:
.join("\n"); .join("\n");
assert_eq_text!(&expected, &actual); assert_eq_text!(&expected, &actual);
fn dump_resolution(resolution: &hir::Resolution) -> &'static str { fn dump_resolution(resolution: &Resolution) -> &'static str {
match ( match (
resolution.def_id.types.is_some(), resolution.def_id.types.is_some(),
resolution.def_id.values.is_some(), resolution.def_id.values.is_some(),
@ -181,7 +182,7 @@ fn item_map_across_crates() {
db.set_crate_graph(crate_graph); db.set_crate_graph(crate_graph);
let source_root = db.file_source_root(main_id); let source_root = db.file_source_root(main_id);
let module = hir::source_binder::module_from_file_id(&db, main_id) let module = crate::source_binder::module_from_file_id(&db, main_id)
.unwrap() .unwrap()
.unwrap(); .unwrap();
let module_id = module.def_id.loc(&db).module_id; let module_id = module.def_id.loc(&db).module_id;