Fix ICE in try_to_raw_bytes when array elements have mismatched#152794
Open
reddevilmidzy wants to merge 1 commit intorust-lang:mainfrom
Open
Fix ICE in try_to_raw_bytes when array elements have mismatched#152794reddevilmidzy wants to merge 1 commit intorust-lang:mainfrom
try_to_raw_bytes when array elements have mismatched#152794reddevilmidzy wants to merge 1 commit intorust-lang:mainfrom
Conversation
Collaborator
|
|
Member
Author
|
Ah, it seems like the issue is resolved in #152492, but would it be better to revert the change to The error changes like this: #![expect(incomplete_features)]
#![feature(adt_const_params, generic_const_parameter_types, min_generic_const_args)]
fn foo<const N: usize, const A: [u8; N]>() {}
fn main() {
foo::<_, { [0, 1u8, 2u32, 8u64] }>();
//~^ ERROR the constant `8` is not of type `u8`
//~| ERROR the constant `2` is not of type `u8`
} |
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.
close: #152683
After #152001, suffixed integer literals preserve their own type during const lowering, so
try_to_raw_bytescould call.to_u8()on a scalar with size > 1, causing an ICE. Fix by usingtry_to_bits(Size::from_bytes(1)).ok()instead.r? BoxyUwU