Voultapher/self_cell

Use of addr_of_mut requires recent Rust

Closed this issue · 3 comments

I got a pull request sent for the new yank which I very much appreciate (mitsuhiko/minijinja#21). However the latest version uses addr_of_mut! which bumps up the rustc requirement to 1.51. I was previously able to target 1.42 which I need for an upstream user of this crate.

Would it be possible to restore support for 1.42 somehow?

I see some discussion here about the usage of addr_of_mut!: #21

It calls out that only two uses of addr_of_mut! are necessary and only one remains:

let owner_ptr: *mut $Owner = core::ptr::addr_of_mut!((*joined_ptr.as_ptr()).owner);
let dependent_ptr: *mut $Dependent = core::ptr::addr_of_mut!((*joined_ptr.as_ptr()).dependent);

are important, because previously they would create intermediate references to uninitialized memory.

Might be worth investigating if there are alternatives that can be used.

I suppose the fix is to wrap owner and dependent in MaybeUninit in which case the addr_of_mut shouldn't be needed.

I've just published https://github.com/Voultapher/self_cell/releases/tag/v0.10.1 I hope that works for mininjinja.