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

ATOMIC_USIZE_INIT deprecated in rust 1.34 #320

Closed
dekellum opened this issue Feb 2, 2019 · 5 comments · Fixed by #321
Closed

ATOMIC_USIZE_INIT deprecated in rust 1.34 #320

dekellum opened this issue Feb 2, 2019 · 5 comments · Fixed by #321

Comments

@dekellum
Copy link
Contributor

dekellum commented Feb 2, 2019

On to the next build warning...

https://travis-ci.com/rust-lang-nursery/log/jobs/174845625#L448

warning: use of deprecated item 'core::sync::atomic::ATOMIC_USIZE_INIT': the new function is now preferred

AtomicUsize::new became usable as a const fn in 1.24, as best I can tell, so there are two options to fix this:

(a) Increase log's MSRV to 1.24 and use AtomicUsize::new

(b) Introduce a build script with version_check (build dep) and cfg switch to AtomicUsize::new for >= 1.24

Or, I suppose: (c) ignore it. Thoughts?

@sfackler
Copy link
Member

sfackler commented Feb 2, 2019

#[allow(deprecated)]

@dekellum
Copy link
Contributor Author

dekellum commented Feb 2, 2019

Ok lets call that option (d). With all due respect, I am least pleased with (d) since it hides the upgrade nudge, until it breaks. But that said, its also rather lame that all of (b) is required to cfg use the newer const fn with >= 1.24.

@sfackler
Copy link
Member

sfackler commented Feb 2, 2019

until it breaks

ATOMIC_USIZE_INIT will never break.

But that said, its also rather lame that all of (b) is required to cfg use the newer const fn with >= 1.24.

How will a user of this library be better off if it uses the const constructor for this value?

@dekellum
Copy link
Contributor Author

dekellum commented Feb 2, 2019

I presume you prefer (d) to either (a) or (b) then, ok.

Seems like the your last question would be better made to whomever did the deprecation in std in the first place. As a user I have to assume it was deprecated for some good reason and will therefore be removed in a future release.

But rust-lang/rfcs#2523 would have had to be stabilized by rust 1.16 to make (b) trivially simple, and I guess I can understand your position in terms of risk-benefit.

@sfackler
Copy link
Member

sfackler commented Feb 2, 2019

Deprecated stable APIs will not be removed from the standard library.

dekellum added a commit to dekellum/log that referenced this issue Feb 3, 2019
ATOMIC_USIZE_INIT was deprecated in rust 1.34. Silence the deprecation
warning until our MSRV >= 1.24, where we can use the replacement const
fn `AtomicUsize::new`

github: fixes rust-lang#320
EFanZh pushed a commit to EFanZh/log that referenced this issue Jul 23, 2023
* Print `rerun-if-changed=build.rs` in `build.rs`
* Optimize compile-time: Extract `bin/src/lib.rs`
   
   so that `cargo-binstall (lib)` can be compiled in parallel to other
   deps.
* Refactor: Extract new mod `bin/src/bin_utils.rs`
* Extract new fn `MainExit::new`
* Refactor: Extract new fn `run_tokio_main`
* Handle `Runtime::new` err gracefully in `run_tokio_main`
   instead of `panic!`ing, return the error as `BinstallError`
* Avoid mixing `eprintln` and `error` in `MainExit::report`
* Set profile for `build-override`
   to speedup building of `build.rs` and proc macros.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
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 a pull request may close this issue.

2 participants