Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why does cbindgen transfer annotations from typedef to the underlying aliased type? #1027

Open
scovich opened this issue Nov 4, 2024 · 1 comment

Comments

@scovich
Copy link
Contributor

scovich commented Nov 4, 2024

A very ancient commit 98c707b attempts to transfer annotations from each Typedef to its underlying aliased type. The attempt fails if the aliased type already has annotations, or if multiple typedefs alias the same type.

What purpose does annotation transfer serve? I can't think of any reason it's necessary, and it risks causing unintended side effects.

For example, a must-use typedef forces the underlying struct to be must-use as well, which is probably not the original intent -- if the code writer intended for a struct to be must-use, they would annotate the struct as must-use -- not some random typedef (of potentially several) that happens to alias it.

There are no code comments explaining why this behavior is desirable, let alone necessary. There is no pull request associated with the commit that might explain the change, no issue tracking the feature, and no unit tests fail if I disable the code.

@scovich
Copy link
Contributor Author

scovich commented Nov 4, 2024

CC @eqrion @emilio in case they have context?

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

No branches or pull requests

1 participant