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

Fix build for wasm32/64-unknown-unknown without std #1528

Merged
merged 4 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions maybe_rayon/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#![cfg_attr(not(std), no_std)]

#[cfg(not(feature = "parallel"))]
use core::{
iter::{FlatMap, IntoIterator, Iterator},
slice::{Chunks, ChunksExact, ChunksExactMut, ChunksMut},
};
extern crate alloc;
Copy link
Collaborator

Choose a reason for hiding this comment

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

We only need alloc conditionally imported here

Suggested change
extern crate alloc;
#[cfg(not(feature = "parallel"))]
extern crate alloc;


#[cfg(feature = "parallel")]
pub use rayon::{
Expand All @@ -20,6 +19,14 @@ use rayon::{
ChunksMut as ParChunksMut, ParallelSlice, ParallelSliceMut,
},
};
#[cfg(not(feature = "parallel"))]
use {
alloc::vec::Vec,
core::{
iter::{FlatMap, IntoIterator, Iterator},
slice::{self, Chunks, ChunksExact, ChunksExactMut, ChunksMut},
},
};

pub trait MaybeParIter<'data> {
#[cfg(feature = "parallel")]
Expand Down Expand Up @@ -53,7 +60,7 @@ where
#[cfg(not(feature = "parallel"))]
impl<'data, T: 'data> MaybeParIter<'data> for Vec<T> {
type Item = &'data T;
type Iter = std::slice::Iter<'data, T>;
type Iter = slice::Iter<'data, T>;

fn par_iter(&'data self) -> Self::Iter {
self.iter()
Expand All @@ -63,7 +70,7 @@ impl<'data, T: 'data> MaybeParIter<'data> for Vec<T> {
#[cfg(not(feature = "parallel"))]
impl<'data, T: 'data> MaybeParIter<'data> for [T] {
type Item = &'data T;
type Iter = std::slice::Iter<'data, T>;
type Iter = slice::Iter<'data, T>;

fn par_iter(&'data self) -> Self::Iter {
self.iter()
Expand Down Expand Up @@ -102,7 +109,7 @@ where
#[cfg(not(feature = "parallel"))]
impl<'data, T: 'data> MaybeParIterMut<'data> for Vec<T> {
type Item = &'data mut T;
type Iter = std::slice::IterMut<'data, T>;
type Iter = slice::IterMut<'data, T>;

fn par_iter_mut(&'data mut self) -> Self::Iter {
self.iter_mut()
Expand All @@ -112,7 +119,7 @@ impl<'data, T: 'data> MaybeParIterMut<'data> for Vec<T> {
#[cfg(not(feature = "parallel"))]
impl<'data, T: 'data> MaybeParIterMut<'data> for [T] {
type Item = &'data mut T;
type Iter = std::slice::IterMut<'data, T>;
type Iter = slice::IterMut<'data, T>;

fn par_iter_mut(&'data mut self) -> Self::Iter {
self.iter_mut()
Expand Down
2 changes: 1 addition & 1 deletion plonky2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ plonky2_util = { path = "../util", default-features = false }
rand = { version = "0.8.4", default-features = false }
rand_chacha = { version = "0.3.1", optional = true, default-features = false }
serde = { version = "1.0", default-features = false, features = ["derive", "rc"] }
serde_json = "1.0"
static_assertions = { version = "1.1.0", default-features = false }
unroll = { version = "0.1.5", default-features = false }
web-time = { version = "1.0.0", optional = true }
Expand All @@ -46,6 +45,7 @@ num_cpus = { version = "1.14.0", default-features = false }
rand = { version = "0.8.4", default-features = false, features = ["getrandom"] }
rand_chacha = { version = "0.3.1", default-features = false }
serde_cbor = { version = "0.11.2" }
serde_json = { version = "1.0" }
structopt = { version = "0.3.26", default-features = false }
tynm = { version = "0.1.6", default-features = false }

Expand Down