-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
Address lint ambiguous_wide_pointer_comparisons #478
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a MSRV bump, since core::ptr::addr_eq
was added in Rust 1.76.0, and cordyceps
currently claims a minimum Rust version of 1.61.0.
I'm not super fussed about taking the MSRV bump, but if we do, it would be good to make sure to change the Cargo.toml rust-version
field as part of this commit, as well.
Alternatively, we could perform the same address-without-metadata comparison by writing
head.as_ptr() as *const () == tail.as_ptr() as *const ()
and
splice_start.as_ptr() as *const () == splice_end.as_ptr() as *const ()
which is basically what ptr::addr_eq
does internally, but is permitted on older Rust versions. If we go that route, we can avoid the MSRV bump, but it might be worth adding a comment that the as *const ()
casts are to ignore the wide pointer metadata, so that a future reader doesn't change them back...
Ugh, it looks like some of the maitake tests are not feature flagged correctly: https://github.com/hawkw/mycelium/actions/runs/9821097757/job/27116399920?pr=478 I can fix that separately... |
…pointer_comparisons
Updated MSRV of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some smallish nits. I'd like to merge this, though!
@@ -17,7 +17,7 @@ categories = [ | |||
"concurrency" | |||
] | |||
edition = "2021" | |||
rust-version = "1.61.0" | |||
rust-version = "1.76.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't actually think we need to do the MSRV bump for maitake-sync
. Since the cordyceps
changes will be released in a semver-compatible version, and maitake-sync
's minimum cordyceps
version isn't changing, users of maitake-sync
can continue using the current cordyceps version rather than picking up the one with the new MSRV --- either by checking in a lockfile, or by explicitly pinning the cordyceps
version in their Cargo.toml.
IMHO, we would only need to change maitake-sync
's MSRV if we were changing the dependency spec for cordyceps
to not permit versions that compile on 1.61.0.
@@ -494,7 +494,7 @@ impl<T: Linked<Links<T>> + ?Sized> List<T> { | |||
let tail_links = unsafe { T::links(tail) }; | |||
let head_links = unsafe { head_links.as_ref() }; | |||
let tail_links = unsafe { tail_links.as_ref() }; | |||
if head == tail { | |||
if core::ptr::addr_eq(head.as_ptr(), tail.as_ptr()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, take it or leave it: core::ptr
is already imported in this file:
mycelium/cordyceps/src/list.rs
Line 13 in ed9e49b
ptr::{self, NonNull}, |
so we could drop the core
prefix:
if core::ptr::addr_eq(head.as_ptr(), tail.as_ptr()) { | |
if ptr::addr_eq(head.as_ptr(), tail.as_ptr()) { |
@@ -963,7 +963,7 @@ impl<T: Linked<Links<T>> + ?Sized> List<T> { | |||
let start_links = T::links(splice_start).as_mut(); | |||
let end_links = T::links(splice_end).as_mut(); | |||
debug_assert!( | |||
splice_start == splice_end | |||
core::ptr::addr_eq(splice_start.as_ptr(), splice_end.as_ptr()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similarly, we could write:
core::ptr::addr_eq(splice_start.as_ptr(), splice_end.as_ptr()) | |
ptr::addr_eq(splice_start.as_ptr(), splice_end.as_ptr()) |
@@ -17,7 +17,7 @@ categories = [ | |||
"async", | |||
] | |||
edition = "2021" | |||
rust-version = "1.61.0" | |||
rust-version = "1.76.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again, i think the MSRV bump isn't strictly necessary unless we are also changing the cordyceps dep
@@ -3,7 +3,7 @@ name = "mycelium-util" | |||
version = "0.1.0" | |||
authors = ["Eliza Weisman <eliza@elizas.website>"] | |||
edition = "2021" | |||
rust-version = "1.61.0" | |||
rust-version = "1.76.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and again, i don't think this is really necessary...although it's also fine since this isn't a published crate.
Noticed this warning: