rust-lang / rust-lang/rust-bindgen
[0.71.1]: Invalid generated method names.
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
Unable to compile Mesa with 0.71.1 for Fedora in a Mesa CI container due to the following:
[3762/4770] Compiling Rust source src/etnaviv/isa/isa_bindings.rs
FAILED: src/etnaviv/isa/libisa_bindings.rlib
rustc -C linker=cc --color=always -C debug-assertions=no -C overflow-checks=no --crate-type rlib -D warnings --edition=2021 -C opt-level=3 --crate-name isa_bindings --emit dep-info=src/etnaviv/isa/isa_bindings.d --emit link=src/etnaviv/isa/libisa_bindings.rlib --out-dir src/etnaviv/isa/libisa_bindings.rlib.p -C metadata=5824fa0@@isa_bindings@sta -Anon_camel_case_types src/etnaviv/isa/isa_bindings.rs
error: method `use__raw` should have a snake case name
--> src/etnaviv/isa/isa_bindings.rs:1:9453
|
1 | ...s u64) } } # [inline] pub unsafe fn use__raw (this : * const Self) -> :: std :: os :: raw :: c_uint { unsafe { :: std :: mem :: transm...
| ^^^^^^^^ help: convert the identifier to snake case: `use_raw`
|
= note: `-D non-snake-case` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(non_snake_case)]`
error: method `use__raw` should have a snake case name
--> src/etnaviv/isa/isa_bindings.rs:1:29259
|
1 | ...s u64) } } # [inline] pub unsafe fn use__raw (this : * const Self) -> :: std :: os :: raw :: c_uint { unsafe { :: std :: mem :: transm...
| ^^^^^^^^ help: convert the identifier to snake case: `use_raw`
error: aborting due to 2 previous errors
The field is called use on the C side, however as this is a reserved keyword bindgen is suffixing a _, but not dropping it when the function is named.
Encountered in the following Mesa MR: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33725#note_2909634
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the generated src/etnaviv/isa/isa_bindings.rs output from the Mesa example and trace bindgen's handling of the C field named use. Check the generated method-name path for reserved keywords and compare it with the expected use_raw form. Done means the generated Rust passes the shown -D warnings build without invalid non-snake-case method names.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100