Repository navigation
Conversation
libclang has no CXType_Char8, so char8_t reaches build_builtin_ty as CXType_Unexposed and is not recognized. Array element types then fail to resolve and bindgen panics with "Not able to resolve array element?", and enums with a char8_t underlying type are emitted as signed. Map an unexposed type whose canonical spelling is char8_t to u8. Fixes rust-lang#3474. Fixes rust-lang#3464.
This branch has not been deployed
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 #3474
Fixes #3464
Root cause
libclang has no
CXType_Char8, so achar8_ttype reachesbuild_builtin_tyasCXType_Unexposedand gets no builtin mapping. Scalar uses still came out asu8through the fallback path, but an array element type returnedParseError::Recurseand theCXType_ConstantArrayarm panicked withNot able to resolve array element?.Enum::from_tyalso could not resolve the underlying type and treated it as signed, soenum class E : char8_t { HEX = u8'\xFF' }producedpub type E = i8andE_HEX = -1.Fix
build_builtin_ty, map an unexposed type whose canonical spelling ischar8_t(ignoringconst/volatile) toIntKind::U8.char8_t.hpptest covering fixed, incomplete and nested arrays, a struct field array, a function parameter and an enum with achar8_tunderlying type.Testing
Ubuntu (WSL), libclang 21.1.8, rustc 1.99.1.
cargo test -p bindgen-tests -- char8_taborts withNot able to resolve array element?: Recurse.[u8; N]and the enum aspub type Char8Enum = u8withChar8Enum_High = 255.cargo test -p bindgen-tests -p bindgenleaves every other expectation file unchanged, andcargo +nightly fmt -- --checkis clean.