-
Notifications
You must be signed in to change notification settings - Fork 374
Enums shadowed by names in module #649
Copy link
Copy link
Closed
Description
I'm seeing misbehavior where an enum in a module causes mistranslation of a struct containing a #[repr(u32)] enum with the same name.
Here's a very simple test case:
test.rs:
mod uhoh {
enum BindingType { Buffer, NotBuffer }
}
#[repr(u32)]
pub enum BindingType { Buffer = 0, NotBuffer = 1 }
#[repr(C)]
pub struct BindGroupLayoutEntry {
pub ty: BindingType, // This is the repr(u32) enum
}cbindgen.toml
language = "C"
[export]
include = [
"BindGroupLayoutEntry",
]Running cbindgen 0.16.0:
$ cbindgen -c cbindgen.toml test.rs
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
enum BindingType {
Buffer = 0,
NotBuffer = 1,
};
typedef uint32_t BindingType;
typedef struct BindGroupLayoutEntry {
struct BindingType ty;
} BindGroupLayoutEntry;
Having the member be struct BindingType ty is invalid, because there is no struct BindingType in the header; it should instead be BindingType ty.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels