Sort when iterating through CrateGraph

This commit is contained in:
Amos Wenger 2022-07-24 16:11:05 +02:00
parent 4e1a302efc
commit 6c07c71821

View File

@ -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 visible_items = mod_data.scope.entries().filter_map(|(name, per_ns)| {
let per_ns = per_ns.filter_visibility(|vis| vis == Visibility::Public); let per_ns = per_ns.filter_visibility(|vis| vis == Visibility::Public);
if per_ns.is_none() { if per_ns.is_none() { None } else { Some((name, per_ns)) }
None
} else {
Some((name, per_ns))
}
}); });
for (name, per_ns) in visible_items { for (name, per_ns) in visible_items {
@ -591,6 +587,7 @@ mod tests {
Some(format!("{}:\n{:?}\n", name, map)) Some(format!("{}:\n{:?}\n", name, map))
}) })
.sorted()
.collect::<String>(); .collect::<String>();
expect.assert_eq(&actual) expect.assert_eq(&actual)
@ -624,15 +621,15 @@ mod tests {
struct Priv; struct Priv;
", ",
expect![[r#" expect![[r#"
lib:
- Pub (t)
- Pub2 (t)
- Pub2 (v)
main: main:
- publ1 (t) - publ1 (t)
- real_pu2 (t) - real_pu2 (t)
- real_pub (t) - real_pub (t)
- real_pub::Pub (t) - real_pub::Pub (t)
lib:
- Pub (t)
- Pub2 (t)
- Pub2 (v)
"#]], "#]],
); );
} }
@ -674,13 +671,13 @@ mod tests {
pub struct S; pub struct S;
", ",
expect![[r#" expect![[r#"
lib:
- S (t)
- S (v)
main: main:
- m (t) - m (t)
- m::S (t) - m::S (t)
- m::S (v) - m::S (v)
lib:
- S (t)
- S (v)
"#]], "#]],
); );
} }
@ -700,11 +697,11 @@ mod tests {
} }
", ",
expect![[r#" expect![[r#"
lib:
- pub_macro (m)
main: main:
- m (t) - m (t)
- m::pub_macro (m) - m::pub_macro (m)
lib:
- pub_macro (m)
"#]], "#]],
); );
} }
@ -722,14 +719,14 @@ mod tests {
} }
", ",
expect![[r#" expect![[r#"
main:
- reexported_module (t)
- reexported_module::S (t)
- reexported_module::S (v)
lib: lib:
- module (t) - module (t)
- module::S (t) - module::S (t)
- module::S (v) - module::S (v)
main:
- reexported_module (t)
- reexported_module::S (t)
- reexported_module::S (v)
"#]], "#]],
); );
} }