chore(redux): prefer core/alloc over std#2208
Open
0xDevNinja wants to merge 2 commits into
Open
Conversation
Move imports in the `redux` library off `std::` where `core::` or `alloc::` provide the same item. Adds `extern crate alloc;` to make `alloc::collections::VecDeque` and `alloc::borrow::Cow` reachable. Kept on `std::` because no `core`/`alloc` equivalent exists: - `std::sync::OnceLock` (needs platform sync primitives) - `std::time::Instant`, `std::time::SystemTime` - `thread_local!` macro No behaviour change. `cargo check`, `cargo clippy --deny=warnings`, `cargo test -p redux`, and `cargo check --workspace` are all green. Refs o1-labs#1260.
5 tasks
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.
Description
First incremental step toward #1260. Scope is the reusable
libs/reduxcrate only — swapstd::Xforcore::X/alloc::Xwherever an equivalent exists, and addextern crate alloc;at the crate root.Changes (8 files, +20/-17):
lib.rs— addextern crate alloc;dispatcher.rs—std::collections::VecDeque→alloc::collections::VecDeque;std::marker::PhantomData→core::marker::PhantomDatacallback.rs—std::borrow::Cow→alloc::borrow::Cow;std::any::{Any,type_name}→core::any::{Any,type_name}(incl. inside the public_callback!macro body)timestamp.rs,action/action_id.rs,action/action_with_meta.rs,action/action_meta.rs—std::time::Duration→core::time::Duration;impl std::ops::Add→impl core::ops::Add(3 impls)instant.rs—std::{cell::RefCell, cmp, ops, time::Duration}→core::{...};std::fmt::{Debug,Formatter,Result}→core::fmt::{...}Left on
std::(nocore/allocequivalent):std::sync::OnceLockinstore.rs— needs platform sync primitivesstd::time::Instant,std::time::SystemTime— not incore; existingwasm-timershim already coverscfg(target_arch = "wasm32")thread_local!macro ininstant.rs— std-only macroNo behaviour change.
Related Issue(s)
Refs #1260.
Intentionally not a
Closes— #1260 spans the whole workspace. This PR lands the leaf library first to validate the direction; further crates (crates/core,crates/p2p,crates/node,crates/ledger, …) follow in separate PRs.Type of Change
Testing
Local, branched off fresh
upstream/develop:All green.
cargo check --workspaceproduces only pre-existing warnings incrates/nodeandcrates/p2punrelated to this diff.Changelog Entry
Changelog Summary: Changed the
reduxlibrary to prefercore::andalloc::paths overstd::where possible (refs #1260).