rust-lang / rust-lang/rust-bindgen
recursive without indirection
Open
Nobody has claimed this yet.
A-error-reporting
A-libclang
A-spe
I-bogus-codegen
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
I am using this script https://gist.github.com/fitzgen/187381e358f60efa8194d0b276b4d11a.
The hashtag for my bindgen version is 4dd4ac7 .
$ ./b.sh rust-bindgen/target/debug/bindgen abc.h
clang-4.0: warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated [-Wdeprecated]
error[E0072]: recursive type `C` has infinite size
--> /tmp/bindings-kGYvi3.rs:3:123
|
3 | # [ repr ( C ) ] pub struct C__bindgen_vtable ( :: std :: os :: raw :: c_void ) ; # [ repr ( C ) ] # [ derive ( Debug ) ] pub struct C { pub vtable_ : * const C__bindgen_vtable , pub a : C , }
| ^^^^^^^^^^^^ recursive type has infinite size --------- recursive without indirection
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `C` representable
error: aborting due to previous error
Interesting: bindgen emitted Rust code that won't compile!
$ cat abc.h
template < class T > struct C
{
explicit C (const C & t):a (t)
{
} virtual ~ T ()
{
} C 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
Reproduce the failure with the bindgen revision 4dd4ac7 using the script at the linked gist and the abc.h template shown in the issue. Inspect the generated /tmp/bindings-kGYvi3.rs and the handling of the recursive member; done means bindgen emits Rust bindings that compile without the recursive-type error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100