rust-lang / rust-lang/rust-bindgen

feature request: add option to map nonull to ptr::NonNull

Open
#1,791 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

There is supported by clang extension to mark pointers as nonnull

Input C/C++ Header
#if defined(__clang__)
#define C4NONNULL __attribute((nonnull))
#else
#define C4NONNULL /**/
#endif

void f(int *p C4NONNULL);

It would be nice to have option to automatically convert types with such attribute to std::ptr::NonNull,
this repr(transparent) type so this would be valid transformation.
I deal with big enough C API where a lot of argument types have such attribute,
and this automatic conversation will help.

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

No files, tests, or entry points are named. Start by reading bindgen's handling of Clang nonnull attributes and pointer type generation; done means an option converts pointers marked with the attribute to ptr::NonNull and has coverage for the transformation.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, cpp, rust
Domain
compilers, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.