`generate_cstr(true)` results in weird spacing for long strings
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
Research direction
Start by reproducing the issue with the provided Builder::header_contents and generate_cstr(true) example, then inspect the generate_cstr output path used by Builder::generate. Compare the spacing of the short and long generated CStr declarations; done means equivalent declarations use consistent formatting without changing the generated values.
Written by the indexing model from the issue text.
Description
With bindgen 0.72.1, the following code:
fn main() {
let builder = bindgen::Builder::default()
.header_contents(
"php_config.h",
r#"
#define PHP_OS "Linux"
#define PHP_BUILD_SYSTEM "Linux b355e0901ee6 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 GNU/Linux"
"#
)
.generate_cstr(true);
let bindings = builder.generate().expect("Unable to generate bindings");
bindings
.write_to_file("bindings.rs")
.expect("Couldn't write bindings!");
}
resulted in:
/* automatically generated by rust-bindgen 0.72.1 */
pub const PHP_OS: &::std::ffi::CStr = c"Linux";
pub const PHP_BUILD_SYSTEM : & :: std :: ffi :: CStr = c"Linux b355e0901ee6 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 GNU/Linux" ;
the spacing of & :: std :: ffi :: CStr for the second string looks odd, especially since the first string was done with &::std::ffi::CStr
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
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.
More from rust-lang/rust-bindgen
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
rust-lang/rust-bindgen#3485 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
rust-lang/rust-bindgen#3483 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
rust-lang/rust-bindgen#3481 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
rust-lang/rust-bindgen#3370 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
rust-lang/rust-bindgen#3363 ·
All issues in rust-lang/rust-bindgen
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
gitbutlerapp/gitbutler#15998 · 1 comment ·
-
bug triage:deciding
Difficulty 1/5 Under an hour Newbie friendliness 88/100
open-telemetry/otel-arrow#4132 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
bitcoindevkit/bdk-ffi#1125 ·