rust-lang / rust-lang/rust-bindgen
Types with flexible array member generic does not propagate to other types using the type
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
If a type has a flexible array member, any other types which use the type with a flexible array member in their own type does not have the generic for the flexible array member propagated.
For example, scan_params has an FAM (with a regex pass to wrap the FAM in a ManuallyDrop (see https://github.com/rust-lang/rust-bindgen/issues/2936):
https://github.com/i509VCB/nrf70/blob/issue/fam-bindgen/fw/bindings.rs#L3209-L3236
#[repr(C, packed)]
pub struct scan_params<FAM: ?Sized = [::core::ffi::c_uint; 0]> {
#[doc = " If 0x1, RPU force passive scan on all channels"]
pub passive_scan: ::core::ffi::c_ushort,
#[doc = " Number of ssid's in scan_ssids parameter"]
pub num_scan_ssids: ::core::ffi::c_uchar,
#[doc = " Specific SSID's to scan for"]
pub scan_ssids: [ssid; 2usize],
#[doc = " used to send probe requests at non CCK rate in 2GHz band"]
pub no_cck: ::core::ffi::c_uchar,
#[doc = " Bitmap of bands to be scanned. Value Zero will scan both 2.4 and 5 GHZ"]
pub bands: ::core::ffi::c_uchar,
#[doc = " Information element(s) data ie"]
pub ie: ie,
#[doc = " MAC address"]
pub mac_addr: [::core::ffi::c_uchar; 6usize],
#[doc = " Max scan duration in active scan. If zero rpu programs 50msec"]
pub dwell_time_active: ::core::ffi::c_ushort,
#[doc = " Max scan duration in passive scan. If zero rpu programs 150msec"]
pub dwell_time_passive: ::core::ffi::c_ushort,
#[doc = " Number of channels to be scanned"]
pub num_scan_channels: ::core::ffi::c_ushort,
#[doc = " If true, skip local and IANA Unicast reserved MACs"]
pub skip_local_admin_macs: ::core::ffi::c_uchar,
#[doc = " specific channels to be scanned"]
pub center_frequency: ::core::mem::ManuallyDrop<FAM>,
}
But then scan_params when used in umac_scan_info, the FAM type is not expanded:
https://github.com/i509VCB/nrf70/blob/issue/fam-bindgen/fw/bindings.rs#L3489-L3495
#[repr(C, packed)]
pub struct umac_scan_info {
#[doc = " scan type see &enum scan_reason"]
pub scan_reason: ::core::ffi::c_int,
#[doc = " scan parameters scan_params"]
pub scan_params: scan_params,
}
Since the FAM type is not propagated to umac_scan_info, it is not possible to use the FAM parameter
Bindgen invocation:
https://github.com/i509VCB/nrf70/blob/issue/fam-bindgen/gen.py#L111-L124
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 with the generated bindings in fw/bindings.rs, especially scan_params and umac_scan_info, and review the bindgen invocation in gen.py around lines 111-124. Trace how the nested scan_params type is emitted; done when its flexible-array-member generic is propagated through umac_scan_info and the generated bindings support using that parameter.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100