mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-04 18:58:41 +00:00
fix: Avoid .unwrap() when running the discover command
Previously, the following configuration in settings.json: "rust-analyzer.workspace.discoverConfig": { "command": [ "oops", "develop-json", "{arg}" ], "progressLabel": "rust-analyzer", "filesToWatch": [ "BUCK", "TARGETS" ] }, Would previously cause a crash in rust-analyzer: thread 'LspServer' panicked at crates/rust-analyzer/src/main_loop.rs:776:84: called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" } Instead, use more specific panic messages.
This commit is contained in:
parent
3816d0ae53
commit
a50b7b6b4e
1 changed files with 8 additions and 3 deletions
|
@ -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}")
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue