about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAmos Wenger <amoswenger@gmail.com>2022-07-24 16:11:05 +0200
committerAmos Wenger <amoswenger@gmail.com>2022-07-24 16:11:05 +0200
commit56c369db488361822ec4b2dbf954f6c48d384855 (patch)
treec6b2ebdb1efb609b14ab4ac695cf5342988cea89
parentd8c0d88e4f0e491a1f04c0130eecf4426e013ea3 (diff)
downloadrust-56c369db488361822ec4b2dbf954f6c48d384855.tar.gz
rust-56c369db488361822ec4b2dbf954f6c48d384855.zip
Sort when iterating through CrateGraph
-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 252d6693243..688055e430b 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)
             "#]],
         );
     }