diff --git a/src/bindgen/parser.rs b/src/bindgen/parser.rs index 6c95fa6..ebed817 100644 --- a/src/bindgen/parser.rs +++ b/src/bindgen/parser.rs @@ -707,11 +707,22 @@ impl Parse { return; } }; - if ty.is_none() { - return; - } - let impl_path = ty.unwrap().get_root_path().unwrap(); + let ty = match ty { + Some(ty) => ty, + None => return, + }; + + let impl_path = match ty.get_root_path() { + Some(p) => p, + None => { + warn!( + "Couldn't find path for {:?}, skipping associated constants", + ty + ); + return; + } + }; for item in items.into_iter() { if let syn::Visibility::Public(_) = item.vis { diff --git a/tests/expectations/associated_constant_panic.c b/tests/expectations/associated_constant_panic.c new file mode 100644 index 0000000..20c8381 --- /dev/null +++ b/tests/expectations/associated_constant_panic.c @@ -0,0 +1,4 @@ +#include +#include +#include +#include diff --git a/tests/expectations/associated_constant_panic.compat.c b/tests/expectations/associated_constant_panic.compat.c new file mode 100644 index 0000000..20c8381 --- /dev/null +++ b/tests/expectations/associated_constant_panic.compat.c @@ -0,0 +1,4 @@ +#include +#include +#include +#include diff --git a/tests/expectations/associated_constant_panic.cpp b/tests/expectations/associated_constant_panic.cpp new file mode 100644 index 0000000..9849fa3 --- /dev/null +++ b/tests/expectations/associated_constant_panic.cpp @@ -0,0 +1,4 @@ +#include +#include +#include +#include diff --git a/tests/expectations/both/associated_constant_panic.c b/tests/expectations/both/associated_constant_panic.c new file mode 100644 index 0000000..20c8381 --- /dev/null +++ b/tests/expectations/both/associated_constant_panic.c @@ -0,0 +1,4 @@ +#include +#include +#include +#include diff --git a/tests/expectations/both/associated_constant_panic.compat.c b/tests/expectations/both/associated_constant_panic.compat.c new file mode 100644 index 0000000..20c8381 --- /dev/null +++ b/tests/expectations/both/associated_constant_panic.compat.c @@ -0,0 +1,4 @@ +#include +#include +#include +#include diff --git a/tests/expectations/tag/associated_constant_panic.c b/tests/expectations/tag/associated_constant_panic.c new file mode 100644 index 0000000..20c8381 --- /dev/null +++ b/tests/expectations/tag/associated_constant_panic.c @@ -0,0 +1,4 @@ +#include +#include +#include +#include diff --git a/tests/expectations/tag/associated_constant_panic.compat.c b/tests/expectations/tag/associated_constant_panic.compat.c new file mode 100644 index 0000000..20c8381 --- /dev/null +++ b/tests/expectations/tag/associated_constant_panic.compat.c @@ -0,0 +1,4 @@ +#include +#include +#include +#include diff --git a/tests/rust/associated_constant_panic.rs b/tests/rust/associated_constant_panic.rs new file mode 100644 index 0000000..ff0c8ec --- /dev/null +++ b/tests/rust/associated_constant_panic.rs @@ -0,0 +1,7 @@ +pub trait F { + const B: u8; +} + +impl F for u16 { + const B: u8 = 3; +}