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

Fix Rust Beta warning about deprecated AtomicBool method. #3804

Merged
merged 1 commit into from
Jan 11, 2021

Conversation

rfk
Copy link
Contributor

@rfk rfk commented Jan 11, 2021

When compiling on Rust Beta, we're generating a warning about:

warning: use of deprecated associated function
std::sync::atomic::AtomicBool::compare_and_swap:
Use compare_exchange or compare_exchange_weak instead

This commit does as advised in the hope of eliminating the warning,
which is currently failing some scheduled CI jobs.

When compiling on Rust Beta, we're generating a warning about:

  warning: use of deprecated associated function
  `std::sync::atomic::AtomicBool::compare_and_swap`:
  Use `compare_exchange` or `compare_exchange_weak` instead

This commit does as advised in the hope of eliminating the warning.
@rfk rfk force-pushed the rust-beta-warning-compare-exchange branch from 7ab94dc to 880221f Compare January 11, 2021 00:47
@rfk rfk requested a review from a team January 11, 2021 00:47
@codecov-io
Copy link

Codecov Report

Merging #3804 (880221f) into main (1d739d7) will increase coverage by 0.00%.
The diff coverage is 0.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3804   +/-   ##
=======================================
  Coverage   18.67%   18.67%           
=======================================
  Files         229      229           
  Lines       27290    27289    -1     
=======================================
  Hits         5096     5096           
+ Misses      22194    22193    -1     
Impacted Files Coverage Δ
components/places/src/api/places_api.rs 0.00% <0.00%> (ø)
components/viaduct/src/backend/ffi.rs 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1d739d7...880221f. Read the comment docs.

Copy link
Member

@mhammond mhammond left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks correct to me, but I admit to not understanding why compare_exchange is documented as returning current but also saying it only succeeds when current == the current value - surely the return value can be implied in all cases?

I'm also mildly surprised https://doc.rust-lang.org/std/sync/atomic/struct.AtomicBool.html doesn't note that compare_and_swap is deprecated!

Regardless, neither of those points are strictly relevant to this patch.

@rfk
Copy link
Contributor Author

rfk commented Jan 11, 2021

I admit to not understanding why compare_exchange is documented as returning current but also saying it only succeeds
when current == the current value - surely the return value can be implied in all cases?

Yeah, I struggle a bit here wondering if I was missing something, but found rust-lang/rust#31767 (comment) which suggests there isn't anything deep going on, it's just returning the info because it happens to be available.

@rfk rfk merged commit d490503 into main Jan 11, 2021
@rfk rfk deleted the rust-beta-warning-compare-exchange branch January 11, 2021 04:01
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 this pull request may close these issues.

3 participants