Commit c42a375
committed
ffi: don't use empty enums for opaque types
The nomicon doesn't like this. From the bottom of
https://doc.rust-lang.org/nomicon/ffi.html
"Notice that it is a really bad idea to use an empty enum as FFI type. The
compiler relies on empty enums being uninhabited, so handling values of
type &Empty is a huge footgun and can lead to buggy program behavior (by
triggering undefined behavior)."
They give an example that uses a phantom to also remove Send, Sync, and
Unpin. I did not do this. I think all these traits are fine, because the
type has no self-references and is never mutated by the C code except
when it is freed, and then only through a `*mut` pointer.1 parent 2d8c56e commit c42a375
1 file changed
Lines changed: 8 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
133 | | - | |
134 | | - | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
135 | 137 | | |
136 | 138 | | |
137 | 139 | | |
| |||
143 | 145 | | |
144 | 146 | | |
145 | 147 | | |
146 | | - | |
147 | | - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
148 | 152 | | |
149 | 153 | | |
150 | 154 | | |
| |||
0 commit comments