rust-lang / rust-lang/rust-bindgen

Extend `--with-attribute-custom` to support more types

Open
#2,978 2 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

I would like to use custom attributes to feature guard bindings based on information in the doc comment.

E.g. if the doc comment contains @since 10, I would like to generate

#[cfg(feature = "api-10")]
<the item>

Currently, add_attributes seems to only support structs, enums and unions. I would like to also have support for functions and ideally also enum variants.
Would a PR that adds function support to add_attributes() be accepted?

CC @mkroening Any technical reason your PR did not implement support for functions, or did you just not need it for your usecase?

Edit: It seems that it also is not possible / intended to add attributes during the processing of the doc comment callback, so that would also need to be changed to support my usecase.

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 by tracing add_attributes() and the doc comment callback mentioned in the issue. Determine how attributes are currently applied to structs, enums, and unions, then verify what changes are needed for functions and enum variants; done means the requested custom feature guards work for those item types and the relevant behavior is covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
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.