Fix deprecation warnings for atomics initialization#739
Merged
dhardy merged 1 commit intorust-random:masterfrom Feb 25, 2019
Merged
Fix deprecation warnings for atomics initialization#739dhardy merged 1 commit intorust-random:masterfrom
dhardy merged 1 commit intorust-random:masterfrom
Conversation
dhardy
reviewed
Feb 21, 2019
rand_jitter/src/lib.rs
Outdated
| use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering}; | ||
| use std::sync::atomic::{AtomicUsize, Ordering}; | ||
| #[cfg(feature = "std")] | ||
| #[allow(deprecated)] // Since Rust 1.34, `Atomic*::new` is preferred. |
Member
There was a problem hiding this comment.
You've explained the deprecation but not the reason to go against it: better to say "reqiured for compatibility with Rust 1.22" (or < 1.xx)?
Member
There was a problem hiding this comment.
Apparently this became possible in 1.24: https://github.com/rust-lang/rust/blob/stable/RELEASES.md#stabilized-apis-9
Contributor
Author
There was a problem hiding this comment.
I changed it to "Required for compatibility with Rust < 1.24".
Since Rust 1.34, `ATOMIC_*_INIT` is deprecated in favor of `Atomic*::new`. However, this requires the latter to be `const`, which is not the case for older Rust versions. Alternatively, we could detect the Rust version by introducing build scripts to the crates lacking them. However, this increases build time for a very minor benefit, so the deprecation warnings are ignored instead. Fixes rust-random#736.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since Rust 1.34,
ATOMIC_*_INITis deprecated in favor ofAtomic*::new. However, this requires the latter to beconst, whichis not the case for older Rust versions.
Alternatively, we could detect the Rust version by introducing build
scripts to the crates lacking them. However, this increases build time
for a very minor benefit, so the deprecation warnings are ignored
instead.
Fixes #736.