-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add old rustc support as feature #33
Conversation
This provides polyfilled support for addr_of_mut for older rustc versions. This required splitting the tests, but has the benefit of sliming down the main test dependencies.
a8c3c62
to
e4ae3dd
Compare
Also adds old_rust configuration
e4ae3dd
to
28fbf48
Compare
@mitsuhiko please let me know if this addresses your issue. |
@Voultapher would you be open to the idea of adding |
Good point, this transitively affects library users, who can't control what their users compile with. I'll look at a solution. The most straightforward thing would be to use rustversion with 3 versions of the macro. |
I believe given how #[doc(hidden)]
#[macro_export]
#[cfg(feature = "old_rust")]
#[rustversion::before(1.51)]
macro_rules! _addr_of_mut {
($expr:expr) => {
&mut $expr as *mut _
};
}
#[doc(hidden)]
#[macro_export]
#[cfg(feature = "old_rust")]
#[rustversion::since(1.51)]
macro_rules! _addr_of_mut {
($expr:expr) => {
core::ptr::addr_of_mut!($expr)
};
}
#[doc(hidden)]
#[macro_export]
#[cfg(not(feature = "old_rust"))]
macro_rules! _addr_of_mut {
($expr:expr) => {
core::ptr::addr_of_mut!($expr)
};
} |
I just noticed doesn't |
Referencing https://doc.rust-lang.org/core/ptr/macro.addr_of_mut.html
|
Looking at prior art, it's a mixed bag https://grep.app/search?q=addr_of_mut%21
|
I've pushed a version that implements the current scheme without MaybeUninit, if we conclude that's needed I will update. Note @mitsuhiko your suggested approach didn't work because 'procedural macros cannot expand to macro definitions' at least for rustc 1.36. |
That looks good! |
@mitsuhiko I've posted the question here https://users.rust-lang.org/t/does-addr-of-mut-require-maybeuninit/66754 and hope I can clarify this soon, and then close this and release a new version. Thanks for the patience. |
fixes #31
This provides polyfilled support for addr_of_mut for older rustc versions. This required splitting the tests, but has the benefit of sliming down the main test dependencies.
This also documents the version requirements and tests them in the CI.