Skip to content

Commit 7702850

Browse files
authored
Merge pull request #2066 from CosmWasm/aw/fix-warnings
Fix a bunch of warnings across the workspace
2 parents d078d40 + ad959c8 commit 7702850

23 files changed

+35
-62
lines changed

.circleci/config.yml

+9-9
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ commands:
4141
# Run clippy after wasm build to ensure target/wasm32-unknown-unknown/release/<contract>.wasm exists
4242
- run:
4343
name: Clippy
44-
command: cargo clippy --all-targets -- -D warnings
44+
command: cargo clippy --all-targets --tests -- -D warnings
4545
- run:
4646
name: Integration tests (singlepass backend)
4747
command: cargo integration-test --locked --no-default-features
@@ -912,35 +912,35 @@ jobs:
912912
- run:
913913
name: Clippy linting on crypto
914914
working_directory: ~/project/packages/crypto
915-
command: cargo clippy --all-targets -- -D warnings
915+
command: cargo clippy --all-targets --tests -- -D warnings
916916
- run:
917917
name: Clippy linting on derive
918918
working_directory: ~/project/packages/derive
919-
command: cargo clippy --all-targets -- -D warnings
919+
command: cargo clippy --all-targets --tests -- -D warnings
920920
- run:
921921
name: Clippy linting on schema
922922
working_directory: ~/project/packages/schema
923-
command: cargo clippy --all-targets -- -D warnings
923+
command: cargo clippy --all-targets --tests -- -D warnings
924924
- run:
925925
name: Clippy linting on schema-derive
926926
working_directory: ~/project/packages/schema-derive
927-
command: cargo clippy --all-targets -- -D warnings
927+
command: cargo clippy --all-targets --tests -- -D warnings
928928
- run:
929929
name: Clippy linting on std (no feature flags)
930930
working_directory: ~/project/packages/std
931-
command: cargo clippy --all-targets -- -D warnings
931+
command: cargo clippy --all-targets --tests -- -D warnings
932932
- run:
933933
name: Clippy linting on std (all feature flags)
934934
working_directory: ~/project/packages/std
935-
command: cargo clippy --all-targets --features abort,iterator,staking,stargate,cosmwasm_2_0 -- -D warnings
935+
command: cargo clippy --all-targets --tests --features abort,iterator,staking,stargate,cosmwasm_2_0 -- -D warnings
936936
- run:
937937
name: Clippy linting on vm (no feature flags)
938938
working_directory: ~/project/packages/vm
939-
command: cargo clippy --all-targets --no-default-features -- -D warnings
939+
command: cargo clippy --all-targets --tests --no-default-features -- -D warnings
940940
- run:
941941
name: Clippy linting on vm (all feature flags)
942942
working_directory: ~/project/packages/vm
943-
command: cargo clippy --all-targets --features iterator,staking,stargate -- -D warnings
943+
command: cargo clippy --all-targets --tests --features iterator,staking,stargate -- -D warnings
944944
- save_cache:
945945
paths:
946946
- /usr/local/cargo/registry

packages/crypto/src/secp256r1.rs

-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use p256::{
44
ecdsa::signature::DigestVerifier, // traits
55
ecdsa::{Signature, VerifyingKey}, // type aliases
66
};
7-
use std::convert::TryInto;
87

