MaybeUninit, ManuallyDrop, and Pin bindings is't transparent
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 3k
- Forks
- 386
- Avg merge
- 1h 43m
- Merged PRs (30d)
- 1
Description
Documentation for std types says what MaybeUninit<T>, ManuallyDrop<T>, and Pin<T> will be mapped into T, but instead of such behavior it creates additional structure.
Minimal reproducible example
lib.rs
use std::mem::ManuallyDrop;
#[unsafe(no_mangle)]
pub extern "C" fn test_func() -> ManuallyDrop<i32> {
todo!()
}
cbindgen output (no additional flags and cbindgen.toml configs)
#include <cstdarg>
#include <cstdint>
#include <cstdlib>
#include <ostream>
#include <new>
template<typename T = void>
struct ManuallyDrop;
extern "C" {
ManuallyDrop<int32_t> test_func();
} // extern "C"
Currently it's need to manually exclude the ManuallyDrop from binding generation, and write it by yourself. Here's example for it from unit tests.
I think it should generate such by default:
template <typename T>
using MaybeUninit = T;
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 with the std-types behavior described in docs.md and the reproduction in lib.rs. Compare the generated output with the existing tests/rust/maybeuninit.toml example, then trace how MaybeUninit, ManuallyDrop, and Pin are represented. Done means the documented transparent mapping is generated by default and the relevant tests cover it.
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
- 48/100