Avoid index panic when flycheck list is empty#22634
Open
UnknownHacker1 wants to merge 1 commit into
Open
Conversation
This comment has been minimized.
This comment has been minimized.
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
093862b to
35f4602
Compare
bjorn3
reviewed
Jun 24, 2026
| @@ -336,7 +336,9 @@ fn run_flycheck(state: &mut GlobalState, vfs_path: VfsPath) -> bool { | |||
| "should have exactly one flycheck handle when invocation strategy is once" | |||
| ); | |||
Member
There was a problem hiding this comment.
Is not having any flycheck handle supposed to be a valid state? If so, shouldn't this always!() be removed? If not, ending up without any flycheck handle is still a separate bug that needs to be fixed rather than just worked around by the change in this PR.
Member
|
The issue is that without a toolchain we fail to discover any project which means we never populate the flychecks. I'd say this fix is fine, the entire state management is so convoluted in r-a that fixing this proper would entail cleaning all of that mess up imo. But yea, we should remove the always assert there then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #21638.
The
InvocationStrategy::Oncepath innotification.rsindexedworld.flycheck[0]directly. Thealways!()above it only logs in release builds, so when the flycheck list is empty it fell through and panicked with index out of bounds (the crash in #21638). This guards the access withfirst()and skips the restart when there's no handle.changelog fix Avoid a panic when restarting flycheck with an empty handle list