Skip to content

Support cfg attributes on function arguments - #1173

Open
floze-the-genius wants to merge 2 commits into
mozilla:mainfrom
floze-the-genius:agent/cfg-function-arguments
Open

Support cfg attributes on function arguments#1173
floze-the-genius wants to merge 2 commits into
mozilla:mainfrom
floze-the-genius:agent/cfg-function-arguments

Conversation

@floze-the-genius

@floze-the-genius floze-the-genius commented Jul 18, 2026

Copy link
Copy Markdown

Summary

  • preserve #[cfg] attributes when loading function arguments into the IR
  • emit cfg-aware C/C++ parameter lists with valid comma placement
  • emit void when every conditional argument is disabled
  • omit swift_name attributes when conditional parameters would make their fixed arity invalid
  • add regression fixtures for conditional arguments in leading, middle, trailing, and all-conditional positions

Fixes #1037.

Testing

  • CBINDGEN_TEST_VERIFY=1 cargo test --test tests with nightly on PATH: 159/159 passed
  • generated C and C++ compiled with Clang using neither define, each define independently, and both defines
  • cargo test --lib --bins: 4/4 passed
  • cargo check --all-targets
  • cargo fmt -- --check
  • git diff --check
  • cargo clippy --all-targets -- -D warnings reaches a pre-existing clippy::too_many_arguments finding in tests/tests.rs:31; the changed production code is not implicated

AI disclosure

I used OpenAI Codex to assist with issue discovery, implementation, and test execution. I reviewed and understand the changes and verified them locally.

@floze-the-genius
floze-the-genius force-pushed the agent/cfg-function-arguments branch from 58845d0 to 5ff5054 Compare August 9, 2026 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optional function argument is not exported correctly

1 participant