Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync from rust-lang/rust #12871

Merged
merged 11 commits into from
Jul 25, 2022
Prev Previous commit
Next Next commit
Sort when iterating through CrateGraph
  • Loading branch information
fasterthanlime committed Jul 24, 2022
commit 56c369db488361822ec4b2dbf954f6c48d384855
33 changes: 15 additions & 18 deletions crates/hir-def/src/import_map.rs
Original file line number Diff line number Diff line change
@@ -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)) }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the result of some nightly only options rust-lang/rust uses: https://github.com/rust-lang/rust/blob/2f320a224e827b400be25966755a621779f797cc/rustfmt.toml#L2-L4 Stable rustfmt without those options as used in this repo will revert these changes. You will need to do one of:

  • Copy the options to a rustfmt.toml in this repo and switch to nightly rustfmt
  • Ignore rust-analyzer for rustfmt in rust-lang/rust
  • Explicitly use the stable defaults of those options in rustfmt.toml in this repo and hope rustfmt will pick them in favor of the global rustfmt.toml of rust-lang/rust

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That one's my bad, I had "format on save" set up when doing those edits. I'll revert them in this PR.

});

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)
"#]],
);
}