Unnamed repository; edit this file 'description' to name the repository.
Merge pull request #20126 from Wilfred/no_unwrap_in_discover_projects
fix: Avoid .unwrap() when running the discover command
Lukas Wirth 10 months ago
parent ef3e52b · parent a50b7b6 · commit fce1f41
-rw-r--r--crates/rust-analyzer/src/main_loop.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs
index 0c0438c4b8..00cf890510 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -783,9 +783,14 @@ impl GlobalState {
DiscoverProjectParam::Path(it) => DiscoverArgument::Path(it),
};
- let handle =
- discover.spawn(arg, &std::env::current_dir().unwrap()).unwrap();
- self.discover_handle = Some(handle);
+ let handle = discover.spawn(
+ arg,
+ &std::env::current_dir()
+ .expect("Failed to get cwd during project discovery"),
+ );
+ self.discover_handle = Some(handle.unwrap_or_else(|e| {
+ panic!("Failed to spawn project discovery command: {e}")
+ }));
}
}
}