rust-lang / rust-lang/rust-bindgen
Bindings fail to compile with "recursive type .. has infinte size" and "cycle detected when computing drop-check constraints"
Open
Nobody has claimed this yet.
A-C++
A-templates
bug
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
C++ header
template <class a> struct b : a { typename b::c d; };
bindgen command
bindgen test-case-3.hpp -- -x c++
Produced bindings
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct b<a> {
pub _base: a,
pub d: b<a>,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<a>>,
}
rustc --crate-type lib bindings.rs produces
error[E0072]: recursive type `b` has infinite size
--> bindings.rs:5:1
|
5 | pub struct b<a> {
| ^^^^^^^^^^^^^^^ recursive type has infinite size
6 | pub _base: a,
7 | pub d: b<a>,
| ---- recursive without indirection
|
help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `b` representable
|
7 | pub d: Box<b<a>>,
| ^^^^ ^
error[E0391]: cycle detected when computing drop-check constraints for `b`
--> bindings.rs:5:1
|
5 | pub struct b<a> {
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with bindgen test-case-3.hpp -- -x c++, then compile the generated bindings.rs with rustc --crate-type lib. Compare the generated recursive field with the reported E0072 and E0391 errors. Done means the bindings generated from this C++ header compile without those errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100