-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
refactor: replace once_cell Lazy with LazyLock #9844
Conversation
README.md
Outdated
@@ -87,7 +87,7 @@ When updating this, also update: | |||
- .github/workflows/lint.yml | |||
--> | |||
|
|||
The Minimum Supported Rust Version (MSRV) of this project is [1.79.0](https://blog.rust-lang.org/2024/06/13/Rust-1.79.0.html). | |||
The Minimum Supported Rust Version (MSRV) of this project is [1.80.0](https://blog.rust-lang.org/2024/06/13/Rust-1.80.0.html). |
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.
you need to update the blogpost link too.
@mattsse should we remove this link?
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.
now that's updated, maybe next time :D
@harsh-ps-2003 please use nightly toolchain to format: 'cargo +nightly fmt' |
README.md
Outdated
@@ -87,7 +87,7 @@ When updating this, also update: | |||
- .github/workflows/lint.yml | |||
--> | |||
|
|||
The Minimum Supported Rust Version (MSRV) of this project is [1.79.0](https://blog.rust-lang.org/2024/06/13/Rust-1.79.0.html). | |||
The Minimum Supported Rust Version (MSRV) of this project is [1.80.0](https://blog.rust-lang.org/2024/06/13/Rust-1.80.0.html). |
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.
now that's updated, maybe next time :D
crates/chainspec/src/spec.rs
Outdated
@@ -22,6 +21,7 @@ use reth_primitives_traits::{ | |||
use reth_trie_common::root::state_root_ref_unhashed; | |||
#[cfg(feature = "std")] | |||
use std::sync::Arc; | |||
use std::sync::LazyLock; |
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 file has std and no std specific elements so I think you need to do something like (should be true for other files with same cfg config)
#[cfg(feature = "std")]
use std::sync::LazyLock;
#[cfg(not(feature = "std"))]
use alloc::sync::LazyLock;
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 was troubled beacuase I thought I will have to manually implement the no-std version of std::sync::LazyLock
somehow, so as to not use alloc crate at all! Thank you!
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.
LazyLock is only available in std. It does not exist in alloc, as it depends on the OS and other system-specific stuff that are only available in std.
You must keep once_cell in the no_std case.
I would also recommend you run the command locally to see the failures instead of pushing a million commits one at a time and waiting for someone to run CI on it
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.
needs another cargo +nightly fmt
, remember to update your toolchain beforehand:)
The PR should be passing now! Thanks for the patience! |
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.
lgtm, ptal @mattsse
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.
ah, we still need to use once_cell on no_std as mentioned above. otherwise this is good to merge @harsh-ps-2003
I must keep once_cell in the no_std case as LazyLock is not supporting it! Can we remove the |
lets keep once cell for that crate then |
Yes, but you are not actually using once_cell on no_std. You need to switch between once_cell and std's LazyLock based on whether std is available or not. See the ci failure:) |
Now! It should be finally done! |
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.
cool
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.
pending @onbjerg
Removing the use of once_cell crate as we have LazyLock from rust 1.80 release
Fixes #9799