| 1 | # `bytemuck` changelog |
| 2 | |
| 3 | ## 1.24 |
| 4 | |
| 5 | * [use new stable avx512 types from rust 1.89](https://github.com/Lokathor/bytemuck/pull/322) |
| 6 | * [impl AnyBitPattern for [MaybeUninit<T: AnyBitPattern>; N]](https://github.com/Lokathor/bytemuck/pull/317) |
| 7 | * bump `derive` minimum version. |
| 8 | |
| 9 | ## 1.23.2 |
| 10 | |
| 11 | * bump `derive` minimum version. |
| 12 | |
| 13 | ## 1.23.1 |
| 14 | |
| 15 | * Added a windows-only `ZeroableInOption` impl for "stdcall" functions. |
| 16 | |
| 17 | ## 1.23 |
| 18 | |
| 19 | * `impl_core_error` crate feature adds `core::error::Error` impl. |
| 20 | * More `ZeroableInOption` impls. |
| 21 | |
| 22 | ## 1.22 |
| 23 | |
| 24 | * Add the `pod_saturating` feature, which adds `Pod` impls for `Saturating<T>` |
| 25 | when `T` is already `Pod`. |
| 26 | * A bump in the minimum `bytemuck_derive` dependency from 1.4.0 to 1.4.1 to |
| 27 | avoid a bug if you have a truly ancient `cargo.lock` file sitting around. |
| 28 | * Adds `Send` and `Sync` impls to `BoxBytes`. |
| 29 | |
| 30 | ## 1.21 |
| 31 | |
| 32 | * Implement `Pod` and `Zeroable` for `core::arch::{x86, x86_64}::__m512`, `__m512d` and `__m512i` without nightly. |
| 33 | Requires Rust 1.72, and is gated through the `avx512_simd` cargo feature. |
| 34 | * Allow the use of `must_cast_mut` and `must_cast_slice_mut` in const contexts. |
| 35 | Requires Rust 1.83, and is gated through the `must_cast_extra` cargo feature. |
| 36 | * internal: introduced the `maybe_const_fn` macro that allows defining some function |
| 37 | to be const depending upon some `cfg` predicate. |
| 38 | |
| 39 | ## 1.20 |
| 40 | |
| 41 | * New functions to allocate zeroed `Arc` and `Rc`. Requires Rust 1.82 |
| 42 | * `TransparentWrapper` impls for `core::cmp::Reverse` and `core::num::Saturating`. |
| 43 | * internal: Simplified the library's `fill_zeroes` calls to `write_bytes` |
| 44 | |
| 45 | ## 1.19 |
| 46 | |
| 47 | * Adds the `#[track_caller]` attribute to functions which may panic. |
| 48 | |
| 49 | ## 1.18 |
| 50 | |
| 51 | * Adds the `latest_stable_rust` cargo feature, which is a blanket feature that turns all other features on that are both sound and compatible with Stable rust. |
| 52 | |
| 53 | ## 1.17.1 |
| 54 | |
| 55 | * Adds `#[repr(C)]` to the `union Transmute<A, B>` type that's used internally |
| 56 | for most of the transmutations. |
| 57 | |
| 58 | ## 1.17.0 |
| 59 | |
| 60 | * Makes the `must_cast` versions of the by-value and by-ref casts be `const`. |
| 61 | The mut ref cast is unaffected for now (mut references aren't yet stable in `const fn`). |
| 62 | This increases the MSRV of using that particular feature from 1.57 to 1.64. |
| 63 | |
| 64 | ## 1.16.3 |
| 65 | |
| 66 | * Fully described in https://github.com/Lokathor/bytemuck/pull/256, This makes |
| 67 | casting slices to/from ZST elements more consistent between the crate's core |
| 68 | module and other modules. |
| 69 | |
| 70 | ## 1.16.2 |
| 71 | |
| 72 | * Fixes potential UB where `BoxBytes` could attempt to free a dangling pointer |
| 73 | if the `Layout` is zero sized. This type was introduced in 1.14.1, so that |
| 74 | version and the others up to and including 1.16.1 are now yanked for safety. |
| 75 | |
| 76 | ## 1.16.1 |
| 77 | |
| 78 | * **NOT SEMVER SUPPORTED:** Adds the `nightly_float` Cargo feature. This |
| 79 | activates the `f16` and `f128` nightly features, and then provides `Zeroable` |
| 80 | and `Pod` impls for those types. |
| 81 | |
| 82 | ## 1.16.0 |
| 83 | |
| 84 | * Adds a `const_zeroed` feature (MSRV 1.75) which puts a `zeroed` fn at the crate root. |
| 85 | This is just like the `Zeroable::zeroed` method, but as a `const fn`. |
| 86 | |
| 87 | ## 1.15.0 |
| 88 | |
| 89 | This primarily relaxes the bounds on a `From` impl. |
| 90 | |
| 91 | Previously: |
| 92 | |
| 93 | > `impl<T: NoUninit> From<Box<T>> for BoxBytes` |
| 94 | |
| 95 | Now: |
| 96 | |
| 97 | > `impl<T: ?Sized + sealed::BoxBytesOf> From<Box<T>> for BoxBytes` |
| 98 | |
| 99 | All related functions and methods are similarly updated. |
| 100 | |
| 101 | We believe this to be backwards compatible with all previous uses, |
| 102 | and now `BoxBytes` can be converted to/from more types than before. |
| 103 | |
| 104 | ## 1.14.3 |
| 105 | |
| 106 | * The new std simd nightly features are apparently arch-specific. |
| 107 | This adjusts the feature activation to be x86/ x86_64 only. |
| 108 | |
| 109 | ## 1.14.2 |
| 110 | |
| 111 | * Changes the name of the Nightly feature activated by the crate's |
| 112 | `nightly_stdsimd` feature. This is needed as of (approximately) Nightly |
| 113 | 2024-02-06 and later, because the Nightly feature was changed. |
| 114 | |
| 115 | ## 1.14.1 |
| 116 | |
| 117 | * docs clarifications. |
| 118 | |
| 119 | ## 1.14 |
| 120 | |
| 121 | * `write_zeroes` and `fill_zeroes` functions: Writes (to one) or fills (a slice) |
| 122 | zero bytes to all bytes covered by the provided reference. If your type has |
| 123 | padding, this will even zero out the padding bytes. |
| 124 | * `align_offset` feature: causes pointer alignment checks to use the |
| 125 | `align_offset` pointer method rather than as-casting the pointer to `usize`. |
| 126 | This *may* improve codegen, if the compiler would have otherwise thought that |
| 127 | the pointer address escaped. No formal benchmarks have been done either way. |
| 128 | * `must_cast` feature: Adds `must_*` family of functions. These functions will |
| 129 | fail to compile if the cast requested can't be statically known to succeed. |
| 130 | The error messages can be kinda bad when this happens, but eliminating the |
| 131 | possibility of a runtime error might be worth it to you. |
| 132 | |
| 133 | ## 1.13.1 |
| 134 | |
| 135 | * Remove the requirement for the *source* data type to be `AnyBitPattern` on |
| 136 | `pod_collect_to_vec`, allowing you to pod collect vecs of `char` into vecs of |
| 137 | `u32`, or whatever. |
| 138 | |
| 139 | ## 1.13 |
| 140 | |
| 141 | * Now depends on `bytemuck_derive-1.4.0` |
| 142 | * Various small enhancements that would have been patch version updates, but |
| 143 | which have been rolled into this minor version update. |
| 144 | |
| 145 | ## 1.12.4 |
| 146 | |
| 147 | * This has additional impls for existing traits and cleans up some internal code, |
| 148 | but there's no new functions so I guess it counts as just a patch release. |
| 149 | |
| 150 | ## 1.12.3 |
| 151 | |
| 152 | * This bugfix makes the crate do stuff with `Arc` or not based on the |
| 153 | `target_has_atomic` config. Previously, some targets that have allocation but |
| 154 | not atomics were getting errors. This raises the MSRV of the |
| 155 | `extern_crate_alloc` feature to 1.60, but opt-in features are *not* considered |
| 156 | to be hard locked to 1.34 like the basic build of the crate is. |
| 157 | |
| 158 | ## 1.12.2 |
| 159 | |
| 160 | * Fixes `try_pod_read_unaligned` bug that made it always fail unless the target |
| 161 | type was exactly pointer sized in which case UB *could* happen. The |
| 162 | `CheckedBitPattern::is_valid_bit_pattern` was being asked to check that a |
| 163 | *reference* to the `pod` value was a valid bit pattern, rather than the actual |
| 164 | bit pattern itself, and so the check could in some cases be illegally |
| 165 | bypassed. |
| 166 | |
| 167 | ## 1.12.1 |
| 168 | |
| 169 | * Patch bumped the required `bytemuck_derive` version because of a regression in |
| 170 | how it handled `align(N)` attributes. |
| 171 | |
| 172 | ## 1.12 |
| 173 | |
| 174 | * This minor version bump is caused by a version bump in our `bytemuck_derive` |
| 175 | dependency, which is in turn caused by a mixup in the minimum version of `syn` |
| 176 | that `bytemuck_derive` uses. See [Issue |
| 177 | 122](https://github.com/Lokathor/bytemuck/issues/122). There's not any |
| 178 | specific "new" API as you might normally expect from a minor version bump. |
| 179 | * [pali](https://github.com/pali6) fixed a problem with SPIR-V builds being |
| 180 | broken. The error handling functions were trying to be generic over `Display`, |
| 181 | which the error types normally support, except on SPIR-V targets (which run on |
| 182 | the GPU and don't have text formatting). |
| 183 | |
| 184 | ## 1.11 |
| 185 | |
| 186 | * [WaffleLapkin](https://github.com/WaffleLapkin) added `wrap_box` and `peel_box` |
| 187 | to the `TransparentWrapperAlloc` trait. Default impls of these functions are |
| 188 | provided, and (as usual with the transparent trait stuff) you should not override |
| 189 | the default versions. |
| 190 | |
| 191 | ## 1.10 |
| 192 | |
| 193 | * [TheEdward162](https://github.com/TheEdward162) added the `ZeroableInOption` |
| 194 | and `PodInOption` traits. These are for types that are `Zeroable` or `Pod` |
| 195 | *when in an option*, but not on their own. We provide impls for the various |
| 196 | "NonZeroINTEGER" types in `core`, and if you need to newtype a NonZero value |
| 197 | then you can impl these traits when you use `repr(transparent)`. |
| 198 | |
| 199 | ## 1.9.1 |
| 200 | |
| 201 | * Bumped the minimum `bytemuck_derive` dependency version from `1.0` to `1.1`. |
| 202 | The fact that `bytemuck` and `bytemuck_derive` are separate crates at all is |
| 203 | an unfortunate technical limit of current Rust, woe and calamity. |
| 204 | |
| 205 | ## 1.9.0 |
| 206 | |
| 207 | * [fu5ha](https://github.com/fu5ha) added the `NoUninit`, `AnyBitPattern`, and |
| 208 | `CheckedBitPattern` traits. This allows for a more fine-grained level of |
| 209 | detail in what casting operations are allowed for a type. Types that already |
| 210 | implement `Zeroable` and `Pod` will have a blanket impl for these new traits. |
| 211 | This is a "preview" of the direction that the crate will probably go in the |
| 212 | eventual 2.0 version. We're still waiting on [Project Safe |
| 213 | Transmute](https://github.com/rust-lang/project-safe-transmute) for an actual |
| 214 | 2.0 version of the crate, but until then please enjoy this preview. |
| 215 | * Also Fusha added better support for `union` types in the derive macros. I |
| 216 | still don't know how any of the proc-macro stuff works at all, so please |
| 217 | direct questions to her. |
| 218 | |
| 219 | ## 1.8.0 |
| 220 | |
| 221 | * `try_pod_read_unaligned` and `pod_read_unaligned` let you go from `&[u8]` to |
| 222 | `T:Pod` without worrying about alignment. |
| 223 | |
| 224 | ## 1.7.3 |
| 225 | |
| 226 | * Experimental support for the `portable_simd` language extension under the |
| 227 | `nightly_portable_simd` cargo feature. As the name implies, this is an |
| 228 | experimental crate feature and it's **not** part of the semver contract. All |
| 229 | it does is add the appropriate `Zeroable` and `Pod` impls. |
| 230 | |
| 231 | ## 1.7.2 |
| 232 | |
| 233 | * Why does this repo keep being hit with publishing problems? What did I do to |
| 234 | deserve this curse, Ferris? This doesn't ever happen with tinyvec or fermium, |
| 235 | only bytemuck. |
| 236 | |
| 237 | ## 1.7.1 |
| 238 | |
| 239 | * **Soundness Fix:** The wrap/peel methods for owned value conversion, added to |
| 240 | `TransparentWrapper` in 1.6, can cause a double-drop if used with types that |
| 241 | impl `Drop`. The fix was simply to add a `ManuallyDrop` layer around the value |
| 242 | before doing the `transmute_copy` that is used to wrap/peel. While this fix |
| 243 | could technically be backported to the 1.6 series, since 1.7 is semver |
| 244 | compatible anyway the 1.6 series has simply been yanked. |
| 245 | |
| 246 | ## 1.7 |
| 247 | |
| 248 | * In response to [Unsafe Code Guidelines Issue |
| 249 | #286](https://github.com/rust-lang/unsafe-code-guidelines/issues/286), this |
| 250 | version of Bytemuck has a ***Soundness-Required Breaking Change***. This is |
| 251 | "allowed" under Rust's backwards-compatibility guidelines, but it's still |
| 252 | annoying of course so we're trying to keep the damage minimal. |
| 253 | * **The Reason:** It turns out that pointer values should not have been `Pod`. More |
| 254 | specifically, `ptr as usize` is *not* the same operation as calling |
| 255 | `transmute::<_, usize>(ptr)`. |
| 256 | * LLVM has yet to fully sort out their story, but until they do, transmuting |
| 257 | pointers can cause miscompilations. They may fix things up in the future, |
| 258 | but we're not gonna just wait and have broken code in the mean time. |
| 259 | * **The Fix:** The breaking change is that the `Pod` impls for `*const T`, |
| 260 | `*mut T`, and `Option<NonNull<T>` are now gated behind the |
| 261 | `unsound_ptr_pod_impl` feature, which is off by default. |
| 262 | * You are *strongly discouraged* from using this feature, but if a dependency |
| 263 | of yours doesn't work when you upgrade to 1.7 because it relied on pointer |
| 264 | casting, then you might wish to temporarily enable the feature just to get |
| 265 | that dependency to build. Enabled features are global across all users of a |
| 266 | given semver compatible version, so if you enable the feature in your own |
| 267 | crate, your dependency will also end up getting the feature too, and then |
| 268 | it'll be able to compile. |
| 269 | * Please move away from using this feature as soon as you can. Consider it to |
| 270 | *already* be deprecated. |
| 271 | * [PR 65](https://github.com/Lokathor/bytemuck/pull/65) |
| 272 | |
| 273 | ## 1.6.3 |
| 274 | |
| 275 | * Small goof with an errant `;`, so [PR 69](https://github.com/Lokathor/bytemuck/pull/69) |
| 276 | *actually* got things working on SPIR-V. |
| 277 | |
| 278 | ## 1.6.2 |
| 279 | |
| 280 | cargo upload goof! ignore this one. |
| 281 | |
| 282 | ## 1.6.1 |
| 283 | |
| 284 | * [DJMcNab](https://github.com/DJMcNab) did a fix so that the crate can build for SPIR-V |
| 285 | [PR 67](https://github.com/Lokathor/bytemuck/pull/67) |
| 286 | |
| 287 | ## 1.6 |
| 288 | |
| 289 | * The `TransparentWrapper` trait now has more methods. More ways to wrap, and |
| 290 | now you can "peel" too! Note that we don't call it "unwrap" because that name |
| 291 | is too strongly associated with the Option/Result methods. |
| 292 | Thanks to [LU15W1R7H](https://github.com/LU15W1R7H) for doing |
| 293 | [PR 58](https://github.com/Lokathor/bytemuck/pull/58) |
| 294 | * Min Const Generics! Now there's Pod and Zeroable for arrays of any size when |
| 295 | you turn on the `min_const_generics` crate feature. |
| 296 | [zakarumych](https://github.com/zakarumych) got the work started in |
| 297 | [PR 59](https://github.com/Lokathor/bytemuck/pull/59), |
| 298 | and [chorman0773](https://github.com/chorman0773) finished off the task in |
| 299 | [PR 63](https://github.com/Lokathor/bytemuck/pull/63) |
| 300 | |
| 301 | ## 1.5.1 |
| 302 | |
| 303 | * Fix `bytes_of` failing on zero sized types. |
| 304 | [PR 53](https://github.com/Lokathor/bytemuck/pull/53) |
| 305 | |
| 306 | ## 1.5 |
| 307 | |
| 308 | * Added `pod_collect_to_vec`, which will gather a slice into a vec, |
| 309 | allowing you to change the pod type while also safely ignoring alignment. |
| 310 | [PR 50](https://github.com/Lokathor/bytemuck/pull/50) |
| 311 | |
| 312 | ## 1.4.2 |
| 313 | |
| 314 | * [Kimundi](https://github.com/Kimundi) fixed an issue that could make `try_zeroed_box` |
| 315 | stack overflow for large values at low optimization levels. |
| 316 | [PR 43](https://github.com/Lokathor/bytemuck/pull/43) |
| 317 | |
| 318 | ## 1.4.1 |
| 319 | |
| 320 | * [thomcc](https://github.com/thomcc) fixed up the CI and patched over a soundness hole in `offset_of!`. |
| 321 | [PR 38](https://github.com/Lokathor/bytemuck/pull/38) |
| 322 | |
| 323 | ## 1.4 |
| 324 | |
| 325 | * [icewind1991](https://github.com/icewind1991) has contributed the proc-macros |
| 326 | for deriving impls of `Pod`, `TransparentWrapper`, `Zeroable`!! Everyone has |
| 327 | been waiting for this one folks! It's a big deal. Just enable the `derive` |
| 328 | cargo feature and then you'll be able to derive the traits on your types. It |
| 329 | generates all the appropriate tests for you. |
| 330 | * The `zeroable_maybe_uninit` feature now adds a `Zeroable` impl to the |
| 331 | `MaybeUninit` type. This is only behind a feature flag because `MaybeUninit` |
| 332 | didn't exist back in `1.34.0` (the minimum rust version of `bytemuck`). |
| 333 | |
| 334 | ## 1.3.1 |
| 335 | |
| 336 | * The entire crate is now available under the `Apache-2.0 OR MIT` license as |
| 337 | well as the previous `Zlib` license |
| 338 | [#24](https://github.com/Lokathor/bytemuck/pull/24). |
| 339 | * [HeroicKatora](https://github.com/HeroicKatora) added the |
| 340 | `try_zeroed_slice_box` function |
| 341 | [#10](https://github.com/Lokathor/bytemuck/pull/17). `zeroed_slice_box` is |
| 342 | also available. |
| 343 | * The `offset_of!` macro now supports a 2-arg version. For types that impl |
| 344 | Default, it'll just make an instance using `default` and then call over to the |
| 345 | 3-arg version. |
| 346 | * The `PodCastError` type now supports `Hash` and `Display`. Also if you enable |
| 347 | the `extern_crate_std` feature then it will support `std::error::Error`. |
| 348 | * We now provide a `TransparentWrapper<T>` impl for `core::num::Wrapper<T>`. |
| 349 | * The error type of `try_from_bytes` and `try_from_bytes_mut` when the input |
| 350 | isn't aligned has been corrected from being `AlignmentMismatch` (intended for |
| 351 | allocation casting only) to `TargetAlignmentGreaterAndInputNotAligned`. |
| 352 | |
| 353 | ## 1.3.0 |
| 354 | |
| 355 | * Had a bug because the CI was messed up! It wasn't soundness related, because |
| 356 | it prevented the crate from building entirely if the `extern_crate_alloc` |
| 357 | feature was used. Still, this is yanked, sorry. |
| 358 | |
| 359 | ## 1.2.0 |
| 360 | |
| 361 | * [thomcc](https://github.com/thomcc) added many things: |
| 362 | * A fully sound `offset_of!` macro |
| 363 | [#10](https://github.com/Lokathor/bytemuck/pull/10) |
| 364 | * A `Contiguous` trait for when you've got enums with declared values |
| 365 | all in a row [#12](https://github.com/Lokathor/bytemuck/pull/12) |
| 366 | * A `TransparentWrapper` marker trait for when you want to more clearly |
| 367 | enable adding and removing a wrapper struct to its inner value |
| 368 | [#15](https://github.com/Lokathor/bytemuck/pull/15) |
| 369 | * Now MIRI is run on CI in every single push! |
| 370 | [#16](https://github.com/Lokathor/bytemuck/pull/16) |
| 371 | |
| 372 | ## 1.1.0 |
| 373 | |
| 374 | * [SimonSapin](https://github.com/SimonSapin) added `from_bytes`, |
| 375 | `from_bytes_mut`, `try_from_bytes`, and `try_from_bytes_mut` ([PR |
| 376 | Link](https://github.com/Lokathor/bytemuck/pull/8)) |
| 377 | |
| 378 | ## 1.0.1 |
| 379 | |
| 380 | * Changed to the [zlib](https://opensource.org/licenses/Zlib) license. |
| 381 | * Added much more proper documentation. |
| 382 | * Reduced the minimum Rust version to 1.34 |