Skip to content

Commit f9baa71

Browse files
authored
Merge pull request rust-lang#22634 from UnknownHacker1/fix/21638-flycheck-index-panic
Avoid index panic when flycheck list is empty
2 parents 3061c4d + a84bc12 commit f9baa71

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

crates/rust-analyzer/src/handlers/notification.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -346,12 +346,10 @@ fn run_flycheck(state: &mut GlobalState, vfs_path: VfsPath) -> bool {
346346
// have this problem. Remove the line below when triomphe::Arc has an UnwindSafe impl
347347
// like std::sync::Arc's.
348348
let world = world;
349-
stdx::always!(
350-
world.flycheck.len() == 1,
351-
"should have exactly one flycheck handle when invocation strategy is once"
352-
);
353349
let saved_file = vfs_path.as_path().map(ToOwned::to_owned);
354-
world.flycheck[0].restart_workspace(saved_file);
350+
if let Some(flycheck) = world.flycheck.first() {
351+
flycheck.restart_workspace(saved_file);
352+
}
355353
Ok(())
356354
})
357355
}

0 commit comments

Comments
 (0)