File tree Expand file tree Collapse file tree
extensions/bindgen/private Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -243,7 +243,18 @@ def _rust_bindgen_impl(ctx):
243243 args .add_all (ctx .attr .bindgen_flags )
244244
245245 rust_toolchain = ctx .toolchains [Label ("@rules_rust//rust:toolchain_type" )]
246- if "--rust-edition" not in [f .split ("=" )[0 ] for f in ctx .attr .bindgen_flags ]:
246+ user_flags = [f .split ("=" )[0 ] for f in ctx .attr .bindgen_flags ]
247+
248+ # Ignore `nightly` or `beta` versions.
249+ if rust_toolchain .version and rust_toolchain .version [0 ].isdigit ():
250+ # Pass `--rust-target` so bindgen knows the actual toolchain version.
251+ # Without this, bindgen defaults to it's built-in `LATEST_STABLE_RUST`
252+ # which may be older than the actual toolchain version and would
253+ # reject newer editions (e.g. edition 2024 requires `rust-target >= 1.85.0`).
254+ if "--rust-target" not in user_flags :
255+ args .add ("--rust-target=%s" % rust_toolchain .version )
256+
257+ if "--rust-edition" not in user_flags :
247258 args .add ("--rust-edition=%s" % rust_toolchain .default_edition )
248259
249260 args .add (header )
You can’t perform that action at this time.
0 commit comments