Skip to content

Commit

Permalink
Sort when iterating through CrateGraph
Browse files Browse the repository at this point in the history
  • Loading branch information
fasterthanlime committed Jul 24, 2022
1 parent 75b7f68 commit 18ea0c0
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions crates/hir-def/src/import_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -591,6 +587,7 @@ mod tests {

Some(format!("{}:\n{:?}\n", name, map))
})
.sorted()
.collect::<String>();

expect.assert_eq(&actual)
Expand Down Expand Up @@ -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)
"#]],
);
}
Expand Down Expand Up @@ -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)
"#]],
);
}
Expand All @@ -700,11 +697,11 @@ mod tests {
}
",
expect![[r#"
lib:
- pub_macro (m)
main:
- m (t)
- m::pub_macro (m)
lib:
- pub_macro (m)
"#]],
);
}
Expand All @@ -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)
"#]],
);
}
Expand Down

0 comments on commit 18ea0c0

Please sign in to comment.