Skip to content

Commit 8be2be8

Browse files
bors[bot]Jonas Schievink
andauthored
Merge #11308
11308: fix: status: output all crates a file belongs to r=jonas-schievink a=jonas-schievink While investigating #11300 I noticed that we only output the first crate, which masks the reason for that issue – the file in question is the root of multiple crates, and one is missing dependencies. This PR makes "Rust Analyzer: Status" include *every* crate a file is part of. bors r+ Co-authored-by: Jonas Schievink <[email protected]>
2 parents 1861654 + a3d06f8 commit 8be2be8

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

crates/ide/src/status.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,23 @@ pub(crate) fn status(db: &RootDatabase, file_id: Option<FileId>) -> String {
4545

4646
if let Some(file_id) = file_id {
4747
format_to!(buf, "\nFile info:\n");
48-
let krate = crate::parent_module::crate_for(db, file_id).pop();
49-
match krate {
50-
Some(krate) => {
51-
let crate_graph = db.crate_graph();
52-
let display_crate = |krate: CrateId| match &crate_graph[krate].display_name {
53-
Some(it) => format!("{}({:?})", it, krate),
54-
None => format!("{:?}", krate),
55-
};
56-
format_to!(buf, "Crate: {}\n", display_crate(krate));
57-
let deps = crate_graph[krate]
58-
.dependencies
59-
.iter()
60-
.map(|dep| format!("{}={:?}", dep.name, dep.crate_id))
61-
.format(", ");
62-
format_to!(buf, "Dependencies: {}\n", deps);
63-
}
64-
None => format_to!(buf, "Does not belong to any crate"),
48+
let crates = crate::parent_module::crate_for(db, file_id);
49+
if crates.is_empty() {
50+
format_to!(buf, "Does not belong to any crate");
51+
}
52+
let crate_graph = db.crate_graph();
53+
for krate in crates {
54+
let display_crate = |krate: CrateId| match &crate_graph[krate].display_name {
55+
Some(it) => format!("{}({:?})", it, krate),
56+
None => format!("{:?}", krate),
57+
};
58+
format_to!(buf, "Crate: {}\n", display_crate(krate));
59+
let deps = crate_graph[krate]
60+
.dependencies
61+
.iter()
62+
.map(|dep| format!("{}={:?}", dep.name, dep.crate_id))
63+
.format(", ");
64+
format_to!(buf, "Dependencies: {}\n", deps);
6565
}
6666
}
6767

0 commit comments

Comments
 (0)