Skip to content

Commit 1b3ddae

Browse files
authored
Fix all warnings when building for wasm (paritytech#11569)
* Fix all warnings when building for wasm Besides that it also enables warnings as errors for wasm builds in the CI. * FMT * Make clippy happy
1 parent 699375e commit 1b3ddae

File tree

9 files changed

+19
-17
lines changed

9 files changed

+19
-17
lines changed

frame/contracts/proc-macro/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ extern crate alloc;
2424
use alloc::string::ToString;
2525
use proc_macro2::TokenStream;
2626
use quote::{quote, quote_spanned};
27-
use syn::{parse_macro_input, spanned::Spanned, Data, DataStruct, DeriveInput, Fields, Ident};
27+
use syn::{parse_macro_input, Data, DeriveInput, Ident};
2828

2929
/// This derives `Debug` for a struct where each field must be of some numeric type.
3030
/// It interprets each field as its represents some weight and formats it as times so that
@@ -84,7 +84,9 @@ fn derive_debug(
8484

8585
/// This is only used then the `full` feature is activated.
8686
#[cfg(feature = "full")]
87-
fn iterate_fields(data: &DataStruct, fmt: impl Fn(&Ident) -> TokenStream) -> TokenStream {
87+
fn iterate_fields(data: &syn::DataStruct, fmt: impl Fn(&Ident) -> TokenStream) -> TokenStream {
88+
use syn::{spanned::Spanned, Fields};
89+
8890
match &data.fields {
8991
Fields::Named(fields) => {
9092
let recurse = fields.named.iter().filter_map(|f| {

frame/nomination-pools/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ use frame_support::{
316316
Currency, Defensive, DefensiveOption, DefensiveResult, DefensiveSaturating,
317317
ExistenceRequirement, Get,
318318
},
319-
CloneNoBound, DefaultNoBound, PartialEqNoBound, RuntimeDebugNoBound,
319+
CloneNoBound, DefaultNoBound, RuntimeDebugNoBound,
320320
};
321321
use scale_info::TypeInfo;
322322
use sp_core::U256;
@@ -398,7 +398,7 @@ enum AccountType {
398398

399399
/// A member in a pool.
400400
#[derive(Encode, Decode, MaxEncodedLen, TypeInfo, RuntimeDebugNoBound, CloneNoBound)]
401-
#[cfg_attr(feature = "std", derive(PartialEqNoBound, DefaultNoBound))]
401+
#[cfg_attr(feature = "std", derive(frame_support::PartialEqNoBound, DefaultNoBound))]
402402
#[codec(mel_bound(T: Config))]
403403
#[scale_info(skip_type_params(T))]
404404
pub struct PoolMember<T: Config> {

frame/ranked-collective/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ pub mod pallet {
444444
MemberCount::<T, I>::insert(rank, index.checked_add(1).ok_or(Overflow)?);
445445
IdToIndex::<T, I>::insert(rank, &who, index);
446446
IndexToId::<T, I>::insert(rank, index, &who);
447-
Members::<T, I>::insert(&who, MemberRecord { rank, ..record });
447+
Members::<T, I>::insert(&who, MemberRecord { rank });
448448
Self::deposit_event(Event::RankChanged { who, rank });
449449

450450
Ok(())

frame/try-runtime/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#![cfg_attr(not(feature = "std"), no_std)]
2121

2222
use frame_support::weights::Weight;
23-
use sp_std::prelude::*;
2423

2524
sp_api::decl_runtime_apis! {
2625
/// Runtime api for testing the execution of a runtime upgrade.

primitives/block-builder/src/lib.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@
2020
#![cfg_attr(not(feature = "std"), no_std)]
2121

2222
use sp_inherents::{CheckInherentsResult, InherentData};
23-
use sp_runtime::{
24-
legacy::byte_sized_error::ApplyExtrinsicResult as ApplyExtrinsicResultBeforeV6,
25-
traits::Block as BlockT, ApplyExtrinsicResult,
26-
};
23+
use sp_runtime::{traits::Block as BlockT, ApplyExtrinsicResult};
2724

2825
sp_api::decl_runtime_apis! {
2926
/// The `BlockBuilder` api trait that provides the required functionality for building a block.
@@ -36,7 +33,9 @@ sp_api::decl_runtime_apis! {
3633
fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult;
3734

3835
#[changed_in(6)]
39-
fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResultBeforeV6;
36+
fn apply_extrinsic(
37+
extrinsic: <Block as BlockT>::Extrinsic,
38+
) -> sp_runtime::legacy::byte_sized_error::ApplyExtrinsicResult;
4039

4140
/// Finish the current block.
4241
#[renamed("finalise_block", 3)]

primitives/io/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,17 +1522,17 @@ mod tracing_setup {
15221522
fn new_span(&self, attrs: &Attributes<'_>) -> Id {
15231523
Id::from_u64(wasm_tracing::enter_span(Crossing(attrs.into())))
15241524
}
1525-
fn enter(&self, span: &Id) {
1525+
fn enter(&self, _: &Id) {
15261526
// Do nothing, we already entered the span previously
15271527
}
15281528
/// Not implemented! We do not support recording values later
15291529
/// Will panic when used.
1530-
fn record(&self, span: &Id, values: &Record<'_>) {
1530+
fn record(&self, _: &Id, _: &Record<'_>) {
15311531
unimplemented! {} // this usage is not supported
15321532
}
15331533
/// Not implemented! We do not support recording values later
15341534
/// Will panic when used.
1535-
fn record_follows_from(&self, span: &Id, follows: &Id) {
1535+
fn record_follows_from(&self, _: &Id, _: &Id) {
15361536
unimplemented! {} // this usage is not supported
15371537
}
15381538
fn event(&self, event: &Event<'_>) {

primitives/state-machine/src/trie_backend_essence.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ use sp_trie::{
2929
child_delta_trie_root, delta_trie_root, empty_child_trie_root, read_child_trie_value,
3030
read_trie_value,
3131
trie_types::{TrieDB, TrieError},
32-
DBValue, KeySpacedDB, LayoutV1 as Layout, PrefixedMemoryDB, Trie, TrieDBIterator,
33-
TrieDBKeyIterator,
32+
DBValue, KeySpacedDB, LayoutV1 as Layout, Trie, TrieDBIterator, TrieDBKeyIterator,
3433
};
3534
#[cfg(feature = "std")]
3635
use std::collections::HashMap;
@@ -619,7 +618,7 @@ pub trait TrieBackendStorage<H: Hasher>: Send + Sync {
619618
// This implementation is used by normal storage trie clients.
620619
#[cfg(feature = "std")]
621620
impl<H: Hasher> TrieBackendStorage<H> for Arc<dyn Storage<H>> {
622-
type Overlay = PrefixedMemoryDB<H>;
621+
type Overlay = sp_trie::PrefixedMemoryDB<H>;
623622

624623
fn get(&self, key: &H::Out, prefix: Prefix) -> Result<Option<DBValue>> {
625624
Storage::<H>::get(std::ops::Deref::deref(self), key, prefix)

primitives/version/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ impl fmt::Display for RuntimeVersion {
273273
}
274274
}
275275

276+
#[cfg(feature = "std")]
276277
fn has_api_with<P: Fn(u32) -> bool>(apis: &ApisVec, id: &ApiId, predicate: P) -> bool {
277278
apis.iter().any(|(s, v)| s == id && predicate(*v))
278279
}

scripts/ci/gitlab/pipeline/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ test-linux-stable:
205205
RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings"
206206
RUST_BACKTRACE: 1
207207
WASM_BUILD_NO_COLOR: 1
208+
WASM_BUILD_RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings"
208209
# Ensure we run the UI tests.
209210
RUN_UI_TESTS: 1
210211
script:
@@ -247,6 +248,7 @@ test-linux-stable-int:
247248
RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings"
248249
RUST_BACKTRACE: 1
249250
WASM_BUILD_NO_COLOR: 1
251+
WASM_BUILD_RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings"
250252
# Ensure we run the UI tests.
251253
RUN_UI_TESTS: 1
252254
script:

0 commit comments

Comments
 (0)