98
use crate::ecdsa::{ECDSA_COMPRESSED_PUBKEY_LEN, ECDSA_UNCOMPRESSED_PUBKEY_LEN};
109
use crate::errors::{CryptoError, CryptoResult};
@@ -145,8 +144,6 @@ mod tests {
145144
use std::fs::File;
146145
use std::io::BufReader;
147146

148-
use crate::secp256r1_recover_pubkey;
149-
use ecdsa::RecoveryId;
150147
use p256::{
151148
ecdsa::signature::DigestSigner, ecdsa::SigningKey, elliptic_curve::rand_core::OsRng,
152149
};

packages/std/src/addresses.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ fn hash(ty: &str, key: &[u8]) -> Vec<u8> {
360360
#[cfg(test)]
361361
mod tests {
362362
use super::*;
363-
use crate::{assert_hash_works, HexBinary};
363+
use crate::assert_hash_works;
364364
use hex_literal::hex;
365365

366366
#[test]

packages/std/src/binary.rs

-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,6 @@ impl<'de> de::Visitor<'de> for Base64Visitor {
258258
mod tests {
259259
use super::*;
260260
use crate::assert_hash_works;
261-
use crate::errors::StdError;
262261
use crate::serde::{from_json, to_json_vec};
263262

264263
#[test]

packages/std/src/hex_binary.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ impl<'de> de::Visitor<'de> for HexVisitor {
248248
mod tests {
249249
use super::*;
250250

251-
use crate::{assert_hash_works, from_json, to_json_vec, StdError};
251+
use crate::{assert_hash_works, from_json, to_json_vec};
252252

253253
#[test]
254254
fn from_hex_works() {

packages/std/src/ibc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// The CosmosMsg variants are defined in results/cosmos_msg.rs
22
// The rest of the IBC related functionality is defined here
33

4-
use core::cmp::{Ord, Ordering, PartialOrd};
4+
use core::cmp::Ordering;
55
use schemars::JsonSchema;
66
use serde::{Deserialize, Serialize};
77

packages/std/src/math/decimal256.rs

-1
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,6 @@ impl<'de> de::Visitor<'de> for Decimal256Visitor {
783783
#[cfg(test)]
784784
mod tests {
785785
use super::*;
786-
use crate::errors::StdError;
787786
use crate::{from_json, to_json_vec};
788787

789788
fn dec(input: &str) -> Decimal256 {

packages/std/src/math/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ mod tests {
8080
{
8181
}
8282

83+
#[allow(dead_code)] // This is used to statically ensure all the integers have a shared set of traits
8384
trait SignedImpl<'a>: IntImpl<'a> + Neg<Output = Self> {}
8485

8586
impl AllImpl<'_> for Uint64 {}

packages/std/src/query/query_response.rs

+1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ use serde::de::DeserializeOwned;
1515
/// - multi-test/cw-sdk: create a default instance and mutate the fields
1616
///
1717
/// This trait is crate-internal and can change any time.
18+
#[allow(dead_code)] // This is used to statically ensure all the types have a shared set of traits
1819
pub(crate) trait QueryResponseType: DeserializeOwned + Debug + PartialEq + Clone {}

packages/std/src/testing/mock.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -521,16 +521,16 @@ impl<C: DeserializeOwned> MockQuerier<C> {
521521
}
522522
}
523523

524-
pub fn update_wasm<WH: 'static>(&mut self, handler: WH)
524+
pub fn update_wasm<WH>(&mut self, handler: WH)
525525
where
526-
WH: Fn(&WasmQuery) -> QuerierResult,
526+
WH: Fn(&WasmQuery) -> QuerierResult + 'static,
527527
{
528528
self.wasm.update_handler(handler)
529529
}
530530

531-
pub fn with_custom_handler<CH: 'static>(mut self, handler: CH) -> Self
531+
pub fn with_custom_handler<CH>(mut self, handler: CH) -> Self
532532
where
533-
CH: Fn(&C) -> MockQuerierCustomHandlerResult,
533+
CH: Fn(&C) -> MockQuerierCustomHandlerResult + 'static,
534534
{
535535
self.custom_handler = Box::from(handler);
536536
self
@@ -598,9 +598,9 @@ impl WasmQuerier {
598598
Self { handler }
599599
}
600600

601-
fn update_handler<WH: 'static>(&mut self, handler: WH)
601+
fn update_handler<WH>(&mut self, handler: WH)
602602
where
603-
WH: Fn(&WasmQuery) -> QuerierResult,
603+
WH: Fn(&WasmQuery) -> QuerierResult + 'static,
604604
{
605605
self.handler = Box::from(handler)
606606
}
@@ -1116,10 +1116,7 @@ mod tests {
11161116
use super::*;
11171117
#[cfg(feature = "cosmwasm_1_3")]
11181118
use crate::DenomUnit;
1119-
use crate::{
1120-
coin, coins, from_json, instantiate2_address, to_json_binary, ContractInfoResponse,
1121-
HexBinary, Response,
1122-
};
1119+
use crate::{coin, coins, instantiate2_address, ContractInfoResponse, HexBinary, Response};
11231120
#[cfg(feature = "staking")]
11241121
use crate::{Decimal, Delegation};
11251122
use hex_literal::hex;

packages/std/src/traits.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ mod tests {
529529

530530
use super::*;
531531
use crate::testing::MockQuerier;
532-
use crate::{coins, from_json, Uint128};
532+
use crate::{coins, Uint128};
533533

534534
// this is a simple demo helper to prove we can use it
535535
fn demo_helper(_querier: &dyn Querier) -> u64 {

packages/vm/src/cache.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -580,11 +580,9 @@ mod tests {
580580
use super::*;
581581
use crate::calls::{call_execute, call_instantiate};
582582
use crate::capabilities::capabilities_from_csv;
583-
use crate::errors::VmError;
584583
use crate::testing::{mock_backend, mock_env, mock_info, MockApi, MockQuerier, MockStorage};
585584
use cosmwasm_std::{coins, Empty};
586-
use std::fs::{create_dir_all, remove_dir_all, OpenOptions};
587-
use std::io::Write;
585+
use std::fs::{create_dir_all, remove_dir_all};
588586
use tempfile::TempDir;
589587

590588
const TESTING_GAS_LIMIT: u64 = 500_000_000; // ~0.5ms

packages/vm/src/calls.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -859,18 +859,14 @@ mod tests {
859859
#[cfg(feature = "stargate")]
860860
mod ibc {
861861
use super::*;
862-
use crate::calls::{call_instantiate, call_reply};
863-
use crate::testing::{
864-
mock_env, mock_info, mock_instance, MockApi, MockQuerier, MockStorage,
865-
};
862+
use crate::testing::{MockApi, MockQuerier, MockStorage};
866863
use cosmwasm_std::testing::mock_ibc_packet_timeout;
867864
use cosmwasm_std::testing::{
868865
mock_ibc_channel_close_init, mock_ibc_channel_connect_ack, mock_ibc_channel_open_init,
869866
mock_ibc_packet_ack, mock_ibc_packet_recv, mock_wasmd_attr,
870867
};
871868
use cosmwasm_std::{
872-
Empty, Event, IbcAcknowledgement, IbcOrder, Reply, ReplyOn, SubMsgResponse,
873-
SubMsgResult,
869+
Event, IbcAcknowledgement, IbcOrder, ReplyOn, SubMsgResponse, SubMsgResult,
874870
};
875871
static CONTRACT: &[u8] = include_bytes!("../testdata/ibc_reflect.wasm");
876872
const IBC_VERSION: &str = "ibc-reflect-v1";

packages/vm/src/compatibility.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ fn check_wasm_functions(module: &ParsedWasm) -> VmResult<()> {
268268
#[cfg(test)]
269269
mod tests {
270270
use super::*;
271-
use crate::{capabilities_from_csv, errors::VmError};
271+
use crate::capabilities_from_csv;
272272

273273
static CONTRACT_0_7: &[u8] = include_bytes!("../testdata/hackatom_0.7.wasm");
274274
static CONTRACT_0_12: &[u8] = include_bytes!("../testdata/hackatom_0.12.wasm");

packages/vm/src/conversion.rs

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ pub fn to_i32<T: TryInto<i32> + ToString + Copy>(input: T) -> VmResult<i32> {
3232
#[cfg(test)]
3333
mod tests {
3434
use super::*;
35-
use crate::errors::VmError;
3635

3736
#[test]
3837
fn to_u32_works_for_usize() {

packages/vm/src/environment.rs

-2
Original file line numberDiff line numberDiff line change
@@ -455,9 +455,7 @@ pub fn process_gas_info<A: BackendApi, S: Storage, Q: Querier>(
455455
#[cfg(test)]
456456
mod tests {
457457
use super::*;
458-
use crate::backend::Storage;
459458
use crate::conversion::ref_to_u32;
460-
use crate::errors::VmError;
461459
use crate::size::Size;
462460
use crate::testing::{MockApi, MockQuerier, MockStorage};
463461
use crate::wasm_backend::{compile, make_compiling_engine};

packages/vm/src/imports.rs

-1
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,6 @@ mod tests {
691691
use std::ptr::NonNull;
692692
use wasmer::{imports, Function, FunctionEnv, Instance as WasmerInstance, Store};
693693

694-
use crate::backend::{BackendError, Storage};
695694
use crate::size::Size;
696695
use crate::testing::{MockApi, MockQuerier, MockStorage};
697696
use crate::wasm_backend::{compile, make_compiling_engine};

packages/vm/src/instance.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -491,9 +491,7 @@ mod tests {
491491
use std::time::SystemTime;
492492

493493
use super::*;
494-
use crate::backend::Storage;
495494
use crate::calls::{call_execute, call_instantiate, call_query};
496-
use crate::errors::VmError;
497495
use crate::testing::{
498496
mock_backend, mock_env, mock_info, mock_instance, mock_instance_options,
499497
mock_instance_with_balances, mock_instance_with_failing_api, mock_instance_with_gas_limit,
@@ -502,7 +500,7 @@ mod tests {
502500
use cosmwasm_std::{
503501
coin, coins, from_json, AllBalanceResponse, BalanceResponse, BankQuery, Empty, QueryRequest,
504502
};
505-
use wasmer::{FunctionEnv, FunctionEnvMut};
503+
use wasmer::FunctionEnvMut;
506504

507505
const KIB: usize = 1024;
508506
const MIB: usize = 1024 * 1024;

packages/vm/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ pub use crate::instance::{DebugInfo, GasReport, Instance, InstanceOptions};
4747
pub use crate::serde::{from_slice, to_vec};
4848
pub use crate::size::Size;
4949

50-
#[doc(hidden)]
5150
pub mod internals {
51+
#![doc(hidden)]
5252
//! We use the internals module for exporting types that are only
5353
//! intended to be used in internal crates / utils.
5454
//! Please don't use any of these types directly, as

packages/vm/src/modules/file_system_cache.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -237,13 +237,8 @@ fn modules_path(base_path: &Path, wasmer_module_version: u32, target: &Target) -
237237

238238
#[cfg(test)]
239239
mod tests {
240-
use std::fs;
241-
242240
use super::*;
243-
use crate::{
244-
size::Size,
245-
wasm_backend::{compile, make_compiling_engine},
246-
};
241+
use crate::wasm_backend::{compile, make_compiling_engine};
247242
use tempfile::TempDir;
248243
use wasmer::{imports, Instance as WasmerInstance, Store};
249244
use wasmer_middlewares::metering::set_remaining_points;

packages/vm/src/modules/in_memory_cache.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,7 @@ impl InMemoryCache {
9494
#[cfg(test)]
9595
mod tests {
9696
use super::*;
97-
use crate::{
98-
size::Size,
99-
wasm_backend::{compile, make_compiling_engine, make_runtime_engine},
100-
};
97+
use crate::wasm_backend::{compile, make_compiling_engine, make_runtime_engine};
10198
use std::mem;
10299
use wasmer::{imports, Instance as WasmerInstance, Module, Store};
103100
use wasmer_middlewares::metering::set_remaining_points;

packages/vm/src/testing/mock.rs

-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ pub fn mock_info(sender: &str, funds: &[Coin]) -> MessageInfo {
241241
#[cfg(test)]
242242
mod tests {
243243
use super::*;
244-
use crate::BackendError;
245244
use cosmwasm_std::coins;
246245

247246
#[test]

packages/vm/src/testing/querier.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,16 @@ impl<C: CustomQuery + DeserializeOwned> MockQuerier<C> {
4545
self.querier.staking.update(denom, validators, delegations);
4646
}
4747

48-
pub fn update_wasm<WH: 'static>(&mut self, handler: WH)
48+
pub fn update_wasm<WH>(&mut self, handler: WH)
4949
where
50-
WH: Fn(&cosmwasm_std::WasmQuery) -> cosmwasm_std::QuerierResult,
50+
WH: Fn(&cosmwasm_std::WasmQuery) -> cosmwasm_std::QuerierResult + 'static,
5151
{
5252
self.querier.update_wasm(handler)
5353
}
5454

55-
pub fn with_custom_handler<CH: 'static>(mut self, handler: CH) -> Self
55+
pub fn with_custom_handler<CH>(mut self, handler: CH) -> Self
5656
where
57-
CH: Fn(&C) -> MockQuerierCustomHandlerResult,
57+
CH: Fn(&C) -> MockQuerierCustomHandlerResult + 'static,
5858
{
5959
self.querier = self.querier.with_custom_handler(handler);
6060
self
@@ -113,7 +113,7 @@ impl MockQuerier {
113113
#[cfg(test)]
114114
mod tests {
115115
use super::*;
116-
use cosmwasm_std::{coin, from_json, AllBalanceResponse, BalanceResponse, BankQuery, Empty};
116+
use cosmwasm_std::{coin, from_json, AllBalanceResponse, BalanceResponse, BankQuery};
117117

118118
const DEFAULT_QUERY_GAS_LIMIT: u64 = 300_000;
119119

0 commit comments

Comments
 (0)