Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir_def/src/nameres/mod_resolution.rs')
| -rw-r--r-- | crates/hir_def/src/nameres/mod_resolution.rs | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/crates/hir_def/src/nameres/mod_resolution.rs b/crates/hir_def/src/nameres/mod_resolution.rs index bd2588e592..b6f1b17870 100644 --- a/crates/hir_def/src/nameres/mod_resolution.rs +++ b/crates/hir_def/src/nameres/mod_resolution.rs @@ -24,22 +24,13 @@ impl ModDir { pub(super) fn root() -> ModDir { ModDir { dir_path: DirPath::empty(), root_non_dir_owner: false, depth: 0 } } - fn child(&self, dir_path: DirPath, root_non_dir_owner: bool) -> Option<ModDir> { - let depth = self.depth + 1; - if MOD_DEPTH_LIMIT.check(depth as usize).is_err() { - tracing::error!("MOD_DEPTH_LIMIT exceeded"); - cov_mark::hit!(circular_mods); - return None; - } - Some(ModDir { dir_path, root_non_dir_owner, depth }) - } pub(super) fn descend_into_definition( &self, name: &Name, attr_path: Option<&SmolStr>, ) -> Option<ModDir> { - let path = match attr_path.map(|it| it.as_str()) { + let path = match attr_path.map(SmolStr::as_str) { None => { let mut path = self.dir_path.clone(); path.push(&name.to_smol_str()); @@ -56,6 +47,16 @@ impl ModDir { self.child(path, false) } + fn child(&self, dir_path: DirPath, root_non_dir_owner: bool) -> Option<ModDir> { + let depth = self.depth + 1; + if MOD_DEPTH_LIMIT.check(depth as usize).is_err() { + tracing::error!("MOD_DEPTH_LIMIT exceeded"); + cov_mark::hit!(circular_mods); + return None; + } + Some(ModDir { dir_path, root_non_dir_owner, depth }) + } + pub(super) fn resolve_declaration( &self, db: &dyn DefDatabase, |