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

feat: support no_std #250

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

stevencartavia
Copy link

should close #248

Copy link
Contributor

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

cool,
the hardest part is already done I think, now we just need to deal with some features

Cargo.toml Outdated

# serde
serde = { version = "1", optional = true, features = ["derive"] }
serde_json = "1.0"
serde_json = { version = "1.0", optional = true }
Copy link
Contributor

Choose a reason for hiding this comment

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

this can use the alloc feature

Cargo.toml Outdated
Comment on lines 56 to 57
std = ["anstyle", "colorchoice", "serde_json"]
no_std = []
Copy link
Contributor

Choose a reason for hiding this comment

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

here we should also propagate std to everything

src/lib.rs Outdated
Comment on lines 20 to 21
#[cfg(feature = "std")]
pub use colorchoice::ColorChoice;
Copy link
Contributor

Choose a reason for hiding this comment

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

move below mods again

Comment on lines 326 to 327
#[cfg(feature = "std")]
#[error("error deserializing config: {0}")]
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this type works in no-std as long as the serde-json alloc feature is enabled

Comment on lines 10 to 15
#[cfg(feature = "std")]
use anstyle::{AnsiColor, Color, Style};
#[cfg(feature = "std")]
use colorchoice::ColorChoice;
use std::{
collections::HashMap,
io::{self, Write},
};
#[cfg(feature = "std")]
use std::io::{self, Write};
Copy link
Contributor

Choose a reason for hiding this comment

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

here we should rather feature gate the code that depends on this I assume

Copy link
Contributor

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

few more nits

Cargo.toml Outdated
@@ -33,16 +33,16 @@ clippy.lint_groups_priority = "allow"
alloy-rpc-types-eth = "0.9"
alloy-rpc-types-trace = "0.9"
alloy-sol-types = "0.8"
alloy-primitives = { version = "0.8", features = ["map"] }
alloy-primitives = { version = "0.8", features = ["map-hashbrown"] }
Copy link
Contributor

Choose a reason for hiding this comment

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

map should be sufficient here

Cargo.toml Outdated
@@ -52,5 +52,8 @@ boa_gc = { version = "0.20", optional = true }
snapbox = { version = "0.6", features = ["term-svg"] }

[features]
default = ["std"]
std = ["alloy-primitives/std", "anstyle/std", "serde/std", "serde_json/std", "revm/std", "thiserror/std"]
no_std = []
Copy link
Contributor

Choose a reason for hiding this comment

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

this isn't required because this is the same as no-default-features

Suggested change
no_std = []

src/lib.rs Outdated
@@ -4,7 +4,7 @@
//!
//! - `js-tracer`: Enables a JavaScript tracer implementation. This pulls in extra dependencies
//! (such as `boa`, `tokio` and `serde_json`).

#![cfg_attr(not(feature = "std"), no_std)]
Copy link
Contributor

Choose a reason for hiding this comment

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

move to L17

@stevencartavia stevencartavia marked this pull request as ready for review January 4, 2025 21:44
@stevencartavia stevencartavia changed the title (wip)feat: support no_std feat: support no_std Jan 4, 2025
Copy link
Member

@DaniPopes DaniPopes Jan 4, 2025

Choose a reason for hiding this comment

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

Please leave JS unchanged, it can never support no_std. It may look like it works because tests pass but that's because you're running on a target that has std, and it is used by dependencies regardless of the no_std status of this crate.

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.

Support no-std
3 participants