fix: Don't panic on out-of-range integer literals in const positions#22621
Merged
Conversation
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.
Writing an array length that doesn't fit in
usize, like[u8; 18446744073709551616], makes rust-analyzer panic and then spam the log withPropagating panic for cycle head ...over and over.The problem is in
intern_const_ref: it interns the literal withScalarInt::try_from_uint(..).unwrap(), buttry_from_*returnsNonewhen the value doesn't fit the target type, so theunwrap()blows up inside a salsa query. I changed those three integer branches (andusize_const) to return an error const instead of unwrapping, so an out-of-range literal is just treated as an error rather than crashing.Also added a regression test. Running
analysis-statson the repro reportspanics: 1before the change andpanics: 0after.Closes #22620