Re: [PATCH] rust: workaround `bindgen` issue with forward references to `enum` types
From: Miguel Ojeda
Date: Tue Feb 24 2026 - 12:30:59 EST
On Tue, Mar 25, 2025 at 7:43 PM Miguel Ojeda <ojeda@xxxxxxxxxx> wrote:
>
> `bindgen` currently generates the wrong type for an `enum` when there
> is a forward reference to it. For instance:
>
> enum E;
> enum E { A };
>
> generates:
>
> pub const E_A: E = 0;
> pub type E = i32;
>
> instead of the expected:
>
> pub const E_A: E = 0;
> pub type E = ffi::c_uint;
>
> The issue was reported to upstream `bindgen` [1].
This should be fixed now in:
https://github.com/rust-lang/rust-bindgen/pull/3346
So we will likely have it in bindgen 0.73.0. Thus, after a couple
years or so, we should be able to remove the workaround.
Cheers,
Miguel