Unnamed repository; edit this file 'description' to name the repository.
Merge pull request #22634 from UnknownHacker1/fix/21638-flycheck-index-panic
Avoid index panic when flycheck list is empty
| -rw-r--r-- | crates/rust-analyzer/src/handlers/notification.rs | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/crates/rust-analyzer/src/handlers/notification.rs b/crates/rust-analyzer/src/handlers/notification.rs index 93c3aec756..47a98476cd 100644 --- a/crates/rust-analyzer/src/handlers/notification.rs +++ b/crates/rust-analyzer/src/handlers/notification.rs @@ -346,12 +346,10 @@ fn run_flycheck(state: &mut GlobalState, vfs_path: VfsPath) -> bool { // have this problem. Remove the line below when triomphe::Arc has an UnwindSafe impl // like std::sync::Arc's. let world = world; - stdx::always!( - world.flycheck.len() == 1, - "should have exactly one flycheck handle when invocation strategy is once" - ); let saved_file = vfs_path.as_path().map(ToOwned::to_owned); - world.flycheck[0].restart_workspace(saved_file); + if let Some(flycheck) = world.flycheck.first() { + flycheck.restart_workspace(saved_file); + } Ok(()) }) } |