rust-lang / rust-lang/rust-bindgen

Trying to use `new_bitfield_N` in static

Open
#3,125 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
5.3k
Forks
829
Avg merge
1d 1h
Merged PRs (30d)
15

Description

Hi!

I'm trying to use new_bitfield_N in a static. Is there a reason that the generated constructor isn't const?

error[E0015]: cannot call non-const fn `security_configuration::new_bitfield_1` in statics
   --> src/app_impl.rs:135:22
    |
135 |           _bitfield_1: da14531_sdk::bindings::security_configuration::new_bitfield_1(
    |  ______________________^
136 | |             gap_io_cap_GAP_IO_CAP_DISPLAY_YES_NO,
137 | |             gap_oob_GAP_OOB_AUTH_DATA_NOT_PRESENT,
138 | |         ),
    | |_________^

Regards

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate the bindgen code that emits new_bitfield_N constructors, then reproduce the reported static initialization in Rust and inspect existing generated-code tests. Done means the generated constructor can be used in a static without the E0015 error, with regression coverage for the generated output.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.