mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
Auto merge of #15053 - Veykril:crate-root-module-id, r=Veykril
internal: Add a CrateRootModuleId that encodes a module id that is always a crate root
This commit is contained in:
commit
9c967d3809
9 changed files with 102 additions and 65 deletions
|
@ -203,7 +203,7 @@ impl Crate {
|
|||
|
||||
pub fn root_module(self, db: &dyn HirDatabase) -> Module {
|
||||
let def_map = db.crate_def_map(self.id);
|
||||
Module { id: def_map.module_id(DefMap::ROOT) }
|
||||
Module { id: def_map.crate_root().into() }
|
||||
}
|
||||
|
||||
pub fn modules(self, db: &dyn HirDatabase) -> Vec<Module> {
|
||||
|
@ -476,7 +476,7 @@ impl Module {
|
|||
/// in the module tree of any target in `Cargo.toml`.
|
||||
pub fn crate_root(self, db: &dyn HirDatabase) -> Module {
|
||||
let def_map = db.crate_def_map(self.id.krate());
|
||||
Module { id: def_map.module_id(DefMap::ROOT) }
|
||||
Module { id: def_map.crate_root().into() }
|
||||
}
|
||||
|
||||
pub fn is_crate_root(self) -> bool {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue