Skip to content

Commit 35f4602

Browse files
Guard against empty flycheck list in once invocation strategy
The InvocationStrategy::Once path indexed world.flycheck[0] directly. The always!() above only logs in release builds, so when the list was empty it fell through and panicked with index out of bounds. Use first() and skip the restart when there is no handle. Fixes rust-lang#21638
1 parent ff5fcc7 commit 35f4602

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,9 @@ fn run_flycheck(state: &mut GlobalState, vfs_path: VfsPath) -> bool {
336336
"should have exactly one flycheck handle when invocation strategy is once"
337337
);
338338
let saved_file = vfs_path.as_path().map(ToOwned::to_owned);
339-
world.flycheck[0].restart_workspace(saved_file);
339+
if let Some(flycheck) = world.flycheck.first() {
340+
flycheck.restart_workspace(saved_file);
341+
}
340342
Ok(())
341343
})
342344
}

0 commit comments

Comments
 (0)