Skip to content

Commit 6c07c71

Browse files
Sort when iterating through CrateGraph
1 parent 4e1a302 commit 6c07c71

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

Diff for: src/tools/rust-analyzer/crates/hir-def/src/import_map.rs

+15-18
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,7 @@ fn collect_import_map(db: &dyn DefDatabase, krate: CrateId) -> ImportMap {
167167

168168
let visible_items = mod_data.scope.entries().filter_map(|(name, per_ns)| {
169169
let per_ns = per_ns.filter_visibility(|vis| vis == Visibility::Public);
170-
if per_ns.is_none() {
171-
None
172-
} else {
173-
Some((name, per_ns))
174-
}
170+
if per_ns.is_none() { None } else { Some((name, per_ns)) }
175171
});
176172

177173
for (name, per_ns) in visible_items {
@@ -591,6 +587,7 @@ mod tests {
591587

592588
Some(format!("{}:\n{:?}\n", name, map))
593589
})
590+
.sorted()
594591
.collect::<String>();
595592

596593
expect.assert_eq(&actual)
@@ -624,15 +621,15 @@ mod tests {
624621
struct Priv;
625622
",
626623
expect![[r#"
624+
lib:
625+
- Pub (t)
626+
- Pub2 (t)
627+
- Pub2 (v)
627628
main:
628629
- publ1 (t)
629630
- real_pu2 (t)
630631
- real_pub (t)
631632
- real_pub::Pub (t)
632-
lib:
633-
- Pub (t)
634-
- Pub2 (t)
635-
- Pub2 (v)
636633
"#]],
637634
);
638635
}
@@ -674,13 +671,13 @@ mod tests {
674671
pub struct S;
675672
",
676673
expect![[r#"
674+
lib:
675+
- S (t)
676+
- S (v)
677677
main:
678678
- m (t)
679679
- m::S (t)
680680
- m::S (v)
681-
lib:
682-
- S (t)
683-
- S (v)
684681
"#]],
685682
);
686683
}
@@ -700,11 +697,11 @@ mod tests {
700697
}
701698
",
702699
expect![[r#"
700+
lib:
701+
- pub_macro (m)
703702
main:
704703
- m (t)
705704
- m::pub_macro (m)
706-
lib:
707-
- pub_macro (m)
708705
"#]],
709706
);
710707
}
@@ -722,14 +719,14 @@ mod tests {
722719
}
723720
",
724721
expect![[r#"
725-
main:
726-
- reexported_module (t)
727-
- reexported_module::S (t)
728-
- reexported_module::S (v)
729722
lib:
730723
- module (t)
731724
- module::S (t)
732725
- module::S (v)
726+
main:
727+
- reexported_module (t)
728+
- reexported_module::S (t)
729+
- reexported_module::S (v)
733730
"#]],
734731
);
735732
}

0 commit comments

Comments
 (0)