We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
x is not generic
Hi, thanks again for this project!
I wanted to report an x is not generic panic. This may be related to #770.
thread 'main' panicked at 'Dataset is not generic', src/bindgen/ir/generic_path.rs:83:9 stack backtrace: 0: _rust_begin_unwind 1: core::panicking::panic_fmt 2: cbindgen::bindgen::ir::generic_path::GenericParams::call 3: <cbindgen::bindgen::ir::typedef::Typedef as cbindgen::bindgen::ir::item::Item>::instantiate_monomorph 4: cbindgen::bindgen::ir::ty::Type::add_monomorphs 5: cbindgen::bindgen::library::Library::generate 6: cbindgen::bindgen::builder::Builder::generate 7: cbindgen::main
To reproduce, create two libs:
cargo new lib1 --lib cargo new lib2 --lib
In lib1/src/lib.rs, add:
lib1/src/lib.rs
pub struct Dataset<T> { data: Vec<T>, } impl<T> Dataset<T> { pub fn new() -> Self { Self { data: Vec::new() } } }
In lib2/Cargo.toml, add under [dependencies]:
lib2/Cargo.toml
[dependencies]
lib1 = { path = "../lib1" }
In lib2/src/lib.rs, add:
lib2/src/lib.rs
pub type Dataset = lib1::Dataset<u32>; #[no_mangle] pub unsafe extern "C" fn hello() -> *mut Dataset { Box::into_raw(Box::new(Dataset::new())) }
And in lib2, run:
cbindgen --lang c
A few notes:
The text was updated successfully, but these errors were encountered:
My bad, I think this may be a duplicate of #286.
Sorry, something went wrong.
For future readers, one way around this is to use an additional struct instead of a type alias.
pub struct Dataset(lib1::Dataset<u32>); #[no_mangle] pub unsafe extern "C" fn hello() -> *mut Dataset { Box::into_raw(Box::new(Dataset(lib1::Dataset::new()))) }
No branches or pull requests
Hi, thanks again for this project!
I wanted to report an
x is not generic
panic. This may be related to #770.To reproduce, create two libs:
In
lib1/src/lib.rs
, add:In
lib2/Cargo.toml
, add under[dependencies]
:lib1 = { path = "../lib1" }
In
lib2/src/lib.rs
, add:And in lib2, run:
A few notes:
The text was updated successfully, but these errors were encountered: