mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Refactor
- don't take `&self` as receiver for `Copy` types - simplify `hir::Module::nearest_non_block_module()` - style changes for consistency
This commit is contained in:
parent
a02846343f
commit
56dd5368f5
5 changed files with 22 additions and 26 deletions
|
@ -145,24 +145,28 @@ pub struct ModuleId {
|
|||
}
|
||||
|
||||
impl ModuleId {
|
||||
pub fn def_map(&self, db: &dyn db::DefDatabase) -> Arc<DefMap> {
|
||||
pub fn def_map(self, db: &dyn db::DefDatabase) -> Arc<DefMap> {
|
||||
match self.block {
|
||||
Some(block) => db.block_def_map(block),
|
||||
None => db.crate_def_map(self.krate),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn krate(&self) -> CrateId {
|
||||
pub fn krate(self) -> CrateId {
|
||||
self.krate
|
||||
}
|
||||
|
||||
pub fn containing_module(&self, db: &dyn db::DefDatabase) -> Option<ModuleId> {
|
||||
pub fn containing_module(self, db: &dyn db::DefDatabase) -> Option<ModuleId> {
|
||||
self.def_map(db).containing_module(self.local_id)
|
||||
}
|
||||
|
||||
pub fn containing_block(&self) -> Option<BlockId> {
|
||||
pub fn containing_block(self) -> Option<BlockId> {
|
||||
self.block
|
||||
}
|
||||
|
||||
pub fn is_block_module(self) -> bool {
|
||||
self.block.is_some() && self.local_id == DefMap::ROOT
|
||||
}
|
||||
}
|
||||
|
||||
/// An ID of a module, **local** to a `DefMap`.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue