mozilla / cbindgen

A project for generating C bindings from Rust code
Mozilla Public License 2.0
2.29k stars 294 forks source link

cbindgen can not find struct from pre-release crates #925

Closed chyyran closed 5 months ago

chyyran commented 5 months ago

Repro here: https://github.com/SnowflakePowered/librashader/tree/preset-context/librashader-capi.

Run under the librashader-capi directory

$ cbindgen -d -c cbindgen.toml -o librashader.h

Note the error message

WARN: Can't find WildcardContext. This usually means that this type was incompatible or not found.

However, WildcardContext is a struct exported from a local crate here: librashader_presets::context::WildcardContext. The only real snaggle I could think of is that it's being accessed through a re-export of a root crate, librashader::presets::context::WildcardContext.

Bindings seem to generate properly for a similar struct, librashader_presets::ShaderPreset, and there is no warning for ShaderPreset. Both structs are exported in similar ways in the same crate. I even tried moving WildcardContext to the root of librashader_presets but the same error occurred.

chyyran commented 5 months ago

An update on this, I removed the -beta.8 from librashader-presets and it could pick up the struct just fine.