mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +00:00
Merge #5456
5456: Simplify r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
62735cf587
2 changed files with 11 additions and 11 deletions
|
@ -229,12 +229,11 @@ impl CrateDefMap {
|
|||
// even), as this should be a great debugging aid.
|
||||
pub fn dump(&self) -> String {
|
||||
let mut buf = String::new();
|
||||
go(&mut buf, self, "\ncrate", self.root);
|
||||
return buf.trim().to_string();
|
||||
go(&mut buf, self, "crate", self.root);
|
||||
return buf;
|
||||
|
||||
fn go(buf: &mut String, map: &CrateDefMap, path: &str, module: LocalModuleId) {
|
||||
*buf += path;
|
||||
*buf += "\n";
|
||||
format_to!(buf, "{}\n", path);
|
||||
|
||||
let mut entries: Vec<_> = map.modules[module].scope.resolutions().collect();
|
||||
entries.sort_by_key(|(name, _)| name.clone());
|
||||
|
@ -243,23 +242,24 @@ impl CrateDefMap {
|
|||
format_to!(buf, "{}:", name);
|
||||
|
||||
if def.types.is_some() {
|
||||
*buf += " t";
|
||||
buf.push_str(" t");
|
||||
}
|
||||
if def.values.is_some() {
|
||||
*buf += " v";
|
||||
buf.push_str(" v");
|
||||
}
|
||||
if def.macros.is_some() {
|
||||
*buf += " m";
|
||||
buf.push_str(" m");
|
||||
}
|
||||
if def.is_none() {
|
||||
*buf += " _";
|
||||
buf.push_str(" _");
|
||||
}
|
||||
|
||||
*buf += "\n";
|
||||
buf.push_str("\n");
|
||||
}
|
||||
|
||||
for (name, child) in map.modules[module].children.iter() {
|
||||
let path = &format!("{}::{}", path, name);
|
||||
let path = format!("{}::{}", path, name);
|
||||
buf.push('\n');
|
||||
go(buf, map, &path, *child);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ fn compute_crate_def_map(fixture: &str) -> Arc<CrateDefMap> {
|
|||
fn check(ra_fixture: &str, expect: Expect) {
|
||||
let db = TestDB::with_files(ra_fixture);
|
||||
let krate = db.crate_graph().iter().next().unwrap();
|
||||
let actual = db.crate_def_map(krate).dump() + "\n";
|
||||
let actual = db.crate_def_map(krate).dump();
|
||||
expect.assert_eq(&actual);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue