Skip to content

Build bindgen without its prettyplease feature - #148

Open
sabzanotto7 wants to merge 2 commits into
HMIProject:mainfrom
sabzanotto7:bindgen-without-prettyplease
Open

sabzanotto7 wants to merge 2 commits into
HMIProject:mainfrom
sabzanotto7:bindgen-without-prettyplease

Conversation

@sabzanotto7

Copy link
Copy Markdown

build.rs never selects a formatter, so bindgen formats the bindings with its default,
Formatter::Rustfmt. bindgen's prettyplease feature is on by default, so prettyplease is
compiled into the build script and never called. This turns that feature off and keeps the other
two defaults, logging and runtime.

Why

bindgen 0.73.2 accepts syn 2 or 3 and prettyplease 0.2 or 0.3 independently, while
prettyplease 0.3 needs syn 3. In a dependent's lock file that holds both syn majors (most
larger workspaces do), an unrelated cargo update can leave bindgen on syn 2 beside
prettyplease 0.3, and bindgen then fails to compile with the ParseQuote error reported in
rust-lang/rust-bindgen#3448 and rust-lang/rust-bindgen#3551. The fix proposed there
(rust-lang/rust-bindgen#3506) is not released.

The failing syn::parse_quote! sits behind bindgen's prettyplease feature. Without the feature
the pair cannot break the build of this crate, whichever syn the resolver picks, and there is one
crate fewer to compile.

Checked

  • bindings.rs is byte-identical before and after (x86_64 Linux, same sha256), since rustfmt
    stays the formatter.
  • cargo test --locked passes.
  • Cargo.lock loses prettyplease and nothing else moves.

🤖 Generated with Claude Code

build.rs never selects a formatter, so bindgen formats the bindings with
its default, rustfmt. The prettyplease feature, on by default, is compiled
and never called.

bindgen 0.73.2 accepts syn 2 or 3 and prettyplease 0.2 or 0.3
independently, and prettyplease 0.3 needs syn 3. In a dependent's lock
file that holds both syn majors, an unrelated `cargo update` can leave
bindgen on syn 2 beside prettyplease 0.3, and bindgen then fails to
compile (rust-lang/rust-bindgen#3448, rust-lang/rust-bindgen#3551). The
failing code sits behind the prettyplease feature, so without the feature
the pair cannot break the build.

The generated bindings are byte-identical before and after.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
sgoll
sgoll previously approved these changes Nov 23, 2026

@sgoll sgoll left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👍

@sgoll
sgoll requested a review from uklotzde November 23, 2026 13:02
uklotzde
uklotzde previously approved these changes Nov 23, 2026
@sgoll

sgoll commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

@sabzanotto7 Can you fix the auto-formatting in the changelog? See the failing pre-commit check.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@sabzanotto7
sabzanotto7 dismissed stale reviews from uklotzde and sgoll via ec0f7f1 November 24, 2026 03:26
Comment thread CHANGELOG.md

## [Unreleased]

### Changed

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sgoll Do really need a changelog entry? There are no user facing changes, just an internal build optimization.

IMHO only adds noise and could be removed. The Git history is appropriate to store this info.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure. From the PR description, the change does read like something that affects consumers of the crate, resulting in possible bindgen compilation errors without it.

@sabzanotto7 Care to weigh in? Would you say we should reword the changelog message slightly, so it better explains the consequences of the change, instead of purely describing what it does?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants