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

Add std flag #1266

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
12 changes: 12 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ features = ["curr"]
# git = "https://github.com/stellar/rs-stellar-xdr"
# rev = "d0138770652a615e3cd99447f2f2727658c17450"

#[patch."https://github.com/stellar/rs-soroban-env"]
#soroban-env-common = { path = "../rs-soroban-env/soroban-env-common" }
#soroban-env-guest = { path = "../rs-soroban-env/soroban-env-guest" }
#soroban-env-host = { path = "../rs-soroban-env/soroban-env-host/" }
[patch."https://github.com/stellar/rs-soroban-env"]
soroban-env-common = { path = "../rs-soroban-env/soroban-env-common" }
soroban-env-guest = { path = "../rs-soroban-env/soroban-env-guest" }
soroban-env-host = { path = "../rs-soroban-env/soroban-env-host/" }
#[patch."https://github.com/stellar/rs-stellar-xdr"]
#stellar-xdr = { path = "../rs-stellar-xdr/" }

Expand Down
1 change: 1 addition & 0 deletions soroban-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ proptest = "1.2.0"
proptest-arbitrary-interop = "0.1.0"

[features]
std = []
alloc = []
testutils = ["soroban-sdk-macros/testutils", "soroban-env-host/testutils", "dep:ed25519-dalek", "dep:arbitrary", "dep:ctor"]
docs = []
Expand Down
2 changes: 1 addition & 1 deletion soroban-sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
compile_error!("'testutils' feature is not supported on 'wasm' target");

// When used in a no_std contract, provide a panic handler as one is required.
#[cfg(all(not(feature = "alloc"), target_family = "wasm"))]
#[cfg(all(not(feature = "alloc"), not(feature = "std"), target_family = "wasm"))]
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 be breaking for someone, can't it? No-one would have the new feature enabled, so handle_panic may disappear suddenly. Wouldn't it be safer to add a feature that disables handle_panic on-demand?

#[panic_handler]
fn handle_panic(_: &core::panic::PanicInfo) -> ! {
core::arch::wasm32::unreachable()
Expand Down
14 changes: 7 additions & 7 deletions soroban-sdk/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ use super::{
ConversionError, Env, TryFromVal, TryIntoVal, Val,
};

#[cfg(not(target_family = "wasm"))]
//#[cfg(not(target_family = "wasm"))]
use super::env::SymbolStr;

#[cfg(not(target_family = "wasm"))]
//#[cfg(not(target_family = "wasm"))]
use crate::env::internal::xdr::{ScSymbol, ScVal};
use crate::{
env::MaybeEnv,
Expand Down Expand Up @@ -135,7 +135,7 @@ impl TryFromVal<Env, &str> for Symbol {
}
}

#[cfg(not(target_family = "wasm"))]
//#[cfg(not(target_family = "wasm"))]
impl TryFrom<&Symbol> for ScVal {
type Error = ConversionError;
fn try_from(v: &Symbol) -> Result<Self, ConversionError> {
Expand All @@ -148,23 +148,23 @@ impl TryFrom<&Symbol> for ScVal {
}
}

#[cfg(not(target_family = "wasm"))]
//#[cfg(not(target_family = "wasm"))]
impl TryFrom<Symbol> for ScVal {
type Error = ConversionError;
fn try_from(v: Symbol) -> Result<Self, ConversionError> {
(&v).try_into()
}
}

#[cfg(not(target_family = "wasm"))]
//#[cfg(not(target_family = "wasm"))]
impl TryFromVal<Env, Symbol> for ScVal {
type Error = ConversionError;
fn try_from_val(_e: &Env, v: &Symbol) -> Result<Self, ConversionError> {
v.try_into()
}
}

#[cfg(not(target_family = "wasm"))]
//#[cfg(not(target_family = "wasm"))]
impl TryFromVal<Env, ScVal> for Symbol {
type Error = ConversionError;
fn try_from_val(env: &Env, val: &ScVal) -> Result<Self, Self::Error> {
Expand All @@ -174,7 +174,7 @@ impl TryFromVal<Env, ScVal> for Symbol {
}
}

#[cfg(not(target_family = "wasm"))]
//#[cfg(not(target_family = "wasm"))]
impl TryFromVal<Env, ScSymbol> for Symbol {
type Error = ConversionError;
fn try_from_val(env: &Env, val: &ScSymbol) -> Result<Self, Self::Error> {
Expand Down
Loading