Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of addr_of_mut requires recent Rust #30

Closed
mitsuhiko opened this issue Oct 26, 2021 · 3 comments
Closed

Use of addr_of_mut requires recent Rust #30

mitsuhiko opened this issue Oct 26, 2021 · 3 comments

Comments

@mitsuhiko
Copy link

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?

@mitsuhiko
Copy link
Author

mitsuhiko commented Oct 26, 2021

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.

@mitsuhiko
Copy link
Author

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

@mitsuhiko mitsuhiko changed the title Use of addr_of_mut requires very new Rust Use of addr_of_mut requires recent Rust Oct 26, 2021
@Voultapher
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants