rust-lang / rust-lang/rust-bindgen
Error generation
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
error[E0740]: field must implement Copy or be wrapped in ManuallyDrop<...> to be used in a union
--> ./open/162/generated_bindings.rs:12:5
|
12 | pub _M_val: _Tp,
| ^^^^^^^^^^^^^^^
|
= note: union fields must not have drop side-effects, which is currently enforced via either Copy or ManuallyDrop<...>
help: wrap the field type in ManuallyDrop<...>
|
12 | pub _M_val: std::mem::ManuallyDrop<_Tp>,
| +++++++++++++++++++++++ +
error: aborting due to 1 previous error
For more information about this error, try rustc --explain E0740.
#[repr(C)]
pub union std_vector__Temporary_value__Storage<_Tp> {
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<_Tp>>,
pub _M_byte: ::std::os::raw::c_uchar,
pub _M_val: _Tp, //Error generation
}
#[repr(C)]
pub union std_vector__Temporary_value__Storage<_Tp> {
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<_Tp>>,
pub _M_byte: ::std::os::raw::c_uchar,
pub _M_val: ManuallyDrop<_Tp>, //Changing it to this compilation can be passed
}
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 examining the generated_bindings.rs example and run rustc --explain E0740 to confirm why the union field is rejected. Trace how rust-bindgen produces std_vector__Temporary_value__Storage and compare the _M_val output with the ManuallyDrop form shown; done means the generated binding compiles without E0740.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100