rust-lang / rust-lang/rust-bindgen

Support Clang parameter nullability attributes: _Nonnull & _Nullable for C headers

Open
#3,260 0 comments 2 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

Swift imports C apis while taking into account clang nullability attributes: _Nullable & _Nonnull which results in Optional<UnsafePointer<T> and UnsafePointer<T> for the respective Swift generated C bindings, these should map to the Rust option equivalent

There was a previous attempt to use implement this feature https://github.com/rust-lang/rust-bindgen/issues/1876, however the title is wrong, as these are clang level annotations and not objective-c exclusive annotations, in other words, hey can work on any plain C header, and are independent from objective-c rust support

Sources:

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

Start with the linked Swift and Clang documentation to understand how _Nullable and _Nonnull affect imported C pointers. Then trace rust-bindgen's handling of C headers and type generation. Done means plain C headers using either attribute produce the corresponding Rust optional or non-optional pointer binding.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, rust
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.