Unnamed repository; edit this file 'description' to name the repository.
Sort when iterating through CrateGraph
Amos Wenger 2022-07-24
parent d8c0d88 · commit 56c369d
-rw-r--r--crates/hir-def/src/import_map.rs33
1 files changed, 15 insertions, 18 deletions
diff --git a/crates/hir-def/src/import_map.rs b/crates/hir-def/src/import_map.rs
index 252d669324..688055e430 100644
--- a/crates/hir-def/src/import_map.rs
+++ b/crates/hir-def/src/import_map.rs
@@ -167,11 +167,7 @@ fn collect_import_map(db: &dyn DefDatabase, krate: CrateId) -> ImportMap {
let visible_items = mod_data.scope.entries().filter_map(|(name, per_ns)| {
let per_ns = per_ns.filter_visibility(|vis| vis == Visibility::Public);
- if per_ns.is_none() {
- None
- } else {
- Some((name, per_ns))
- }
+ if per_ns.is_none() { None } else { Some((name, per_ns)) }
});
for (name, per_ns) in visible_items {
@@ -591,6 +587,7 @@ mod tests {
Some(format!("{}:\n{:?}\n", name, map))
})
+ .sorted()
.collect::<String>();
expect.assert_eq(&actual)
@@ -624,15 +621,15 @@ mod tests {
struct Priv;
",
expect![[r#"
+ lib:
+ - Pub (t)
+ - Pub2 (t)
+ - Pub2 (v)
main:
- publ1 (t)
- real_pu2 (t)
- real_pub (t)
- real_pub::Pub (t)
- lib:
- - Pub (t)
- - Pub2 (t)
- - Pub2 (v)
"#]],
);
}
@@ -674,13 +671,13 @@ mod tests {
pub struct S;
",
expect![[r#"
+ lib:
+ - S (t)
+ - S (v)
main:
- m (t)
- m::S (t)
- m::S (v)
- lib:
- - S (t)
- - S (v)
"#]],
);
}
@@ -700,11 +697,11 @@ mod tests {
}
",
expect![[r#"
+ lib:
+ - pub_macro (m)
main:
- m (t)
- m::pub_macro (m)
- lib:
- - pub_macro (m)
"#]],
);
}
@@ -722,14 +719,14 @@ mod tests {
}
",
expect![[r#"
- main:
- - reexported_module (t)
- - reexported_module::S (t)
- - reexported_module::S (v)
lib:
- module (t)
- module::S (t)
- module::S (v)
+ main:
+ - reexported_module (t)
+ - reexported_module::S (t)
+ - reexported_module::S (v)
"#]],
);
}