Skip to content

Commit d912030

Browse files
authored
Merge pull request #1976 from CosmWasm/fail-without-std
Throw compiler error if std feature is not enabled
2 parents 35c5470 + fb01967 commit d912030

File tree

8 files changed

+19
-12
lines changed

8 files changed

+19
-12
lines changed

.circleci/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,15 +344,15 @@ jobs:
344344
- run:
345345
name: Build library for native target (no features)
346346
working_directory: ~/project/packages/std
347-
command: cargo build --locked --no-default-features
347+
command: cargo build --locked --no-default-features --features std
348348
- run:
349349
name: Build library for wasm target (no features)
350350
working_directory: ~/project/packages/std
351-
command: cargo wasm --locked --no-default-features
351+
command: cargo wasm --locked --no-default-features --features std
352352
- run:
353353
name: Run unit tests (no features)
354354
working_directory: ~/project/packages/std
355-
command: cargo test --locked --no-default-features
355+
command: cargo test --locked --no-default-features --features std
356356
- run:
357357
name: Build library for native target (all features)
358358
working_directory: ~/project/packages/std

contracts/cyberpunk/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ cranelift = ["cosmwasm-vm/cranelift"]
2828

2929
[dependencies]
3030
cosmwasm-schema = { path = "../../packages/schema" }
31-
cosmwasm-std = { path = "../../packages/std", default-features = false, features = ["abort", "cosmwasm_1_3"] }
31+
cosmwasm-std = { path = "../../packages/std", default-features = false, features = ["std", "abort", "cosmwasm_1_3"] }
3232
rust-argon2 = "0.8"
3333
thiserror = "1.0.26"
3434

contracts/hackatom/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ cranelift = ["cosmwasm-vm/cranelift"]
3030

3131
[dependencies]
3232
cosmwasm-schema = { path = "../../packages/schema" }
33-
cosmwasm-std = { path = "../../packages/std", default-features = false, features = ["abort"] }
33+
cosmwasm-std = { path = "../../packages/std", default-features = false, features = ["std", "abort"] }
3434
schemars = "0.8.3"
3535
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
3636
sha2 = "0.10"

contracts/reflect/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ cranelift = ["cosmwasm-vm/cranelift"]
3131

3232
[dependencies]
3333
cosmwasm-schema = { path = "../../packages/schema" }
34-
cosmwasm-std = { path = "../../packages/std", default-features = false, features = ["staking", "stargate", "cosmwasm_1_4"] }
34+
cosmwasm-std = { path = "../../packages/std", default-features = false, features = ["std", "staking", "stargate", "cosmwasm_1_4"] }
3535
schemars = "0.8.3"
3636
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
3737
thiserror = "1.0.26"

contracts/staking/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ cranelift = ["cosmwasm-vm/cranelift"]
3030

3131
[dependencies]
3232
cosmwasm-schema = { path = "../../packages/schema" }
33-
cosmwasm-std = { path = "../../packages/std", default-features = false, features = ["staking"] }
33+
cosmwasm-std = { path = "../../packages/std", default-features = false, features = ["std", "staking"] }
3434
schemars = "0.8.3"
3535
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
3636
snafu = "0.6.6"

devtools/check_workspace.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ cargo fmt
99
cd packages/std
1010
# default, min, all
1111
cargo check
12-
cargo check --no-default-features
13-
cargo check --features abort,iterator,staking,stargate,cosmwasm_1_2
12+
cargo check --no-default-features --features std
13+
cargo check --features std,abort,iterator,staking,stargate,cosmwasm_1_2
1414
cargo wasm-debug
15-
cargo wasm-debug --features iterator,staking,stargate
16-
cargo clippy --all-targets --features iterator,staking,stargate -- -D warnings
15+
cargo wasm-debug --features std,iterator,staking,stargate
16+
cargo clippy --all-targets --features std,iterator,staking,stargate -- -D warnings
1717
)
1818
(cd packages/schema && cargo build && cargo clippy --all-targets -- -D warnings)
1919
(cd packages/schema-derive && cargo build && cargo clippy --all-targets -- -D warnings)

packages/std/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
extern crate alloc;
22

3+
#[cfg(not(feature = "std"))]
4+
core::compile_error!(
5+
r#"Please enable `cosmwasm-std`'s `std` feature, as we might move existing functionality to that feature in the future.
6+
Builds without the std feature are currently not expected to work. If you need no_std support see #1484.
7+
"#
8+
);
9+
310
// Exposed on all platforms
411

512
mod addresses;

packages/vm/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ clru = "0.6.1"
3131
crc32fast = "1.3.2"
3232
bech32 = "0.9.1"
3333
# Uses the path when built locally; uses the given version from crates.io when published
34-
cosmwasm-std = { path = "../std", version = "1.5.0", default-features = false }
34+
cosmwasm-std = { path = "../std", version = "1.5.0", default-features = false, features = ["std"] }
3535
cosmwasm-crypto = { path = "../crypto", version = "1.5.0" }
3636
derivative = "2"
3737
hex = "0.4"

0 commit comments

Comments
 (0)