You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Remove Debug implementation for types where any default impls are UB
This restores buildability with nightly releases after around 2022-04
when it became stricter around unaligned access.
Workaround-For: rust-lang/rust-bindgen#2221
See-Also: #3
Copy file name to clipboardExpand all lines: build.rs
+33
Original file line number
Diff line number
Diff line change
@@ -181,6 +181,39 @@ fn main() {
181
181
.use_core()
182
182
.ctypes_prefix("libc")
183
183
.impl_debug(true)
184
+
// Structs listed here are Packed and thus need impl_debug, but also contain non-Copy
185
+
// members.
186
+
//
187
+
// This is a workaround for <https://github.com/rust-lang/rust-bindgen/issues/2221>; once
188
+
// that is fixed and our bindgen is updated, these can just go away again.
189
+
//
190
+
// If you see any errors like
191
+
//
192
+
// ```
193
+
// error: reference to packed field is unaligned
194
+
// --> .../out/bindings.rs:79797:13
195
+
// |
196
+
// 79797 | self.opcode, self.length, self.data
197
+
// | ^^^^^^^^^^^
198
+
// |
199
+
// = note: `#[deny(unaligned_references)]` on by default
200
+
// = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
201
+
// = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
202
+
// = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
203
+
// = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
204
+
// = note: this error originates in the macro `$crate::format_args` (in Nightly builds, run with -Z macro-backtrace for more info)
205
+
// ```
206
+
//
207
+
// please add the offending struct in here; if existing code depends on the Debug
208
+
// implementation, you may add a Debug implementation (that possibly is just a dummy, for
209
+
// in these cases it *is* hard to implement showing all details) to this crate for the
0 commit comments