rust-lang / rust-lang/rust-bindgen
call to unsafe function `std::intrinsics::transmute` is unsafe and requires unsafe block
Open
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
When compiling https://github.com/JMS55/dlss_wgpu/tree/deabf142d371b0f7700afc2741b9b43eb670b286.
warning[E0133]: call to unsafe function `std::intrinsics::transmute` is unsafe and requires unsafe block
--> D:\dlss_wgpu\target\debug\build\dlss_wgpu-6adfd00d523bab83\out/bindings.rs:12:9
|
12 | ::std::mem::transmute(self)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/unsafe-op-in-unsafe-fn.html>
= note: consult the function's documentation for information on how to avoid undefined behavior
note: an unsafe function restricts its caller, but its body is safe by default
--> D:\dlss_wgpu\target\debug\build\dlss_wgpu-6adfd00d523bab83\out/bindings.rs:11:5
|
11 | pub unsafe fn as_ref(&self) -> &T {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: `#[warn(unsafe_op_in_unsafe_fn)]` on by default
warning[E0133]: call to unsafe function `std::intrinsics::transmute` is unsafe and requires unsafe block
--> D:\dlss_wgpu\target\debug\build\dlss_wgpu-6adfd00d523bab83\out/bindings.rs:16:9
|
16 | ::std::mem::transmute(self)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/unsafe-op-in-unsafe-fn.html>
= note: consult the function's documentation for information on how to avoid undefined behavior
note: an unsafe function restricts its caller, but its body is safe by default
--> D:\dlss_wgpu\target\debug\build\dlss_wgpu-6adfd00d523bab83\out/bindings.rs:15:5
|
15 | pub unsafe fn as_mut(&mut self) -> &mut T {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
For more information about this error, try `rustc --explain E0133`.
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 locations shown in the warning, especially the as_ref and as_mut methods using transmute. Trace those generated methods back to bindgen's relevant code-generation entry point, then verify that generated bindings compile without the unsafe_op_in_unsafe_fn warning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100