diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-02-03 18:06:55 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-02-03 18:06:55 +0000 |
commit | 74a223faa33156be1b8b1a6880f9b63463027946 (patch) | |
tree | c3fb598d2107f53cff6983451ee83d4cdb2c7bb2 /crates | |
parent | 3ff2aa6d09bfcc2ab97f0ee8d76e40680440b178 (diff) | |
parent | 1a8ea81a791dbd72e67dfcc94a863d2af310bfdd (diff) |
Merge #7547
7547: Split out ItemScope::dump from DefMap::dump r=jonas-schievink a=jonas-schievink
This is helpful for more targeted debugging
bors r+
Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r-- | crates/hir_def/src/item_scope.rs | 25 | ||||
-rw-r--r-- | crates/hir_def/src/nameres.rs | 22 |
2 files changed, 26 insertions, 21 deletions
diff --git a/crates/hir_def/src/item_scope.rs b/crates/hir_def/src/item_scope.rs index 2750e1c91..ee46c3330 100644 --- a/crates/hir_def/src/item_scope.rs +++ b/crates/hir_def/src/item_scope.rs | |||
@@ -8,6 +8,7 @@ use hir_expand::name::Name; | |||
8 | use hir_expand::MacroDefKind; | 8 | use hir_expand::MacroDefKind; |
9 | use once_cell::sync::Lazy; | 9 | use once_cell::sync::Lazy; |
10 | use rustc_hash::{FxHashMap, FxHashSet}; | 10 | use rustc_hash::{FxHashMap, FxHashSet}; |
11 | use stdx::format_to; | ||
11 | use test_utils::mark; | 12 | use test_utils::mark; |
12 | 13 | ||
13 | use crate::{ | 14 | use crate::{ |
@@ -292,6 +293,30 @@ impl ItemScope { | |||
292 | *vis = Visibility::Module(this_module); | 293 | *vis = Visibility::Module(this_module); |
293 | } | 294 | } |
294 | } | 295 | } |
296 | |||
297 | pub(crate) fn dump(&self, buf: &mut String) { | ||
298 | let mut entries: Vec<_> = self.resolutions().collect(); | ||
299 | entries.sort_by_key(|(name, _)| name.clone()); | ||
300 | |||
301 | for (name, def) in entries { | ||
302 | format_to!(buf, "{}:", name.map_or("_".to_string(), |name| name.to_string())); | ||
303 | |||
304 | if def.types.is_some() { | ||
305 | buf.push_str(" t"); | ||
306 | } | ||
307 | if def.values.is_some() { | ||
308 | buf.push_str(" v"); | ||
309 | } | ||
310 | if def.macros.is_some() { | ||
311 | buf.push_str(" m"); | ||
312 | } | ||
313 | if def.is_none() { | ||
314 | buf.push_str(" _"); | ||
315 | } | ||
316 | |||
317 | buf.push('\n'); | ||
318 | } | ||
319 | } | ||
295 | } | 320 | } |
296 | 321 | ||
297 | impl PerNs { | 322 | impl PerNs { |
diff --git a/crates/hir_def/src/nameres.rs b/crates/hir_def/src/nameres.rs index c858ea0c4..68998c121 100644 --- a/crates/hir_def/src/nameres.rs +++ b/crates/hir_def/src/nameres.rs | |||
@@ -333,27 +333,7 @@ impl DefMap { | |||
333 | fn go(buf: &mut String, map: &DefMap, path: &str, module: LocalModuleId) { | 333 | fn go(buf: &mut String, map: &DefMap, path: &str, module: LocalModuleId) { |
334 | format_to!(buf, "{}\n", path); | 334 | format_to!(buf, "{}\n", path); |
335 | 335 | ||
336 | let mut entries: Vec<_> = map.modules[module].scope.resolutions().collect(); | 336 | map.modules[module].scope.dump(buf); |
337 | entries.sort_by_key(|(name, _)| name.clone()); | ||
338 | |||
339 | for (name, def) in entries { | ||
340 | format_to!(buf, "{}:", name.map_or("_".to_string(), |name| name.to_string())); | ||
341 | |||
342 | if def.types.is_some() { | ||
343 | buf.push_str(" t"); | ||
344 | } | ||
345 | if def.values.is_some() { | ||
346 | buf.push_str(" v"); | ||
347 | } | ||
348 | if def.macros.is_some() { | ||
349 | buf.push_str(" m"); | ||
350 | } | ||
351 | if def.is_none() { | ||
352 | buf.push_str(" _"); | ||
353 | } | ||
354 | |||
355 | buf.push('\n'); | ||
356 | } | ||
357 | 337 | ||
358 | for (name, child) in map.modules[module].children.iter() { | 338 | for (name, child) in map.modules[module].children.iter() { |
359 | let path = format!("{}::{}", path, name); | 339 | let path = format!("{}::{}", path, name); |