then the generated Rust file contains nothing. Without --allowlist-function, the generated file contains a const and a type, as expected. I'm confused by this—why would --allowlist-function have any impact on whether code is generated for a C enum? Is this a bindgen bug?
My interpretation -- which is based entirely on your example and reading the docs (not experience or experimentation) -- is that allow-listing is a globally on-or-off thing, and once you specify any of
--allowlist-type
--allowlist-function
--allowlist-var
then it is turned on. After which, for something to be included, it has to either match based on the specific allowlist rules you gave, or because it's a transitive dependency of something that matched.
You don't have any functions, and that's the only rule you gave, so nothing matches.
You could test this by
using --allowlist-type instead (or just adding it in addition)
adding a dummy function that somehow uses the enum
Gah, of course there's a documentation page laying everything out. Thanks for looking that up when I couldn't be bothered to do so. I'd just been consulting the command-line --help message, which says this:
--allowlist-function <regex>...
Allowlist all the free-standing functions matching <regex>. Other non-allowlisted functions will not be
generated.
And similarly for the other allowlist options. So I didn't get the hint about the "global switch" part.