Skip to content

Fix deprecation warnings for atomics initialization#739

Merged
dhardy merged 1 commit intorust-random:masterfrom
vks:fix-deprec
Feb 25, 2019
Merged

Fix deprecation warnings for atomics initialization#739
dhardy merged 1 commit intorust-random:masterfrom
vks:fix-deprec

Conversation

@vks
Copy link
Copy Markdown
Contributor

@vks vks commented Feb 21, 2019

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 #736.

@vks vks requested a review from dhardy February 21, 2019 13:45
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.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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)?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.
@dhardy dhardy merged commit 270682e into rust-random:master Feb 25, 2019
@vks vks deleted the fix-deprec branch February 25, 2019 13:08
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.

2 participants