Sort when iterating through CrateGraph
@@ -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)
"#]],
);
}
