diff --git a/.github/env b/.github/env index 730c37f1db80b..6d3f8e994cbab 100644 --- a/.github/env +++ b/.github/env @@ -1 +1 @@ -IMAGE="docker.io/paritytech/ci-unified:bullseye-1.81.0-2024-11-19-v202411281558" +IMAGE="docker.io/paritytech/ci-unified:bullseye-1.84.1-2025-01-28-v202502131220" diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 42a7e87bda433..359aec73214e8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,7 +22,7 @@ workflow: variables: # CI_IMAGE: !reference [ .ci-unified, variables, CI_IMAGE ] - CI_IMAGE: "docker.io/paritytech/ci-unified:bullseye-1.81.0-2024-11-19-v202411281558" + CI_IMAGE: "docker.io/paritytech/ci-unified:bullseye-1.84.1-2025-01-28-v202502131220" # BUILDAH_IMAGE is defined in group variables BUILDAH_COMMAND: "buildah --storage-driver overlay2" RELENG_SCRIPTS_BRANCH: "master" @@ -125,18 +125,18 @@ default: - cat .forklift/config-gitlab.toml > .forklift/config.toml - > if [ "$FORKLIFT_BYPASS" != "true" ]; then - echo "FORKLIFT_BYPASS not set"; + echo "FORKLIFT_BYPASS not set"; if command -v forklift >/dev/null 2>&1; then - echo "forklift already exists"; + echo "forklift already exists"; forklift version else echo "forklift does not exist, downloading"; - curl --header "PRIVATE-TOKEN: $FL_CI_GROUP_TOKEN" -o forklift -L "${CI_API_V4_URL}/projects/676/packages/generic/forklift/${FL_FORKLIFT_VERSION}/forklift_${FL_FORKLIFT_VERSION}_linux_amd64"; + curl --header "PRIVATE-TOKEN: $FL_CI_GROUP_TOKEN" -o forklift -L "${CI_API_V4_URL}/projects/676/packages/generic/forklift/${FL_FORKLIFT_VERSION}/forklift_${FL_FORKLIFT_VERSION}_linux_amd64"; chmod +x forklift; export PATH=$PATH:$(pwd); echo ${FL_FORKLIFT_VERSION}; fi - echo "Creating alias cargo='forklift cargo'"; + echo "Creating alias cargo='forklift cargo'"; shopt -s expand_aliases; alias cargo="forklift cargo"; fi diff --git a/Cargo.lock b/Cargo.lock index c6fefcfdfe186..76455fdb82945 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1747,15 +1747,6 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" -[[package]] -name = "basic-toml" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2db21524cad41c5591204d22d75e1970a2d1f71060214ca931dc7d5afe2c14e5" -dependencies = [ - "serde", -] - [[package]] name = "binary-merkle-tree" version = "13.0.0" @@ -29640,6 +29631,12 @@ version = "0.12.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d0e916b1148c8e263850e1ebcbd046f333e0683c724876bb0da63ea4373dc8a" +[[package]] +name = "target-triple" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42a4d50cdb458045afc8131fd91b64904da29548bcb63c7236e0844936c13078" + [[package]] name = "tempfile" version = "3.14.0" @@ -30488,18 +30485,18 @@ checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" [[package]] name = "trybuild" -version = "1.0.89" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a9d3ba662913483d6722303f619e75ea10b7855b0f8e0d72799cf8621bb488f" +checksum = "b812699e0c4f813b872b373a4471717d9eb550da14b311058a4d9cf4173cbca6" dependencies = [ - "basic-toml", "dissimilar", "glob", - "once_cell", "serde", "serde_derive", "serde_json", + "target-triple", "termcolor", + "toml 0.8.19", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 0769a95932d44..cdca5de448443 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1369,7 +1369,7 @@ trie-bench = { version = "0.39.0" } trie-db = { version = "0.29.1", default-features = false } trie-root = { version = "0.18.0", default-features = false } trie-standardmap = { version = "0.16.0" } -trybuild = { version = "1.0.89" } +trybuild = { version = "1.0.103" } tt-call = { version = "1.0.8" } tuplex = { version = "0.1", default-features = false } twox-hash = { version = "1.6.3", default-features = false } diff --git a/bridges/modules/grandpa/src/lib.rs b/bridges/modules/grandpa/src/lib.rs index 22a15ec4062f7..c2c1218418fb1 100644 --- a/bridges/modules/grandpa/src/lib.rs +++ b/bridges/modules/grandpa/src/lib.rs @@ -789,12 +789,9 @@ where pub fn synced_headers_grandpa_info() -> Vec>> { frame_system::Pallet::::read_events_no_consensus() .filter_map(|event| { - if let Event::::UpdatedBestFinalizedHeader { grandpa_info, .. } = - event.event.try_into().ok()? - { - return Some(grandpa_info) - } - None + let Event::::UpdatedBestFinalizedHeader { grandpa_info, .. } = + event.event.try_into().ok()?; + Some(grandpa_info) }) .collect() } diff --git a/bridges/primitives/test-utils/src/lib.rs b/bridges/primitives/test-utils/src/lib.rs index 9855c32a46895..ae3d85ccdf51f 100644 --- a/bridges/primitives/test-utils/src/lib.rs +++ b/bridges/primitives/test-utils/src/lib.rs @@ -110,7 +110,7 @@ pub fn make_justification_for_header( ); // Roughly, how many vote ancestries do we want per fork - let target_depth = (ancestors + forks - 1) / forks; + let target_depth = ancestors.div_ceil(forks); let mut unsigned_precommits = vec![]; for i in 0..forks { diff --git a/bridges/relays/lib-substrate-relay/src/messages/mod.rs b/bridges/relays/lib-substrate-relay/src/messages/mod.rs index b4ee57ed7742e..8d22c0c843917 100644 --- a/bridges/relays/lib-substrate-relay/src/messages/mod.rs +++ b/bridges/relays/lib-substrate-relay/src/messages/mod.rs @@ -820,6 +820,7 @@ mod tests { } // mock runtime with `pallet_bridge_messages` + #[allow(unexpected_cfgs)] mod mock { use super::super::*; use bp_messages::{target_chain::ForbidInboundMessages, HashedLaneId}; diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs index 15c1a822b756c..32077c7a987a8 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs @@ -1687,6 +1687,7 @@ impl_runtime_apis! { (list, storage_info) } + #[allow(non_local_definitions)] fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig ) -> Result, alloc::string::String> { diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index 016f46d3c556a..ec2148a57595d 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -1883,6 +1883,7 @@ impl_runtime_apis! { (list, storage_info) } + #[allow(non_local_definitions)] fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig ) -> Result, alloc::string::String> { diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index 140056e724a79..23cb8684e3626 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -1086,6 +1086,7 @@ impl_runtime_apis! { (list, storage_info) } + #[allow(non_local_definitions)] fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig ) -> Result, alloc::string::String> { diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs index 83712df8295b7..d097f9fc26d7d 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs @@ -976,6 +976,7 @@ impl_runtime_apis! { (list, storage_info) } + #[allow(non_local_definitions)] fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig ) -> Result, alloc::string::String> { diff --git a/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs b/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs index 65f3e27ae9a71..db547b5f2264c 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs @@ -1088,6 +1088,7 @@ impl_runtime_apis! { (list, storage_info) } + #[allow(non_local_definitions)] fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig ) -> Result, alloc::string::String> { diff --git a/cumulus/parachains/runtimes/contracts/contracts-rococo/src/lib.rs b/cumulus/parachains/runtimes/contracts/contracts-rococo/src/lib.rs index 165e60361cd18..7dee544327138 100644 --- a/cumulus/parachains/runtimes/contracts/contracts-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/contracts/contracts-rococo/src/lib.rs @@ -785,6 +785,7 @@ impl_runtime_apis! { (list, storage_info) } + #[allow(non_local_definitions)] fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig ) -> Result, alloc::string::String> { diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs index b477bb4850d1c..e55e69e3ebcf1 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs @@ -953,6 +953,7 @@ impl_runtime_apis! { (list, storage_info) } + #[allow(non_local_definitions)] fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig ) -> Result, alloc::string::String> { diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs index 964351575de83..3ad31463dd542 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs @@ -945,6 +945,7 @@ impl_runtime_apis! { (list, storage_info) } + #[allow(non_local_definitions)] fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig ) -> Result, alloc::string::String> { diff --git a/cumulus/parachains/runtimes/glutton/glutton-westend/src/lib.rs b/cumulus/parachains/runtimes/glutton/glutton-westend/src/lib.rs index 4de0c4976ffda..bc344dd776687 100644 --- a/cumulus/parachains/runtimes/glutton/glutton-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/glutton/glutton-westend/src/lib.rs @@ -459,6 +459,7 @@ impl_runtime_apis! { (list, storage_info) } + #[allow(non_local_definitions)] fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig ) -> Result, alloc::string::String> { diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs b/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs index 3766626ba4f63..07b96ce55bf86 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs @@ -901,6 +901,7 @@ impl_runtime_apis! { (list, storage_info) } + #[allow(non_local_definitions)] fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig ) -> Result, alloc::string::String> { diff --git a/cumulus/parachains/runtimes/people/people-westend/src/lib.rs b/cumulus/parachains/runtimes/people/people-westend/src/lib.rs index 34ab85f3d0cdd..98e38a2dd2c95 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/lib.rs @@ -899,6 +899,7 @@ impl_runtime_apis! { (list, storage_info) } + #[allow(non_local_definitions)] fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig ) -> Result, alloc::string::String> { diff --git a/cumulus/parachains/runtimes/testing/penpal/src/lib.rs b/cumulus/parachains/runtimes/testing/penpal/src/lib.rs index dfccf3ec9860d..e5c1dbb936558 100644 --- a/cumulus/parachains/runtimes/testing/penpal/src/lib.rs +++ b/cumulus/parachains/runtimes/testing/penpal/src/lib.rs @@ -1140,6 +1140,7 @@ impl_runtime_apis! { (list, storage_info) } + #[allow(non_local_definitions)] fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig ) -> Result, alloc::string::String> { diff --git a/cumulus/polkadot-omni-node/lib/src/fake_runtime_api/utils.rs b/cumulus/polkadot-omni-node/lib/src/fake_runtime_api/utils.rs index 636c845271d54..858275d189a67 100644 --- a/cumulus/polkadot-omni-node/lib/src/fake_runtime_api/utils.rs +++ b/cumulus/polkadot-omni-node/lib/src/fake_runtime_api/utils.rs @@ -206,6 +206,7 @@ macro_rules! impl_node_runtime_apis { unimplemented!() } + #[allow(non_local_definitions)] fn dispatch_benchmark( _: frame_benchmarking::BenchmarkConfig ) -> Result, String> { diff --git a/docs/contributor/container.md b/docs/contributor/container.md index e387f568d7b51..bc05bf8b54a50 100644 --- a/docs/contributor/container.md +++ b/docs/contributor/container.md @@ -24,7 +24,7 @@ The command below allows building a Linux binary without having to even install docker run --rm -it \ -w /polkadot-sdk \ -v $(pwd):/polkadot-sdk \ - docker.io/paritytech/ci-unified:bullseye-1.81.0-2024-11-19-v202411281558 \ + docker.io/paritytech/ci-unified:bullseye-1.84.1-2025-01-28-v202502131220 \ cargo build --release --locked -p polkadot-parachain-bin --bin polkadot-parachain sudo chown -R $(id -u):$(id -g) target/ ``` diff --git a/docs/sdk/src/lib.rs b/docs/sdk/src/lib.rs index d96239ca89424..c1aefe435354d 100644 --- a/docs/sdk/src/lib.rs +++ b/docs/sdk/src/lib.rs @@ -23,6 +23,8 @@ #![doc = simple_mermaid::mermaid!("../../mermaid/IA.mmd")] #![warn(rustdoc::broken_intra_doc_links)] #![warn(rustdoc::private_intra_doc_links)] +// Frame macros reference features which this crate does not have +#![allow(unexpected_cfgs)] #![doc(html_favicon_url = "https://polkadot.com/favicon.ico")] #![doc( html_logo_url = "https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/docs/images/Polkadot_Logo_Horizontal_Pink_White.png" diff --git a/polkadot/node/network/statement-distribution/src/v2/tests/mod.rs b/polkadot/node/network/statement-distribution/src/v2/tests/mod.rs index 5a9b8efa2a13b..da3715e387334 100644 --- a/polkadot/node/network/statement-distribution/src/v2/tests/mod.rs +++ b/polkadot/node/network/statement-distribution/src/v2/tests/mod.rs @@ -776,6 +776,7 @@ async fn answer_expected_hypothetical_membership_request( ) } +/// Assert that the correct peer is reported. #[macro_export] macro_rules! assert_peer_reported { ($virtual_overseer:expr, $peer_id:expr, $rep_change:expr $(,)*) => { diff --git a/polkadot/node/overseer/src/lib.rs b/polkadot/node/overseer/src/lib.rs index a8d0ab90f6b91..92989e2b520e9 100644 --- a/polkadot/node/overseer/src/lib.rs +++ b/polkadot/node/overseer/src/lib.rs @@ -60,7 +60,8 @@ // unused dependencies can not work for test and examples at the same time // yielding false positives #![warn(missing_docs)] -#![allow(dead_code)] // TODO https://github.com/paritytech/polkadot-sdk/issues/5793 +// TODO https://github.com/paritytech/polkadot-sdk/issues/5793 +#![allow(dead_code, irrefutable_let_patterns)] use std::{ collections::{hash_map, HashMap}, diff --git a/polkadot/runtime/common/Cargo.toml b/polkadot/runtime/common/Cargo.toml index 4ffa5c475ed77..066fd1ef32bfc 100644 --- a/polkadot/runtime/common/Cargo.toml +++ b/polkadot/runtime/common/Cargo.toml @@ -120,6 +120,7 @@ std = [ runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", "frame-election-provider-support/runtime-benchmarks", + "frame-support-test/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", "libsecp256k1/hmac", diff --git a/polkadot/runtime/parachains/Cargo.toml b/polkadot/runtime/parachains/Cargo.toml index 6c87f7773c235..145b533cbb15a 100644 --- a/polkadot/runtime/parachains/Cargo.toml +++ b/polkadot/runtime/parachains/Cargo.toml @@ -120,6 +120,7 @@ std = [ ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", + "frame-support-test/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", "pallet-babe/runtime-benchmarks", diff --git a/polkadot/runtime/parachains/src/coretime/migration.rs b/polkadot/runtime/parachains/src/coretime/migration.rs index c3a1ebe824324..cd44451a7c392 100644 --- a/polkadot/runtime/parachains/src/coretime/migration.rs +++ b/polkadot/runtime/parachains/src/coretime/migration.rs @@ -250,7 +250,7 @@ mod v_coretime { return None }, }; - let time_slice = (valid_until + TIMESLICE_PERIOD - 1) / TIMESLICE_PERIOD; + let time_slice = valid_until.div_ceil(TIMESLICE_PERIOD); log::trace!(target: "coretime-migration", "Sending of lease holding para {:?}, valid_until: {:?}, time_slice: {:?}", p, valid_until, time_slice); Some(mk_coretime_call::(crate::coretime::CoretimeCalls::SetLease(p.into(), time_slice))) }); diff --git a/polkadot/runtime/rococo/src/lib.rs b/polkadot/runtime/rococo/src/lib.rs index 61403c001e210..6fd21eb6928e2 100644 --- a/polkadot/runtime/rococo/src/lib.rs +++ b/polkadot/runtime/rococo/src/lib.rs @@ -2467,6 +2467,7 @@ sp_api::impl_runtime_apis! { return (list, storage_info) } + #[allow(non_local_definitions)] fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig, ) -> Result< diff --git a/polkadot/runtime/westend/src/lib.rs b/polkadot/runtime/westend/src/lib.rs index 8ee9e073f162d..e7aaf6f29e377 100644 --- a/polkadot/runtime/westend/src/lib.rs +++ b/polkadot/runtime/westend/src/lib.rs @@ -2648,6 +2648,7 @@ sp_api::impl_runtime_apis! { return (list, storage_info) } + #[allow(non_local_definitions)] fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig, ) -> Result< diff --git a/polkadot/xcm/docs/src/lib.rs b/polkadot/xcm/docs/src/lib.rs index 8d78b9b19452d..77823cad3fd2c 100644 --- a/polkadot/xcm/docs/src/lib.rs +++ b/polkadot/xcm/docs/src/lib.rs @@ -50,6 +50,8 @@ //! //! ## Docs structure #![doc = simple_mermaid::mermaid!("../mermaid/structure.mmd")] +// Frame macros reference features which this crate does not have +#![allow(unexpected_cfgs)] /// Fundamentals of the XCM language. The virtual machine, instructions, locations and assets. pub mod fundamentals; diff --git a/polkadot/xcm/xcm-simulator/example/src/lib.rs b/polkadot/xcm/xcm-simulator/example/src/lib.rs index 8a05569831b5c..7d179bd258714 100644 --- a/polkadot/xcm/xcm-simulator/example/src/lib.rs +++ b/polkadot/xcm/xcm-simulator/example/src/lib.rs @@ -14,7 +14,12 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . +// We do not declare all features used by `construct_runtime` +#[allow(unexpected_cfgs)] mod parachain; + +// We do not declare all features used by `construct_runtime` +#[allow(unexpected_cfgs)] mod relay_chain; #[cfg(test)] diff --git a/polkadot/xcm/xcm-simulator/fuzzer/src/fuzz.rs b/polkadot/xcm/xcm-simulator/fuzzer/src/fuzz.rs index 8ea5e033f3ad7..c49804310dd32 100644 --- a/polkadot/xcm/xcm-simulator/fuzzer/src/fuzz.rs +++ b/polkadot/xcm/xcm-simulator/fuzzer/src/fuzz.rs @@ -14,7 +14,12 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . +// We do not declare all features used by `construct_runtime` +#[allow(unexpected_cfgs)] mod parachain; + +// We do not declare all features used by `construct_runtime` +#[allow(unexpected_cfgs)] mod relay_chain; use codec::DecodeLimit; diff --git a/substrate/bin/node/runtime/src/lib.rs b/substrate/bin/node/runtime/src/lib.rs index d90d103fdedc2..8f5817108bc8d 100644 --- a/substrate/bin/node/runtime/src/lib.rs +++ b/substrate/bin/node/runtime/src/lib.rs @@ -4058,6 +4058,7 @@ impl_runtime_apis! { (list, storage_info) } + #[allow(non_local_definitions)] fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig ) -> Result, alloc::string::String> { diff --git a/substrate/client/allocator/src/freeing_bump.rs b/substrate/client/allocator/src/freeing_bump.rs index 405916adc3c3f..f98e540b18c5b 100644 --- a/substrate/client/allocator/src/freeing_bump.rs +++ b/substrate/client/allocator/src/freeing_bump.rs @@ -350,7 +350,7 @@ pub struct AllocationStats { /// /// Returns `None` if the number of pages to not fit into `u32`. fn pages_from_size(size: u64) -> Option { - u32::try_from((size + PAGE_SIZE as u64 - 1) / PAGE_SIZE as u64).ok() + u32::try_from(size.div_ceil(PAGE_SIZE as u64)).ok() } /// An implementation of freeing bump allocator. @@ -378,7 +378,7 @@ impl FreeingBumpHeapAllocator { /// /// - `heap_base` - the offset from the beginning of the linear memory where the heap starts. pub fn new(heap_base: u32) -> Self { - let aligned_heap_base = (heap_base + ALIGNMENT - 1) / ALIGNMENT * ALIGNMENT; + let aligned_heap_base = heap_base.div_ceil(ALIGNMENT) * ALIGNMENT; FreeingBumpHeapAllocator { original_heap_base: aligned_heap_base, diff --git a/substrate/client/merkle-mountain-range/src/test_utils.rs b/substrate/client/merkle-mountain-range/src/test_utils.rs index 3b0506ef55d32..79879cc09a79e 100644 --- a/substrate/client/merkle-mountain-range/src/test_utils.rs +++ b/substrate/client/merkle-mountain-range/src/test_utils.rs @@ -16,6 +16,8 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +//! Test utilities. + use crate::MmrGadget; use parking_lot::Mutex; use sc_block_builder::BlockBuilderBuilder; @@ -67,9 +69,12 @@ pub(crate) struct MmrBlock { pub(crate) leaf_data: Vec, } +/// Which kind of key type to use. #[derive(Clone, Copy)] pub enum OffchainKeyType { + /// Temporary key. Temp, + /// Cononical key. Canon, } diff --git a/substrate/client/network/types/src/kad.rs b/substrate/client/network/types/src/kad.rs index 72028d356dc78..e844f97674018 100644 --- a/substrate/client/network/types/src/kad.rs +++ b/substrate/client/network/types/src/kad.rs @@ -101,7 +101,7 @@ impl Record { /// Checks whether the record is expired w.r.t. the given `Instant`. pub fn is_expired(&self, now: Instant) -> bool { - self.expires.map_or(false, |t| now >= t) + self.expires.is_some_and(|t| now >= t) } } diff --git a/substrate/client/network/types/src/multiaddr/protocol.rs b/substrate/client/network/types/src/multiaddr/protocol.rs index aca3a31136860..35fcaa5493a47 100644 --- a/substrate/client/network/types/src/multiaddr/protocol.rs +++ b/substrate/client/network/types/src/multiaddr/protocol.rs @@ -66,14 +66,14 @@ pub enum Protocol<'a> { Wss(Cow<'a, str>), } -impl<'a> Display for Protocol<'a> { +impl Display for Protocol<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let protocol = LiteP2pProtocol::from(self.clone()); Display::fmt(&protocol, f) } } -impl<'a> From for Protocol<'a> { +impl From for Protocol<'_> { #[inline] fn from(addr: IpAddr) -> Self { match addr { @@ -83,14 +83,14 @@ impl<'a> From for Protocol<'a> { } } -impl<'a> From for Protocol<'a> { +impl From for Protocol<'_> { #[inline] fn from(addr: Ipv4Addr) -> Self { Protocol::Ip4(addr) } } -impl<'a> From for Protocol<'a> { +impl From for Protocol<'_> { #[inline] fn from(addr: Ipv6Addr) -> Self { Protocol::Ip6(addr) diff --git a/substrate/client/rpc-spec-v2/src/chain_head/test_utils.rs b/substrate/client/rpc-spec-v2/src/chain_head/test_utils.rs index fa10fde388f97..48259f10ffc07 100644 --- a/substrate/client/rpc-spec-v2/src/chain_head/test_utils.rs +++ b/substrate/client/rpc-spec-v2/src/chain_head/test_utils.rs @@ -16,6 +16,8 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +//! Test utilities. + use parking_lot::Mutex; use sc_client_api::{ execution_extensions::ExecutionExtensions, BlockBackend, BlockImportNotification, @@ -36,6 +38,7 @@ use sp_version::RuntimeVersion; use std::sync::Arc; use substrate_test_runtime::{Block, Hash, Header, H256}; +/// A mock client used for testing. pub struct ChainHeadMockClient { client: Arc, import_sinks: Mutex>>>, @@ -44,6 +47,7 @@ pub struct ChainHeadMockClient { } impl ChainHeadMockClient { + /// Create a new mock client. pub fn new(client: Arc) -> Self { ChainHeadMockClient { client, @@ -53,6 +57,7 @@ impl ChainHeadMockClient { } } + /// Trigger the import stram from a header. pub async fn trigger_import_stream(&self, header: Header) { // Ensure the client called the `import_notification_stream`. while self.import_sinks.lock().is_empty() { @@ -69,6 +74,7 @@ impl ChainHeadMockClient { } } + /// Trigger the import stram from a header and a list of stale heads. pub async fn trigger_finality_stream(&self, header: Header, stale_heads: Vec) { // Ensure the client called the `finality_notification_stream`. while self.finality_sinks.lock().is_empty() { diff --git a/substrate/frame/babe/src/tests.rs b/substrate/frame/babe/src/tests.rs index 5210d9289bcdb..bfcd3540ae3ef 100644 --- a/substrate/frame/babe/src/tests.rs +++ b/substrate/frame/babe/src/tests.rs @@ -35,6 +35,12 @@ const EMPTY_RANDOMNESS: [u8; RANDOMNESS_LENGTH] = [ 161, 164, 127, 217, 153, 138, 37, 48, 192, 248, 0, ]; +impl crate::migrations::BabePalletPrefix for Test { + fn pallet_prefix() -> &'static str { + "Babe" + } +} + #[test] fn empty_randomness_is_correct() { let s = compute_randomness([0; RANDOMNESS_LENGTH], 0, std::iter::empty(), None); @@ -943,12 +949,6 @@ fn valid_equivocation_reports_dont_pay_fees() { fn add_epoch_configurations_migration_works() { use frame_support::storage::migration::{get_storage_value, put_storage_value}; - impl crate::migrations::BabePalletPrefix for Test { - fn pallet_prefix() -> &'static str { - "Babe" - } - } - new_test_ext(1).execute_with(|| { let next_config_descriptor = NextConfigDescriptor::V1 { c: (3, 4), allowed_slots: AllowedSlots::PrimarySlots }; diff --git a/substrate/frame/benchmarking/src/tests_instance.rs b/substrate/frame/benchmarking/src/tests_instance.rs index 428f29e2bc161..11062813e33ce 100644 --- a/substrate/frame/benchmarking/src/tests_instance.rs +++ b/substrate/frame/benchmarking/src/tests_instance.rs @@ -86,6 +86,11 @@ frame_support::construct_runtime!( } ); +crate::define_benchmarks!( + [pallet_test, TestPallet] + [pallet_test, TestPallet2] +); + #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; @@ -187,11 +192,6 @@ mod benchmarks { fn ensure_correct_instance_is_selected() { use crate::utils::Benchmarking; - crate::define_benchmarks!( - [pallet_test, TestPallet] - [pallet_test, TestPallet2] - ); - let whitelist = vec![]; let mut batches = Vec::::new(); diff --git a/substrate/frame/contracts/fixtures/contracts/crypto_hashes.rs b/substrate/frame/contracts/fixtures/contracts/crypto_hashes.rs index 35cc03f1e7237..69b1671bbe2f8 100644 --- a/substrate/frame/contracts/fixtures/contracts/crypto_hashes.rs +++ b/substrate/frame/contracts/fixtures/contracts/crypto_hashes.rs @@ -48,7 +48,6 @@ pub extern "C" fn deploy() {} /// | 2 | BLAKE2 | 256 | /// | 3 | BLAKE2 | 128 | /// --------------------------------- - #[no_mangle] #[polkavm_derive::polkavm_export] pub extern "C" fn call() { diff --git a/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs b/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs index fa64dd6f7d6eb..c0e7efc662379 100644 --- a/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs +++ b/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/lib.rs @@ -16,6 +16,9 @@ // limitations under the License. #![cfg(test)] + +// We do not declare all features used by `construct_runtime` +#[allow(unexpected_cfgs)] mod mock; pub(crate) const LOG_TARGET: &str = "tests::e2e-epm"; diff --git a/substrate/frame/lottery/Cargo.toml b/substrate/frame/lottery/Cargo.toml index 23eb19c7ffa7d..f59bd8003e310 100644 --- a/substrate/frame/lottery/Cargo.toml +++ b/substrate/frame/lottery/Cargo.toml @@ -46,6 +46,7 @@ std = [ ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", + "frame-support-test/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", "pallet-balances/runtime-benchmarks", diff --git a/substrate/frame/migrations/src/lib.rs b/substrate/frame/migrations/src/lib.rs index 5fcbc2ee62980..5f321b6c8a1b9 100644 --- a/substrate/frame/migrations/src/lib.rs +++ b/substrate/frame/migrations/src/lib.rs @@ -784,7 +784,7 @@ impl Pallet { Self::deposit_event(Event::MigrationAdvanced { index: cursor.index, took }); cursor.inner_cursor = Some(bound_next_cursor); - if max_steps.map_or(false, |max| took > max.into()) { + if max_steps.is_some_and(|max| took > max.into()) { Self::deposit_event(Event::MigrationFailed { index: cursor.index, took }); Self::upgrade_failed(Some(cursor.index)); None diff --git a/substrate/frame/node-authorization/src/lib.rs b/substrate/frame/node-authorization/src/lib.rs index 3cec0d3bcb63d..4fbb9555deeb2 100644 --- a/substrate/frame/node-authorization/src/lib.rs +++ b/substrate/frame/node-authorization/src/lib.rs @@ -38,6 +38,8 @@ #![cfg_attr(not(feature = "std"), no_std)] #[cfg(test)] +// We do not declare all features used by `construct_runtime` +#[allow(unexpected_cfgs)] mod mock; #[cfg(test)] mod tests; diff --git a/substrate/frame/nomination-pools/test-delegate-stake/src/lib.rs b/substrate/frame/nomination-pools/test-delegate-stake/src/lib.rs index b43a41cd0f980..cabffa45461df 100644 --- a/substrate/frame/nomination-pools/test-delegate-stake/src/lib.rs +++ b/substrate/frame/nomination-pools/test-delegate-stake/src/lib.rs @@ -17,6 +17,8 @@ #![cfg(test)] +// We do not declare all features used by `construct_runtime` +#[allow(unexpected_cfgs)] mod mock; use frame_support::{ diff --git a/substrate/frame/parameters/src/tests/mock.rs b/substrate/frame/parameters/src/tests/mock.rs index 8d6f7d25ceac5..b7c391f383c22 100644 --- a/substrate/frame/parameters/src/tests/mock.rs +++ b/substrate/frame/parameters/src/tests/mock.rs @@ -107,7 +107,7 @@ mod custom_origin { ) -> Result { // Account 123 is allowed to set parameters in benchmarking only: #[cfg(feature = "runtime-benchmarks")] - if ensure_signed(origin.clone()).map_or(false, |acc| acc == 123) { + if ensure_signed(origin.clone()).is_ok_and(|acc| acc == 123) { return Ok(()); } diff --git a/substrate/frame/revive/fixtures/Cargo.toml b/substrate/frame/revive/fixtures/Cargo.toml index eaa2deefdc757..ab5030b4a09b7 100644 --- a/substrate/frame/revive/fixtures/Cargo.toml +++ b/substrate/frame/revive/fixtures/Cargo.toml @@ -7,6 +7,7 @@ license.workspace = true description = "Fixtures for testing and benchmarking" homepage.workspace = true repository.workspace = true +rust-version = "1.84" [package.metadata.polkadot-sdk] exclude-from-umbrella = true diff --git a/substrate/frame/revive/fixtures/build.rs b/substrate/frame/revive/fixtures/build.rs index fe420ba40da63..38d3b6439ec0e 100644 --- a/substrate/frame/revive/fixtures/build.rs +++ b/substrate/frame/revive/fixtures/build.rs @@ -109,11 +109,6 @@ fn create_cargo_toml<'a>( let cargo_toml = toml::to_string_pretty(&cargo_toml)?; fs::write(output_dir.join("Cargo.toml"), cargo_toml.clone()) .with_context(|| format!("Failed to write {cargo_toml:?}"))?; - fs::copy( - fixtures_dir.join("build/_rust-toolchain.toml"), - output_dir.join("rust-toolchain.toml"), - ) - .context("Failed to write toolchain file")?; Ok(()) } diff --git a/substrate/frame/revive/fixtures/build/_rust-toolchain.toml b/substrate/frame/revive/fixtures/build/_rust-toolchain.toml deleted file mode 100644 index 4c757c708d58b..0000000000000 --- a/substrate/frame/revive/fixtures/build/_rust-toolchain.toml +++ /dev/null @@ -1,4 +0,0 @@ -[toolchain] -channel = "nightly-2024-11-19" -components = ["rust-src"] -profile = "minimal" diff --git a/substrate/frame/scored-pool/src/lib.rs b/substrate/frame/scored-pool/src/lib.rs index c4464bbbfac04..fcaa6950110a8 100644 --- a/substrate/frame/scored-pool/src/lib.rs +++ b/substrate/frame/scored-pool/src/lib.rs @@ -93,6 +93,8 @@ #![cfg_attr(not(feature = "std"), no_std)] #[cfg(test)] +// We do not declare all features used by `construct_runtime` +#[allow(unexpected_cfgs)] mod mock; #[cfg(test)] diff --git a/substrate/frame/society/Cargo.toml b/substrate/frame/society/Cargo.toml index d5860518fdda8..e507538640f5e 100644 --- a/substrate/frame/society/Cargo.toml +++ b/substrate/frame/society/Cargo.toml @@ -55,6 +55,7 @@ std = [ runtime-benchmarks = [ "frame-benchmarking", "frame-benchmarking/runtime-benchmarks", + "frame-support-test/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", "pallet-balances/runtime-benchmarks", diff --git a/substrate/frame/statement/src/lib.rs b/substrate/frame/statement/src/lib.rs index 6a7f577ab0869..02eef2ca1b2c6 100644 --- a/substrate/frame/statement/src/lib.rs +++ b/substrate/frame/statement/src/lib.rs @@ -45,6 +45,8 @@ use sp_statement_store::{ }; #[cfg(test)] +// We do not declare all features used by `construct_runtime` +#[allow(unexpected_cfgs)] mod mock; #[cfg(test)] mod tests; diff --git a/substrate/frame/support/src/traits/hooks.rs b/substrate/frame/support/src/traits/hooks.rs index 51209cb542467..bf54f237eb707 100644 --- a/substrate/frame/support/src/traits/hooks.rs +++ b/substrate/frame/support/src/traits/hooks.rs @@ -628,6 +628,8 @@ pub trait OnTimestampSet { #[cfg(test)] mod tests { use super::*; + use crate::parameter_types; + use alloc::vec::Vec; use sp_io::TestExternalities; #[cfg(feature = "try-runtime")] @@ -712,7 +714,9 @@ mod tests { #[test] fn on_idle_round_robin_works() { - static mut ON_IDLE_INVOCATION_ORDER: alloc::vec::Vec<&str> = alloc::vec::Vec::new(); + parameter_types! { + static OnIdleInvocationOrder: Vec<&'static str> = Vec::new(); + } struct Test1; struct Test2; @@ -720,49 +724,41 @@ mod tests { type TestTuple = (Test1, Test2, Test3); impl OnIdle for Test1 { fn on_idle(_n: u32, _weight: Weight) -> Weight { - unsafe { - ON_IDLE_INVOCATION_ORDER.push("Test1"); - } + OnIdleInvocationOrder::mutate(|o| o.push("Test1")); Weight::zero() } } impl OnIdle for Test2 { fn on_idle(_n: u32, _weight: Weight) -> Weight { - unsafe { - ON_IDLE_INVOCATION_ORDER.push("Test2"); - } + OnIdleInvocationOrder::mutate(|o| o.push("Test2")); Weight::zero() } } impl OnIdle for Test3 { fn on_idle(_n: u32, _weight: Weight) -> Weight { - unsafe { - ON_IDLE_INVOCATION_ORDER.push("Test3"); - } + OnIdleInvocationOrder::mutate(|o| o.push("Test3")); Weight::zero() } } - unsafe { - TestTuple::on_idle(0, Weight::zero()); - assert_eq!(ON_IDLE_INVOCATION_ORDER, ["Test1", "Test2", "Test3"].to_vec()); - ON_IDLE_INVOCATION_ORDER.clear(); + TestTuple::on_idle(0, Weight::zero()); + assert_eq!(OnIdleInvocationOrder::get(), ["Test1", "Test2", "Test3"].to_vec()); + OnIdleInvocationOrder::mutate(|o| o.clear()); - TestTuple::on_idle(1, Weight::zero()); - assert_eq!(ON_IDLE_INVOCATION_ORDER, ["Test2", "Test3", "Test1"].to_vec()); - ON_IDLE_INVOCATION_ORDER.clear(); + TestTuple::on_idle(1, Weight::zero()); + assert_eq!(OnIdleInvocationOrder::get(), ["Test2", "Test3", "Test1"].to_vec()); + OnIdleInvocationOrder::mutate(|o| o.clear()); - TestTuple::on_idle(2, Weight::zero()); - assert_eq!(ON_IDLE_INVOCATION_ORDER, ["Test3", "Test1", "Test2"].to_vec()); - ON_IDLE_INVOCATION_ORDER.clear(); + TestTuple::on_idle(2, Weight::zero()); + assert_eq!(OnIdleInvocationOrder::get(), ["Test3", "Test1", "Test2"].to_vec()); + OnIdleInvocationOrder::mutate(|o| o.clear()); - TestTuple::on_idle(3, Weight::zero()); - assert_eq!(ON_IDLE_INVOCATION_ORDER, ["Test1", "Test2", "Test3"].to_vec()); - ON_IDLE_INVOCATION_ORDER.clear(); + TestTuple::on_idle(3, Weight::zero()); + assert_eq!(OnIdleInvocationOrder::get(), ["Test1", "Test2", "Test3"].to_vec()); + OnIdleInvocationOrder::mutate(|o| o.clear()); - TestTuple::on_idle(4, Weight::zero()); - assert_eq!(ON_IDLE_INVOCATION_ORDER, ["Test2", "Test3", "Test1"].to_vec()); - ON_IDLE_INVOCATION_ORDER.clear(); - } + TestTuple::on_idle(4, Weight::zero()); + assert_eq!(OnIdleInvocationOrder::get(), ["Test2", "Test3", "Test1"].to_vec()); + OnIdleInvocationOrder::mutate(|o| o.clear()); } } diff --git a/substrate/frame/support/test/Cargo.toml b/substrate/frame/support/test/Cargo.toml index ca122e6bd5446..37287452f319d 100644 --- a/substrate/frame/support/test/Cargo.toml +++ b/substrate/frame/support/test/Cargo.toml @@ -60,6 +60,12 @@ std = [ "test-pallet/std", ] experimental = ["frame-support/experimental", "frame-system/experimental"] +runtime-benchmarks = [ + "frame-benchmarking/runtime-benchmarks", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", +] try-runtime = [ "frame-executive/try-runtime", "frame-support/try-runtime", diff --git a/substrate/frame/support/test/tests/benchmark_ui.rs b/substrate/frame/support/test/tests/benchmark_ui.rs index aa5fadd0e27bf..410f9e09a43a1 100644 --- a/substrate/frame/support/test/tests/benchmark_ui.rs +++ b/substrate/frame/support/test/tests/benchmark_ui.rs @@ -28,7 +28,7 @@ fn benchmark_ui() { std::env::set_var("SKIP_WASM_BUILD", "1"); // Deny all warnings since we emit warnings as part of a Pallet's UI. - std::env::set_var("RUSTFLAGS", "--deny warnings"); + std::env::set_var("CARGO_ENCODED_RUSTFLAGS", "--deny=warnings"); let t = trybuild::TestCases::new(); t.compile_fail("tests/benchmark_ui/*.rs"); diff --git a/substrate/frame/support/test/tests/benchmark_ui/invalid_origin.stderr b/substrate/frame/support/test/tests/benchmark_ui/invalid_origin.stderr index 30f1289767fc5..87d4f476a60d1 100644 --- a/substrate/frame/support/test/tests/benchmark_ui/invalid_origin.stderr +++ b/substrate/frame/support/test/tests/benchmark_ui/invalid_origin.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `::RuntimeOrigin: --> tests/benchmark_ui/invalid_origin.rs:23:1 | 23 | #[benchmarks] - | ^^^^^^^^^^^^^ the trait `From<{integer}>` is not implemented for `::RuntimeOrigin`, which is required by `{integer}: Into<_>` + | ^^^^^^^^^^^^^ the trait `From<{integer}>` is not implemented for `::RuntimeOrigin` | = note: required for `{integer}` to implement `Into<::RuntimeOrigin>` = note: this error originates in the attribute macro `benchmarks` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/substrate/frame/support/test/tests/benchmark_ui/pass/valid_const_expr.rs b/substrate/frame/support/test/tests/benchmark_ui/pass/valid_const_expr.rs index b1ef44be8b09d..e6ba5873e899d 100644 --- a/substrate/frame/support/test/tests/benchmark_ui/pass/valid_const_expr.rs +++ b/substrate/frame/support/test/tests/benchmark_ui/pass/valid_const_expr.rs @@ -25,6 +25,7 @@ mod benches { const MY_CONST: u32 = 100; + #[allow(dead_code)] const fn my_fn() -> u32 { 200 } diff --git a/substrate/frame/support/test/tests/construct_runtime_ui.rs b/substrate/frame/support/test/tests/construct_runtime_ui.rs index 0cf857e2d73c0..3ff60a60c611c 100644 --- a/substrate/frame/support/test/tests/construct_runtime_ui.rs +++ b/substrate/frame/support/test/tests/construct_runtime_ui.rs @@ -28,7 +28,7 @@ fn ui() { std::env::set_var("SKIP_WASM_BUILD", "1"); // Deny all warnings since we emit warnings as part of a Runtime's UI. - std::env::set_var("RUSTFLAGS", "--deny warnings"); + std::env::set_var("CARGO_ENCODED_RUSTFLAGS", "--deny=warnings"); let t = trybuild::TestCases::new(); t.compile_fail("tests/construct_runtime_ui/*.rs"); diff --git a/substrate/frame/support/test/tests/construct_runtime_ui/deprecated_where_block.stderr b/substrate/frame/support/test/tests/construct_runtime_ui/deprecated_where_block.stderr index 3b0bf05bd4e72..b468b8647ca19 100644 --- a/substrate/frame/support/test/tests/construct_runtime_ui/deprecated_where_block.stderr +++ b/substrate/frame/support/test/tests/construct_runtime_ui/deprecated_where_block.stderr @@ -86,7 +86,7 @@ error[E0277]: the trait bound `Runtime: Config` is not satisfied ... | 27 | | } 28 | | } - | |_^ the trait `Config` is not implemented for `Runtime`, which is required by `Pallet: Callable` + | |_^ the trait `Config` is not implemented for `Runtime` | = help: the trait `Callable` is implemented for `Pallet` = note: required for `Pallet` to implement `Callable` @@ -237,7 +237,7 @@ error[E0277]: the trait bound `Runtime: Config` is not satisfied ... | 27 | | } 28 | | } - | |_^ the trait `Config` is not implemented for `Runtime`, which is required by `&frame_system::Event: std::fmt::Debug` + | |_^ the trait `Config` is not implemented for `Runtime` | = help: the trait `std::fmt::Debug` is implemented for `frame_system::Event` = note: required for `frame_system::Event` to implement `std::fmt::Debug` @@ -256,7 +256,7 @@ error[E0277]: the trait bound `Runtime: Config` is not satisfied ... | 27 | | } 28 | | } - | |_^ the trait `Config` is not implemented for `Runtime`, which is required by `&frame_system::Error: std::fmt::Debug` + | |_^ the trait `Config` is not implemented for `Runtime` | = help: the trait `std::fmt::Debug` is implemented for `frame_system::Error` = note: required for `frame_system::Error` to implement `std::fmt::Debug` @@ -295,7 +295,7 @@ error[E0277]: the trait bound `Runtime: Config` is not satisfied ... | 27 | | } 28 | | } - | |_^ the trait `Config` is not implemented for `Runtime`, which is required by `RawOrigin<_>: Into<_>` + | |_^ the trait `Config` is not implemented for `Runtime` | = note: required for `RawOrigin<_>` to implement `Into` = note: this error originates in the macro `frame_support::construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -344,7 +344,7 @@ error[E0277]: the trait bound `Runtime: Config` is not satisfied ... | 27 | | } 28 | | } - | |_^ the trait `Config` is not implemented for `Runtime`, which is required by `Pallet: PalletInfoAccess` + | |_^ the trait `Config` is not implemented for `Runtime` | = help: the trait `PalletInfoAccess` is implemented for `Pallet` = note: required for `Pallet` to implement `PalletInfoAccess` @@ -360,7 +360,7 @@ error[E0277]: the trait bound `Runtime: Config` is not satisfied ... | 27 | | } 28 | | } - | |_^ the trait `Config` is not implemented for `Runtime`, which is required by `Pallet: Callable` + | |_^ the trait `Config` is not implemented for `Runtime` | = help: the trait `Callable` is implemented for `Pallet` = note: required for `Pallet` to implement `Callable` @@ -376,7 +376,7 @@ error[E0277]: the trait bound `Runtime: Config` is not satisfied ... | 27 | | } 28 | | } - | |_^ the trait `Config` is not implemented for `Runtime`, which is required by `Pallet: Callable` + | |_^ the trait `Config` is not implemented for `Runtime` | = help: the trait `Callable` is implemented for `Pallet` = note: required for `Pallet` to implement `Callable` @@ -466,7 +466,7 @@ error[E0277]: the trait bound `Runtime: Config` is not satisfied ... | 27 | | } 28 | | } - | |_^ the trait `Config` is not implemented for `Runtime`, which is required by `Pallet: Callable` + | |_^ the trait `Config` is not implemented for `Runtime` | = help: the trait `Callable` is implemented for `Pallet` = note: required for `Pallet` to implement `Callable` @@ -569,7 +569,7 @@ error[E0277]: the trait bound `Runtime: Config` is not satisfied --> tests/construct_runtime_ui/deprecated_where_block.rs:26:3 | 26 | System: frame_system::{Pallet, Call, Storage, Config, Event}, - | ^^^^^^ the trait `Config` is not implemented for `Runtime`, which is required by `Pallet: ViewFunctionIdPrefix` + | ^^^^^^ the trait `Config` is not implemented for `Runtime` | = help: the trait `ViewFunctionIdPrefix` is implemented for `Pallet` = note: required for `Pallet` to implement `ViewFunctionIdPrefix` @@ -784,7 +784,7 @@ error[E0277]: the trait bound `Runtime: Config` is not satisfied ... | 27 | | } 28 | | } - | |_^ the trait `Config` is not implemented for `Runtime`, which is required by `GenesisConfig: Serialize` + | |_^ the trait `Config` is not implemented for `Runtime` | = help: the trait `Serialize` is implemented for `GenesisConfig` = note: required for `GenesisConfig` to implement `Serialize` @@ -846,10 +846,13 @@ error[E0277]: the trait bound `Runtime: Config` is not satisfied ... | 27 | | } 28 | | } - | |_^ the trait `Config` is not implemented for `Runtime`, which is required by `GenesisConfig: std::default::Default` + | |_^ the trait `Config` is not implemented for `Runtime` + | +note: required by a bound in `GenesisConfig` + --> $WORKSPACE/substrate/frame/system/src/lib.rs | - = help: the trait `std::default::Default` is implemented for `GenesisConfig` - = note: required for `GenesisConfig` to implement `std::default::Default` + | pub struct GenesisConfig { + | ^^^^^^ required by this bound in `GenesisConfig` = note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `Runtime: Config` is not satisfied @@ -862,7 +865,7 @@ error[E0277]: the trait bound `Runtime: Config` is not satisfied ... | 27 | | } 28 | | } - | |_^ the trait `Config` is not implemented for `Runtime`, which is required by `(Pallet,): OnGenesis` + | |_^ the trait `Config` is not implemented for `Runtime` | = help: the following other types implement trait `OnGenesis`: () diff --git a/substrate/frame/support/test/tests/derive_impl_ui.rs b/substrate/frame/support/test/tests/derive_impl_ui.rs index ee219d0670aaf..84c010187b82e 100644 --- a/substrate/frame/support/test/tests/derive_impl_ui.rs +++ b/substrate/frame/support/test/tests/derive_impl_ui.rs @@ -30,7 +30,7 @@ fn derive_impl_ui() { std::env::set_var("SKIP_WASM_BUILD", "1"); // Deny all warnings since we emit warnings as part of a Pallet's UI. - std::env::set_var("RUSTFLAGS", "--deny warnings"); + std::env::set_var("CARGO_ENCODED_RUSTFLAGS", "--deny=warnings"); let t = trybuild::TestCases::new(); t.compile_fail("tests/derive_impl_ui/*.rs"); diff --git a/substrate/frame/support/test/tests/derive_no_bound_ui.rs b/substrate/frame/support/test/tests/derive_no_bound_ui.rs index b1c9283c0925a..11f61f6329b3c 100644 --- a/substrate/frame/support/test/tests/derive_no_bound_ui.rs +++ b/substrate/frame/support/test/tests/derive_no_bound_ui.rs @@ -27,6 +27,9 @@ fn derive_no_bound_ui() { // As trybuild is using `cargo check`, we don't need the real WASM binaries. std::env::set_var("SKIP_WASM_BUILD", "1"); + // Deny all warnings since we emit warnings as part of a Pallet's UI. + std::env::set_var("CARGO_ENCODED_RUSTFLAGS", "--deny=warnings"); + let t = trybuild::TestCases::new(); t.compile_fail("tests/derive_no_bound_ui/*.rs"); } diff --git a/substrate/frame/support/test/tests/pallet_ui.rs b/substrate/frame/support/test/tests/pallet_ui.rs index 466957c9faa63..c92b07b829d5d 100644 --- a/substrate/frame/support/test/tests/pallet_ui.rs +++ b/substrate/frame/support/test/tests/pallet_ui.rs @@ -28,7 +28,7 @@ fn pallet_ui() { std::env::set_var("SKIP_WASM_BUILD", "1"); // Deny all warnings since we emit warnings as part of a Pallet's UI. - std::env::set_var("RUSTFLAGS", "--deny warnings"); + std::env::set_var("CARGO_ENCODED_RUSTFLAGS", "--deny=warnings"); let t = trybuild::TestCases::new(); t.compile_fail("tests/pallet_ui/*.rs"); diff --git a/substrate/frame/support/test/tests/pallet_ui/call_argument_invalid_bound.stderr b/substrate/frame/support/test/tests/pallet_ui/call_argument_invalid_bound.stderr index 1f91f77402386..883740ea92457 100644 --- a/substrate/frame/support/test/tests/pallet_ui/call_argument_invalid_bound.stderr +++ b/substrate/frame/support/test/tests/pallet_ui/call_argument_invalid_bound.stderr @@ -18,7 +18,7 @@ error[E0277]: `::Bar` doesn't implement `std::fmt::Debug` 38 | pub fn foo(origin: OriginFor, _bar: T::Bar) -> DispatchResultWithPostInfo { | ^^^^ `::Bar` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug` | - = help: the trait `std::fmt::Debug` is not implemented for `::Bar`, which is required by `&::Bar: std::fmt::Debug` + = help: the trait `std::fmt::Debug` is not implemented for `::Bar` = note: required for `&::Bar` to implement `std::fmt::Debug` = note: required for the cast from `&&::Bar` to `&dyn std::fmt::Debug` diff --git a/substrate/frame/support/test/tests/pallet_ui/call_argument_invalid_bound_2.stderr b/substrate/frame/support/test/tests/pallet_ui/call_argument_invalid_bound_2.stderr index 4657c0a0c601f..999f9fea87251 100644 --- a/substrate/frame/support/test/tests/pallet_ui/call_argument_invalid_bound_2.stderr +++ b/substrate/frame/support/test/tests/pallet_ui/call_argument_invalid_bound_2.stderr @@ -18,7 +18,7 @@ error[E0277]: `::Bar` doesn't implement `std::fmt::Debug` 38 | pub fn foo(origin: OriginFor, _bar: T::Bar) -> DispatchResultWithPostInfo { | ^^^^ `::Bar` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug` | - = help: the trait `std::fmt::Debug` is not implemented for `::Bar`, which is required by `&::Bar: std::fmt::Debug` + = help: the trait `std::fmt::Debug` is not implemented for `::Bar` = note: required for `&::Bar` to implement `std::fmt::Debug` = note: required for the cast from `&&::Bar` to `&dyn std::fmt::Debug` @@ -41,7 +41,7 @@ error[E0277]: the trait bound `::Bar: Encode` is not satisf | ------------------------ required by a bound introduced by this call ... 38 | pub fn foo(origin: OriginFor, _bar: T::Bar) -> DispatchResultWithPostInfo { - | ^^^^ the trait `WrapperTypeEncode` is not implemented for `::Bar`, which is required by `::Bar: Encode` + | ^^^^ the trait `WrapperTypeEncode` is not implemented for `::Bar` | = note: required for `::Bar` to implement `Encode` @@ -49,7 +49,7 @@ error[E0277]: the trait bound `::Bar: Decode` is not satisf --> tests/pallet_ui/call_argument_invalid_bound_2.rs:38:42 | 38 | pub fn foo(origin: OriginFor, _bar: T::Bar) -> DispatchResultWithPostInfo { - | ^^^^^^ the trait `WrapperTypeDecode` is not implemented for `::Bar`, which is required by `::Bar: Decode` + | ^^^^^^ the trait `WrapperTypeDecode` is not implemented for `::Bar` | = note: required for `::Bar` to implement `Decode` diff --git a/substrate/frame/support/test/tests/pallet_ui/call_argument_invalid_bound_3.stderr b/substrate/frame/support/test/tests/pallet_ui/call_argument_invalid_bound_3.stderr index f829baeb4c112..f342433149837 100644 --- a/substrate/frame/support/test/tests/pallet_ui/call_argument_invalid_bound_3.stderr +++ b/substrate/frame/support/test/tests/pallet_ui/call_argument_invalid_bound_3.stderr @@ -18,7 +18,7 @@ error[E0277]: `Bar` doesn't implement `std::fmt::Debug` 40 | pub fn foo(origin: OriginFor, _bar: Bar) -> DispatchResultWithPostInfo { | ^^^^ `Bar` cannot be formatted using `{:?}` | - = help: the trait `std::fmt::Debug` is not implemented for `Bar`, which is required by `&Bar: std::fmt::Debug` + = help: the trait `std::fmt::Debug` is not implemented for `Bar` = note: add `#[derive(Debug)]` to `Bar` or manually `impl std::fmt::Debug for Bar` = note: required for `&Bar` to implement `std::fmt::Debug` = note: required for the cast from `&&Bar` to `&dyn std::fmt::Debug` diff --git a/substrate/frame/support/test/tests/pallet_ui/call_missing_index.stderr b/substrate/frame/support/test/tests/pallet_ui/call_missing_index.stderr index ba06285bdeeab..cace73a333c5a 100644 --- a/substrate/frame/support/test/tests/pallet_ui/call_missing_index.stderr +++ b/substrate/frame/support/test/tests/pallet_ui/call_missing_index.stderr @@ -46,3 +46,24 @@ error: use of deprecated constant `pallet::warnings::ConstantWeight_1::_w`: | 36 | #[pallet::weight(0)] | ^ + +error: associated function `error_metadata` is never used + --> tests/pallet_ui/call_missing_index.rs:26:12 + | +26 | #[pallet::pallet] + | ^^^^^^ associated function in this implementation + | + = note: `-D dead-code` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(dead_code)]` + +error: associated functions `new_call_variant_foo` and `new_call_variant_bar` are never used + --> tests/pallet_ui/call_missing_index.rs:32:10 + | +29 | #[pallet::call] + | ---- associated functions in this implementation +... +32 | pub fn foo(_: OriginFor) -> DispatchResult { + | ^^^ +... +37 | pub fn bar(_: OriginFor) -> DispatchResult { + | ^^^ diff --git a/substrate/frame/support/test/tests/pallet_ui/call_weight_const_warning.stderr b/substrate/frame/support/test/tests/pallet_ui/call_weight_const_warning.stderr index d399df4d85bd4..553ae08cefdd1 100644 --- a/substrate/frame/support/test/tests/pallet_ui/call_weight_const_warning.stderr +++ b/substrate/frame/support/test/tests/pallet_ui/call_weight_const_warning.stderr @@ -11,3 +11,21 @@ error: use of deprecated constant `pallet::warnings::ConstantWeight_0::_w`: | = note: `-D deprecated` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(deprecated)]` + +error: associated function `error_metadata` is never used + --> tests/pallet_ui/call_weight_const_warning.rs:26:12 + | +26 | #[pallet::pallet] + | ^^^^^^ associated function in this implementation + | + = note: `-D dead-code` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(dead_code)]` + +error: associated function `new_call_variant_foo` is never used + --> tests/pallet_ui/call_weight_const_warning.rs:33:10 + | +29 | #[pallet::call] + | ---- associated function in this implementation +... +33 | pub fn foo(_: OriginFor) -> DispatchResult { Ok(()) } + | ^^^ diff --git a/substrate/frame/support/test/tests/pallet_ui/call_weight_unchecked_warning.stderr b/substrate/frame/support/test/tests/pallet_ui/call_weight_unchecked_warning.stderr index 33302a2a0278a..fca5f657c67b7 100644 --- a/substrate/frame/support/test/tests/pallet_ui/call_weight_unchecked_warning.stderr +++ b/substrate/frame/support/test/tests/pallet_ui/call_weight_unchecked_warning.stderr @@ -11,3 +11,21 @@ error: use of deprecated constant `pallet::warnings::UncheckedWeightWitness_0::_ | = note: `-D deprecated` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(deprecated)]` + +error: associated function `error_metadata` is never used + --> tests/pallet_ui/call_weight_unchecked_warning.rs:26:12 + | +26 | #[pallet::pallet] + | ^^^^^^ associated function in this implementation + | + = note: `-D dead-code` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(dead_code)]` + +error: associated function `new_call_variant_foo` is never used + --> tests/pallet_ui/call_weight_unchecked_warning.rs:33:10 + | +29 | #[pallet::call] + | ---- associated function in this implementation +... +33 | pub fn foo(_: OriginFor, _unused: u64) -> DispatchResult { Ok(()) } + | ^^^ diff --git a/substrate/frame/support/test/tests/pallet_ui/dev_mode_without_arg_max_encoded_len.stderr b/substrate/frame/support/test/tests/pallet_ui/dev_mode_without_arg_max_encoded_len.stderr index 2fcc332821408..d36a9a453c57c 100644 --- a/substrate/frame/support/test/tests/pallet_ui/dev_mode_without_arg_max_encoded_len.stderr +++ b/substrate/frame/support/test/tests/pallet_ui/dev_mode_without_arg_max_encoded_len.stderr @@ -35,7 +35,7 @@ error[E0277]: the trait bound `Vec: MaxEncodedLen` is not satisfied ... | 35 | | #[pallet::storage] 36 | | type MyStorage = StorageValue<_, Vec>; - | |__________________^ the trait `MaxEncodedLen` is not implemented for `Vec`, which is required by `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageMyStorage, Vec>: StorageInfoTrait` + | |__________________^ the trait `MaxEncodedLen` is not implemented for `Vec` | = help: the following other types implement trait `MaxEncodedLen`: () diff --git a/substrate/frame/support/test/tests/pallet_ui/event_field_not_member.stderr b/substrate/frame/support/test/tests/pallet_ui/event_field_not_member.stderr index e9c2eae686baf..44660d2690603 100644 --- a/substrate/frame/support/test/tests/pallet_ui/event_field_not_member.stderr +++ b/substrate/frame/support/test/tests/pallet_ui/event_field_not_member.stderr @@ -16,6 +16,6 @@ error[E0277]: `::Bar` doesn't implement `std::fmt::Debug` 41 | B { b: T::Bar }, | ^ `::Bar` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug` | - = help: the trait `std::fmt::Debug` is not implemented for `::Bar`, which is required by `&::Bar: std::fmt::Debug` + = help: the trait `std::fmt::Debug` is not implemented for `::Bar` = note: required for `&::Bar` to implement `std::fmt::Debug` = note: required for the cast from `&&::Bar` to `&dyn std::fmt::Debug` diff --git a/substrate/frame/support/test/tests/pallet_ui/hooks_invalid_item.stderr b/substrate/frame/support/test/tests/pallet_ui/hooks_invalid_item.stderr index c04499dbbd144..5c37e99fac220 100644 --- a/substrate/frame/support/test/tests/pallet_ui/hooks_invalid_item.stderr +++ b/substrate/frame/support/test/tests/pallet_ui/hooks_invalid_item.stderr @@ -18,4 +18,6 @@ error[E0277]: the trait bound `pallet::Pallet: Hooks<<< tests/pallet_ui/hooks_invalid_item.rs:28:12 | 28 | #[pallet::hooks] - | ^^^^^ the trait `Hooks<<<::Block as frame_support::sp_runtime::traits::Block>::Header as frame_support::sp_runtime::traits::Header>::Number>` is not implemented for `pallet::Pallet` + | ^^^^^ unsatisfied trait bound + | + = help: the trait `Hooks<<<::Block as frame_support::sp_runtime::traits::Block>::Header as frame_support::sp_runtime::traits::Header>::Number>` is not implemented for `pallet::Pallet` diff --git a/substrate/frame/support/test/tests/pallet_ui/pass/config_multiple_attr.rs b/substrate/frame/support/test/tests/pallet_ui/pass/config_multiple_attr.rs index c016c52181cf9..e7af18be00e08 100644 --- a/substrate/frame/support/test/tests/pallet_ui/pass/config_multiple_attr.rs +++ b/substrate/frame/support/test/tests/pallet_ui/pass/config_multiple_attr.rs @@ -16,7 +16,7 @@ // limitations under the License. #[frame_support::pallet] -mod pallet { +pub mod pallet { use frame_support::pallet_prelude::*; #[pallet::config(with_default, without_automatic_metadata)] diff --git a/substrate/frame/support/test/tests/pallet_ui/pass/config_without_metadata.rs b/substrate/frame/support/test/tests/pallet_ui/pass/config_without_metadata.rs index c9f5244d73452..734c31431efb8 100644 --- a/substrate/frame/support/test/tests/pallet_ui/pass/config_without_metadata.rs +++ b/substrate/frame/support/test/tests/pallet_ui/pass/config_without_metadata.rs @@ -16,7 +16,7 @@ // limitations under the License. #[frame_support::pallet] -mod pallet { +pub mod pallet { use frame_support::pallet_prelude::*; #[pallet::config(without_automatic_metadata)] diff --git a/substrate/frame/support/test/tests/pallet_ui/pass/default_config.rs b/substrate/frame/support/test/tests/pallet_ui/pass/default_config.rs index f169ee34c9ab5..0d1e92e4be986 100644 --- a/substrate/frame/support/test/tests/pallet_ui/pass/default_config.rs +++ b/substrate/frame/support/test/tests/pallet_ui/pass/default_config.rs @@ -16,7 +16,7 @@ // limitations under the License. #[frame_support::pallet] -mod pallet { +pub mod pallet { use frame_support::pallet_prelude::*; #[pallet::config(with_default)] diff --git a/substrate/frame/support/test/tests/pallet_ui/pass/error_nested_types.rs b/substrate/frame/support/test/tests/pallet_ui/pass/error_nested_types.rs index 0e0dc5890519f..b4c18920f7b54 100644 --- a/substrate/frame/support/test/tests/pallet_ui/pass/error_nested_types.rs +++ b/substrate/frame/support/test/tests/pallet_ui/pass/error_nested_types.rs @@ -20,7 +20,7 @@ use frame_support::PalletError; #[frame_support::pallet] #[allow(unused_imports)] -mod pallet { +pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config {} diff --git a/substrate/frame/support/test/tests/pallet_ui/pass/event_type_bound_system_config_assoc_type.rs b/substrate/frame/support/test/tests/pallet_ui/pass/event_type_bound_system_config_assoc_type.rs index d84d320b0b24a..f028dd20de869 100644 --- a/substrate/frame/support/test/tests/pallet_ui/pass/event_type_bound_system_config_assoc_type.rs +++ b/substrate/frame/support/test/tests/pallet_ui/pass/event_type_bound_system_config_assoc_type.rs @@ -17,7 +17,7 @@ #[frame_support::pallet] #[allow(unused_imports)] -mod pallet { +pub mod pallet { use frame_support::pallet_prelude::{Hooks, IsType}; use frame_system::pallet_prelude::BlockNumberFor; diff --git a/substrate/frame/support/test/tests/pallet_ui/pass/feeless_call.rs b/substrate/frame/support/test/tests/pallet_ui/pass/feeless_call.rs index 566b7c65cc710..9028d46c9ef9b 100644 --- a/substrate/frame/support/test/tests/pallet_ui/pass/feeless_call.rs +++ b/substrate/frame/support/test/tests/pallet_ui/pass/feeless_call.rs @@ -16,7 +16,7 @@ // limitations under the License. #[frame_support::pallet(dev_mode)] -mod pallet { +pub mod pallet { use frame_support::pallet_prelude::DispatchResult; use frame_system::pallet_prelude::OriginFor; diff --git a/substrate/frame/support/test/tests/pallet_ui/pass/inherited_call_weight.rs b/substrate/frame/support/test/tests/pallet_ui/pass/inherited_call_weight.rs index fdb9d8c401d1d..d37a6da12bd1f 100644 --- a/substrate/frame/support/test/tests/pallet_ui/pass/inherited_call_weight.rs +++ b/substrate/frame/support/test/tests/pallet_ui/pass/inherited_call_weight.rs @@ -23,7 +23,7 @@ pub trait WeightInfo { } #[frame_support::pallet] -mod parentheses { +pub mod parentheses { use super::*; #[pallet::config] @@ -44,7 +44,7 @@ mod parentheses { } #[frame_support::pallet] -mod assign { +pub mod assign { use super::*; #[pallet::config] diff --git a/substrate/frame/support/test/tests/pallet_ui/pass/inherited_call_weight2.rs b/substrate/frame/support/test/tests/pallet_ui/pass/inherited_call_weight2.rs index 208c719cdfc81..8a569bc96e2fe 100644 --- a/substrate/frame/support/test/tests/pallet_ui/pass/inherited_call_weight2.rs +++ b/substrate/frame/support/test/tests/pallet_ui/pass/inherited_call_weight2.rs @@ -29,7 +29,7 @@ impl WeightInfo for () { } #[frame_support::pallet] -mod parentheses { +pub mod parentheses { use super::*; #[pallet::config] @@ -50,7 +50,7 @@ mod parentheses { } #[frame_support::pallet] -mod assign { +pub mod assign { use super::*; #[pallet::config] diff --git a/substrate/frame/support/test/tests/pallet_ui/pass/inherited_call_weight3.rs b/substrate/frame/support/test/tests/pallet_ui/pass/inherited_call_weight3.rs index ddccd0b3e192c..574b7cceb43f7 100644 --- a/substrate/frame/support/test/tests/pallet_ui/pass/inherited_call_weight3.rs +++ b/substrate/frame/support/test/tests/pallet_ui/pass/inherited_call_weight3.rs @@ -19,16 +19,16 @@ use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; // If, for whatever reason, you don't to not use a `WeightInfo` trait - it will still work. -struct Impl; +pub struct Impl; impl Impl { - fn foo() -> Weight { + pub fn foo() -> Weight { Weight::zero() } } #[frame_support::pallet] -mod parentheses { +pub mod parentheses { use super::*; #[pallet::config] @@ -48,7 +48,7 @@ mod parentheses { } #[frame_support::pallet] -mod assign { +pub mod assign { use super::*; #[pallet::config] diff --git a/substrate/frame/support/test/tests/pallet_ui/pass/inherited_call_weight_dev_mode.rs b/substrate/frame/support/test/tests/pallet_ui/pass/inherited_call_weight_dev_mode.rs index a78c9d8f36ebf..6512a3c684815 100644 --- a/substrate/frame/support/test/tests/pallet_ui/pass/inherited_call_weight_dev_mode.rs +++ b/substrate/frame/support/test/tests/pallet_ui/pass/inherited_call_weight_dev_mode.rs @@ -23,7 +23,7 @@ pub trait WeightInfo { } #[frame_support::pallet(dev_mode)] -mod pallet { +pub mod pallet { use super::*; #[pallet::config] diff --git a/substrate/frame/support/test/tests/pallet_ui/pass/simple_storage.rs b/substrate/frame/support/test/tests/pallet_ui/pass/simple_storage.rs index 13ed3b2306fa0..00f26e64b1c72 100644 --- a/substrate/frame/support/test/tests/pallet_ui/pass/simple_storage.rs +++ b/substrate/frame/support/test/tests/pallet_ui/pass/simple_storage.rs @@ -16,7 +16,7 @@ // limitations under the License. #[frame_support::pallet] -mod pallet { +pub mod pallet { use frame_support::pallet_prelude::*; #[pallet::config(with_default)] diff --git a/substrate/frame/support/test/tests/pallet_ui/pass/task_valid.rs b/substrate/frame/support/test/tests/pallet_ui/pass/task_valid.rs index bc66c09de7e80..4cc2cfe700bea 100644 --- a/substrate/frame/support/test/tests/pallet_ui/pass/task_valid.rs +++ b/substrate/frame/support/test/tests/pallet_ui/pass/task_valid.rs @@ -16,7 +16,7 @@ // limitations under the License. #[frame_support::pallet(dev_mode)] -mod pallet { +pub mod pallet { use frame_support::{ensure, pallet_prelude::DispatchResult}; #[pallet::config] @@ -40,7 +40,7 @@ mod pallet { } #[frame_support::pallet(dev_mode)] -mod pallet_with_instance { +pub mod pallet_with_instance { use frame_support::pallet_prelude::{ValueQuery, StorageValue}; #[pallet::config] diff --git a/substrate/frame/support/test/tests/pallet_ui/pass/trait_constant_valid_bounds.rs b/substrate/frame/support/test/tests/pallet_ui/pass/trait_constant_valid_bounds.rs index 83b323e3abafd..9fbce7fcafc0c 100644 --- a/substrate/frame/support/test/tests/pallet_ui/pass/trait_constant_valid_bounds.rs +++ b/substrate/frame/support/test/tests/pallet_ui/pass/trait_constant_valid_bounds.rs @@ -16,7 +16,7 @@ // limitations under the License. #[frame_support::pallet] -mod pallet { +pub mod pallet { use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::BlockNumberFor; diff --git a/substrate/frame/support/test/tests/pallet_ui/pass/view_function_valid.rs b/substrate/frame/support/test/tests/pallet_ui/pass/view_function_valid.rs index a4c3a6eb9baf5..18392d4c316a5 100644 --- a/substrate/frame/support/test/tests/pallet_ui/pass/view_function_valid.rs +++ b/substrate/frame/support/test/tests/pallet_ui/pass/view_function_valid.rs @@ -16,7 +16,7 @@ // limitations under the License. #[frame_support::pallet] -mod pallet { +pub mod pallet { use frame_support::pallet_prelude::*; #[pallet::config(with_default)] diff --git a/substrate/frame/support/test/tests/pallet_ui/pass/where_clause_missing_hooks.rs b/substrate/frame/support/test/tests/pallet_ui/pass/where_clause_missing_hooks.rs index 560ebbb868708..688fcef3c93fa 100644 --- a/substrate/frame/support/test/tests/pallet_ui/pass/where_clause_missing_hooks.rs +++ b/substrate/frame/support/test/tests/pallet_ui/pass/where_clause_missing_hooks.rs @@ -16,7 +16,7 @@ // limitations under the License. #[frame_support::pallet] -mod pallet { +pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config where @@ -34,7 +34,7 @@ mod pallet { where ::Nonce: From, { - fn foo(x: u128) { + pub fn foo(x: u128) { let _index = ::Nonce::from(x); } } diff --git a/substrate/frame/support/test/tests/pallet_ui/storage_ensure_span_are_ok_on_wrong_gen.stderr b/substrate/frame/support/test/tests/pallet_ui/storage_ensure_span_are_ok_on_wrong_gen.stderr index 641cdef1cc087..fee09c8011ba2 100644 --- a/substrate/frame/support/test/tests/pallet_ui/storage_ensure_span_are_ok_on_wrong_gen.stderr +++ b/substrate/frame/support/test/tests/pallet_ui/storage_ensure_span_are_ok_on_wrong_gen.stderr @@ -9,7 +9,7 @@ error[E0277]: the trait bound `Bar: WrapperTypeDecode` is not satisfied ... | 38 | | #[pallet::storage] 39 | | type Foo = StorageValue; - | |____________^ the trait `WrapperTypeDecode` is not implemented for `Bar`, which is required by `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo, Bar>: PartialStorageInfoTrait` + | |____________^ the trait `WrapperTypeDecode` is not implemented for `Bar` | = help: the following other types implement trait `WrapperTypeDecode`: Arc @@ -31,7 +31,7 @@ error[E0277]: the trait bound `Bar: EncodeLike` is not satisfied ... | 38 | | #[pallet::storage] 39 | | type Foo = StorageValue; - | |____________^ the trait `EncodeLike` is not implemented for `Bar`, which is required by `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo, Bar>: PartialStorageInfoTrait` + | |____________^ the trait `EncodeLike` is not implemented for `Bar` | = help: the following other types implement trait `EncodeLike`: `&&T` implements `EncodeLike` @@ -58,7 +58,7 @@ error[E0277]: the trait bound `Bar: WrapperTypeEncode` is not satisfied ... | 38 | | #[pallet::storage] 39 | | type Foo = StorageValue; - | |____________^ the trait `WrapperTypeEncode` is not implemented for `Bar`, which is required by `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo, Bar>: PartialStorageInfoTrait` + | |____________^ the trait `WrapperTypeEncode` is not implemented for `Bar` | = help: the following other types implement trait `WrapperTypeEncode`: &T @@ -81,7 +81,7 @@ error[E0277]: the trait bound `Bar: TypeInfo` is not satisfied 38 | #[pallet::storage] | _______________^ 39 | | type Foo = StorageValue; - | |____________^ the trait `TypeInfo` is not implemented for `Bar`, which is required by `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo, Bar>: StorageEntryMetadataBuilder` + | |____________^ the trait `TypeInfo` is not implemented for `Bar` | = help: the following other types implement trait `TypeInfo`: &T @@ -102,7 +102,7 @@ error[E0277]: the trait bound `Bar: WrapperTypeDecode` is not satisfied 38 | #[pallet::storage] | _______________^ 39 | | type Foo = StorageValue; - | |____________^ the trait `WrapperTypeDecode` is not implemented for `Bar`, which is required by `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo, Bar>: StorageEntryMetadataBuilder` + | |____________^ the trait `WrapperTypeDecode` is not implemented for `Bar` | = help: the following other types implement trait `WrapperTypeDecode`: Arc @@ -119,7 +119,7 @@ error[E0277]: the trait bound `Bar: EncodeLike` is not satisfied 38 | #[pallet::storage] | _______________^ 39 | | type Foo = StorageValue; - | |____________^ the trait `EncodeLike` is not implemented for `Bar`, which is required by `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo, Bar>: StorageEntryMetadataBuilder` + | |____________^ the trait `EncodeLike` is not implemented for `Bar` | = help: the following other types implement trait `EncodeLike`: `&&T` implements `EncodeLike` @@ -141,7 +141,7 @@ error[E0277]: the trait bound `Bar: WrapperTypeEncode` is not satisfied 38 | #[pallet::storage] | _______________^ 39 | | type Foo = StorageValue; - | |____________^ the trait `WrapperTypeEncode` is not implemented for `Bar`, which is required by `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo, Bar>: StorageEntryMetadataBuilder` + | |____________^ the trait `WrapperTypeEncode` is not implemented for `Bar` | = help: the following other types implement trait `WrapperTypeEncode`: &T @@ -164,7 +164,7 @@ error[E0277]: the trait bound `Bar: WrapperTypeDecode` is not satisfied 38 | #[pallet::storage] | _______________^ 39 | | type Foo = StorageValue; - | |____________^ the trait `WrapperTypeDecode` is not implemented for `Bar`, which is required by `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo, Bar>: TryDecodeEntireStorage` + | |____________^ the trait `WrapperTypeDecode` is not implemented for `Bar` | = help: the following other types implement trait `WrapperTypeDecode`: Arc @@ -181,7 +181,7 @@ error[E0277]: the trait bound `Bar: EncodeLike` is not satisfied 38 | #[pallet::storage] | _______________^ 39 | | type Foo = StorageValue; - | |____________^ the trait `EncodeLike` is not implemented for `Bar`, which is required by `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo, Bar>: TryDecodeEntireStorage` + | |____________^ the trait `EncodeLike` is not implemented for `Bar` | = help: the following other types implement trait `EncodeLike`: `&&T` implements `EncodeLike` @@ -203,7 +203,7 @@ error[E0277]: the trait bound `Bar: WrapperTypeEncode` is not satisfied 38 | #[pallet::storage] | _______________^ 39 | | type Foo = StorageValue; - | |____________^ the trait `WrapperTypeEncode` is not implemented for `Bar`, which is required by `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo, Bar>: TryDecodeEntireStorage` + | |____________^ the trait `WrapperTypeEncode` is not implemented for `Bar` | = help: the following other types implement trait `WrapperTypeEncode`: &T diff --git a/substrate/frame/support/test/tests/pallet_ui/storage_ensure_span_are_ok_on_wrong_gen_unnamed.stderr b/substrate/frame/support/test/tests/pallet_ui/storage_ensure_span_are_ok_on_wrong_gen_unnamed.stderr index a79a3509e69c8..be362137e8e17 100644 --- a/substrate/frame/support/test/tests/pallet_ui/storage_ensure_span_are_ok_on_wrong_gen_unnamed.stderr +++ b/substrate/frame/support/test/tests/pallet_ui/storage_ensure_span_are_ok_on_wrong_gen_unnamed.stderr @@ -9,7 +9,7 @@ error[E0277]: the trait bound `Bar: WrapperTypeDecode` is not satisfied ... | 38 | | #[pallet::storage] 39 | | type Foo = StorageValue<_, Bar>; - | |____________^ the trait `WrapperTypeDecode` is not implemented for `Bar`, which is required by `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo, Bar>: PartialStorageInfoTrait` + | |____________^ the trait `WrapperTypeDecode` is not implemented for `Bar` | = help: the following other types implement trait `WrapperTypeDecode`: Arc @@ -31,7 +31,7 @@ error[E0277]: the trait bound `Bar: EncodeLike` is not satisfied ... | 38 | | #[pallet::storage] 39 | | type Foo = StorageValue<_, Bar>; - | |____________^ the trait `EncodeLike` is not implemented for `Bar`, which is required by `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo, Bar>: PartialStorageInfoTrait` + | |____________^ the trait `EncodeLike` is not implemented for `Bar` | = help: the following other types implement trait `EncodeLike`: `&&T` implements `EncodeLike` @@ -58,7 +58,7 @@ error[E0277]: the trait bound `Bar: WrapperTypeEncode` is not satisfied ... | 38 | | #[pallet::storage] 39 | | type Foo = StorageValue<_, Bar>; - | |____________^ the trait `WrapperTypeEncode` is not implemented for `Bar`, which is required by `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo, Bar>: PartialStorageInfoTrait` + | |____________^ the trait `WrapperTypeEncode` is not implemented for `Bar` | = help: the following other types implement trait `WrapperTypeEncode`: &T @@ -81,7 +81,7 @@ error[E0277]: the trait bound `Bar: TypeInfo` is not satisfied 38 | #[pallet::storage] | _______________^ 39 | | type Foo = StorageValue<_, Bar>; - | |____________^ the trait `TypeInfo` is not implemented for `Bar`, which is required by `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo, Bar>: StorageEntryMetadataBuilder` + | |____________^ the trait `TypeInfo` is not implemented for `Bar` | = help: the following other types implement trait `TypeInfo`: &T @@ -102,7 +102,7 @@ error[E0277]: the trait bound `Bar: WrapperTypeDecode` is not satisfied 38 | #[pallet::storage] | _______________^ 39 | | type Foo = StorageValue<_, Bar>; - | |____________^ the trait `WrapperTypeDecode` is not implemented for `Bar`, which is required by `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo, Bar>: StorageEntryMetadataBuilder` + | |____________^ the trait `WrapperTypeDecode` is not implemented for `Bar` | = help: the following other types implement trait `WrapperTypeDecode`: Arc @@ -119,7 +119,7 @@ error[E0277]: the trait bound `Bar: EncodeLike` is not satisfied 38 | #[pallet::storage] | _______________^ 39 | | type Foo = StorageValue<_, Bar>; - | |____________^ the trait `EncodeLike` is not implemented for `Bar`, which is required by `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo, Bar>: StorageEntryMetadataBuilder` + | |____________^ the trait `EncodeLike` is not implemented for `Bar` | = help: the following other types implement trait `EncodeLike`: `&&T` implements `EncodeLike` @@ -141,7 +141,7 @@ error[E0277]: the trait bound `Bar: WrapperTypeEncode` is not satisfied 38 | #[pallet::storage] | _______________^ 39 | | type Foo = StorageValue<_, Bar>; - | |____________^ the trait `WrapperTypeEncode` is not implemented for `Bar`, which is required by `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo, Bar>: StorageEntryMetadataBuilder` + | |____________^ the trait `WrapperTypeEncode` is not implemented for `Bar` | = help: the following other types implement trait `WrapperTypeEncode`: &T @@ -164,7 +164,7 @@ error[E0277]: the trait bound `Bar: WrapperTypeDecode` is not satisfied 38 | #[pallet::storage] | _______________^ 39 | | type Foo = StorageValue<_, Bar>; - | |____________^ the trait `WrapperTypeDecode` is not implemented for `Bar`, which is required by `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo, Bar>: TryDecodeEntireStorage` + | |____________^ the trait `WrapperTypeDecode` is not implemented for `Bar` | = help: the following other types implement trait `WrapperTypeDecode`: Arc @@ -181,7 +181,7 @@ error[E0277]: the trait bound `Bar: EncodeLike` is not satisfied 38 | #[pallet::storage] | _______________^ 39 | | type Foo = StorageValue<_, Bar>; - | |____________^ the trait `EncodeLike` is not implemented for `Bar`, which is required by `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo, Bar>: TryDecodeEntireStorage` + | |____________^ the trait `EncodeLike` is not implemented for `Bar` | = help: the following other types implement trait `EncodeLike`: `&&T` implements `EncodeLike` @@ -203,7 +203,7 @@ error[E0277]: the trait bound `Bar: WrapperTypeEncode` is not satisfied 38 | #[pallet::storage] | _______________^ 39 | | type Foo = StorageValue<_, Bar>; - | |____________^ the trait `WrapperTypeEncode` is not implemented for `Bar`, which is required by `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo, Bar>: TryDecodeEntireStorage` + | |____________^ the trait `WrapperTypeEncode` is not implemented for `Bar` | = help: the following other types implement trait `WrapperTypeEncode`: &T diff --git a/substrate/frame/support/test/tests/pallet_ui/storage_info_unsatisfied.stderr b/substrate/frame/support/test/tests/pallet_ui/storage_info_unsatisfied.stderr index 95ec76e29c0be..637f9fc126856 100644 --- a/substrate/frame/support/test/tests/pallet_ui/storage_info_unsatisfied.stderr +++ b/substrate/frame/support/test/tests/pallet_ui/storage_info_unsatisfied.stderr @@ -9,7 +9,7 @@ error[E0277]: the trait bound `Bar: MaxEncodedLen` is not satisfied ... | 38 | | #[pallet::storage] 39 | | type Foo = StorageValue<_, Bar>; - | |____________^ the trait `MaxEncodedLen` is not implemented for `Bar`, which is required by `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo, Bar>: StorageInfoTrait` + | |____________^ the trait `MaxEncodedLen` is not implemented for `Bar` | = help: the following other types implement trait `MaxEncodedLen`: () diff --git a/substrate/frame/support/test/tests/pallet_ui/storage_info_unsatisfied_nmap.stderr b/substrate/frame/support/test/tests/pallet_ui/storage_info_unsatisfied_nmap.stderr index 8351dd92d5944..a601c9f33f665 100644 --- a/substrate/frame/support/test/tests/pallet_ui/storage_info_unsatisfied_nmap.stderr +++ b/substrate/frame/support/test/tests/pallet_ui/storage_info_unsatisfied_nmap.stderr @@ -9,7 +9,7 @@ error[E0277]: the trait bound `Bar: MaxEncodedLen` is not satisfied ... | 41 | | #[pallet::storage] 42 | | type Foo = StorageNMap<_, Key, u32>; - | |____________^ the trait `MaxEncodedLen` is not implemented for `Bar`, which is required by `frame_support::pallet_prelude::StorageNMap<_GeneratedPrefixForStorageFoo, NMapKey, u32>: StorageInfoTrait` + | |____________^ the trait `MaxEncodedLen` is not implemented for `Bar` | = help: the following other types implement trait `MaxEncodedLen`: () @@ -22,4 +22,5 @@ error[E0277]: the trait bound `Bar: MaxEncodedLen` is not satisfied (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7) and $N others = note: required for `NMapKey` to implement `KeyGeneratorMaxEncodedLen` - = note: required for `frame_support::pallet_prelude::StorageNMap<_GeneratedPrefixForStorageFoo, NMapKey, u32>` to implement `StorageInfoTrait` + = note: required for `StorageNMap<_GeneratedPrefixForStorageFoo, Key<..., ...>, ...>` to implement `StorageInfoTrait` + = note: consider using `--verbose` to print the full type name to the console diff --git a/substrate/frame/support/test/tests/runtime_ui.rs b/substrate/frame/support/test/tests/runtime_ui.rs index dbe150f38ed6a..83847f71cfe90 100644 --- a/substrate/frame/support/test/tests/runtime_ui.rs +++ b/substrate/frame/support/test/tests/runtime_ui.rs @@ -28,7 +28,7 @@ fn ui() { std::env::set_var("SKIP_WASM_BUILD", "1"); // Deny all warnings since we emit warnings as part of a Runtime's UI. - std::env::set_var("RUSTFLAGS", "--deny warnings"); + std::env::set_var("CARGO_ENCODED_RUSTFLAGS", "--deny=warnings"); let t = trybuild::TestCases::new(); t.compile_fail("tests/runtime_ui/*.rs"); diff --git a/substrate/frame/support/test/tests/split_ui.rs b/substrate/frame/support/test/tests/split_ui.rs index 14f99b8ecdab1..50a3f812145fe 100644 --- a/substrate/frame/support/test/tests/split_ui.rs +++ b/substrate/frame/support/test/tests/split_ui.rs @@ -28,7 +28,7 @@ fn split_ui() { std::env::set_var("SKIP_WASM_BUILD", "1"); // Deny all warnings since we emit warnings as part of a Pallet's UI. - std::env::set_var("RUSTFLAGS", "--deny warnings"); + std::env::set_var("CARGO_ENCODED_RUSTFLAGS", "--deny=warnings"); let t = trybuild::TestCases::new(); t.compile_fail("tests/split_ui/*.rs"); diff --git a/substrate/frame/support/test/tests/storage_alias_ui.rs b/substrate/frame/support/test/tests/storage_alias_ui.rs index b82acd8f3be43..ab25808e9718a 100644 --- a/substrate/frame/support/test/tests/storage_alias_ui.rs +++ b/substrate/frame/support/test/tests/storage_alias_ui.rs @@ -27,6 +27,9 @@ fn storage_alias_ui() { // As trybuild is using `cargo check`, we don't need the real WASM binaries. std::env::set_var("SKIP_WASM_BUILD", "1"); + // Deny all warnings since we emit warnings as part of a Runtime's UI. + std::env::set_var("CARGO_ENCODED_RUSTFLAGS", "--deny=warnings"); + let t = trybuild::TestCases::new(); t.compile_fail("tests/storage_alias_ui/*.rs"); } diff --git a/substrate/frame/transaction-storage/src/lib.rs b/substrate/frame/transaction-storage/src/lib.rs index 68f24526300d8..1fa5109ad6178 100644 --- a/substrate/frame/transaction-storage/src/lib.rs +++ b/substrate/frame/transaction-storage/src/lib.rs @@ -85,7 +85,7 @@ pub struct TransactionInfo { } fn num_chunks(bytes: u32) -> u32 { - ((bytes as u64 + CHUNK_SIZE as u64 - 1) / CHUNK_SIZE as u64) as u32 + (bytes as u64).div_ceil(CHUNK_SIZE as u64) as u32 } #[frame_support::pallet] diff --git a/substrate/frame/utility/src/lib.rs b/substrate/frame/utility/src/lib.rs index 03b193052c37a..518e75453501c 100644 --- a/substrate/frame/utility/src/lib.rs +++ b/substrate/frame/utility/src/lib.rs @@ -141,9 +141,9 @@ pub mod pallet { /// The limit on the number of batched calls. fn batched_calls_limit() -> u32 { let allocator_limit = sp_core::MAX_POSSIBLE_ALLOCATION; - let call_size = ((core::mem::size_of::<::RuntimeCall>() as u32 + - CALL_ALIGN - 1) / - CALL_ALIGN) * CALL_ALIGN; + let call_size = (core::mem::size_of::<::RuntimeCall>() as u32) + .div_ceil(CALL_ALIGN) * + CALL_ALIGN; // The margin to take into account vec doubling capacity. let margin_factor = 3; diff --git a/substrate/primitives/api/test/tests/trybuild.rs b/substrate/primitives/api/test/tests/trybuild.rs index b13e5df9d6f85..da6a339578e16 100644 --- a/substrate/primitives/api/test/tests/trybuild.rs +++ b/substrate/primitives/api/test/tests/trybuild.rs @@ -28,7 +28,7 @@ fn ui() { std::env::set_var("SKIP_WASM_BUILD", "1"); // Warnings are part of our UI. - std::env::set_var("RUSTFLAGS", "--deny warnings"); + std::env::set_var("CARGO_ENCODED_RUSTFLAGS", "--deny=warnings"); let t = trybuild::TestCases::new(); t.compile_fail("tests/ui/*.rs"); diff --git a/substrate/primitives/api/test/tests/ui/type_reference_in_impl_runtime_apis_call.stderr b/substrate/primitives/api/test/tests/ui/type_reference_in_impl_runtime_apis_call.stderr index 26be311c02fa4..7383fd4f2b29a 100644 --- a/substrate/primitives/api/test/tests/ui/type_reference_in_impl_runtime_apis_call.stderr +++ b/substrate/primitives/api/test/tests/ui/type_reference_in_impl_runtime_apis_call.stderr @@ -54,10 +54,6 @@ note: associated function defined here | 27 | fn test(data: u64); | ^^^^ -help: consider removing the borrow - | -33 | fn test(data: &u64) { - | error: unused variable: `data` --> tests/ui/type_reference_in_impl_runtime_apis_call.rs:33:11 diff --git a/substrate/primitives/core/src/lib.rs b/substrate/primitives/core/src/lib.rs index db2dfcb7a6e29..b24eb400e6459 100644 --- a/substrate/primitives/core/src/lib.rs +++ b/substrate/primitives/core/src/lib.rs @@ -481,16 +481,17 @@ macro_rules! generate_feature_enabled_macro { mod tests { use super::*; + generate_feature_enabled_macro!(if_test, test, $); + generate_feature_enabled_macro!(if_not_test, not(test), $); + #[test] #[should_panic] fn generate_feature_enabled_macro_panics() { - generate_feature_enabled_macro!(if_test, test, $); if_test!(panic!("This should panic")); } #[test] fn generate_feature_enabled_macro_works() { - generate_feature_enabled_macro!(if_not_test, not(test), $); if_not_test!(panic!("This should not panic")); } } diff --git a/substrate/primitives/runtime-interface/test-wasm/src/lib.rs b/substrate/primitives/runtime-interface/test-wasm/src/lib.rs index 545f1ff4a115e..f0b9d6839d412 100644 --- a/substrate/primitives/runtime-interface/test-wasm/src/lib.rs +++ b/substrate/primitives/runtime-interface/test-wasm/src/lib.rs @@ -83,7 +83,7 @@ pub trait TestApi { /// Copy `hello` into the given mutable reference fn return_value_into_mutable_reference(&self, data: &mut [u8]) { let res = "hello"; - data[..res.as_bytes().len()].copy_from_slice(res.as_bytes()); + data[..res.len()].copy_from_slice(res.as_bytes()); } /// Returns the input data wrapped in an `Option` as result. diff --git a/substrate/primitives/runtime-interface/tests/ui/no_feature_gated_method.stderr b/substrate/primitives/runtime-interface/tests/ui/no_feature_gated_method.stderr index 1c1649d011e68..35be091749e6b 100644 --- a/substrate/primitives/runtime-interface/tests/ui/no_feature_gated_method.stderr +++ b/substrate/primitives/runtime-interface/tests/ui/no_feature_gated_method.stderr @@ -26,7 +26,7 @@ note: the item is gated here | ^^^^^^^^^^^^^^^^^^^^ = note: this error originates in the attribute macro `runtime_interface` (in Nightly builds, run with -Z macro-backtrace for more info) -error: unexpected `cfg` condition value: `bar-feature` +warning: unexpected `cfg` condition value: `bar-feature` --> tests/ui/no_feature_gated_method.rs:24:8 | 24 | #[cfg(feature = "bar-feature")] @@ -35,10 +35,9 @@ error: unexpected `cfg` condition value: `bar-feature` = note: expected values for `feature` are: `default`, `disable_target_static_assertions`, and `std` = help: consider adding `bar-feature` as a feature in `Cargo.toml` = note: see for more information about checking conditional configuration - = note: `-D unexpected-cfgs` implied by `-D warnings` - = help: to override `-D warnings` add `#[allow(unexpected_cfgs)]` + = note: `#[warn(unexpected_cfgs)]` on by default -error: unexpected `cfg` condition value: `bar-feature` +warning: unexpected `cfg` condition value: `bar-feature` --> tests/ui/no_feature_gated_method.rs:27:12 | 27 | #[cfg(not(feature = "bar-feature"))] diff --git a/substrate/primitives/runtime/src/lib.rs b/substrate/primitives/runtime/src/lib.rs index cd5dd725c35a7..6d96293be4663 100644 --- a/substrate/primitives/runtime/src/lib.rs +++ b/substrate/primitives/runtime/src/lib.rs @@ -1237,16 +1237,17 @@ mod tests { mod sp_core_tests { use super::*; + sp_core::generate_feature_enabled_macro!(if_test, test, $); + sp_core::generate_feature_enabled_macro!(if_not_test, not(test), $); + #[test] #[should_panic] fn generate_feature_enabled_macro_panics() { - sp_core::generate_feature_enabled_macro!(if_test, test, $); if_test!(panic!("This should panic")); } #[test] fn generate_feature_enabled_macro_works() { - sp_core::generate_feature_enabled_macro!(if_not_test, not(test), $); if_not_test!(panic!("This should not panic")); } } diff --git a/substrate/primitives/state-machine/src/ext.rs b/substrate/primitives/state-machine/src/ext.rs index baad7e621bedc..afd0eeb1a55cd 100644 --- a/substrate/primitives/state-machine/src/ext.rs +++ b/substrate/primitives/state-machine/src/ext.rs @@ -139,6 +139,7 @@ where H::Out: Ord + 'static, B: 'a + Backend, { + /// Return all storage pairs from the backend and overlay combined. pub fn storage_pairs(&mut self) -> Vec<(StorageKey, StorageValue)> { use std::collections::HashMap; diff --git a/substrate/primitives/transaction-storage-proof/src/lib.rs b/substrate/primitives/transaction-storage-proof/src/lib.rs index 52a8703cf6e73..7d8e95dbb0df3 100644 --- a/substrate/primitives/transaction-storage-proof/src/lib.rs +++ b/substrate/primitives/transaction-storage-proof/src/lib.rs @@ -189,10 +189,8 @@ pub mod registration { let mut target_chunk_key = Default::default(); let mut chunk_proof = Default::default(); - let total_chunks: u64 = transactions - .iter() - .map(|t| ((t.len() + CHUNK_SIZE - 1) / CHUNK_SIZE) as u64) - .sum(); + let total_chunks: u64 = + transactions.iter().map(|t| t.len().div_ceil(CHUNK_SIZE) as u64).sum(); let mut buf = [0u8; 8]; buf.copy_from_slice(&random_hash[0..8]); let random_u64 = u64::from_be_bytes(buf); diff --git a/substrate/primitives/trie/src/node_codec.rs b/substrate/primitives/trie/src/node_codec.rs index 400f57f3b1bfe..1b6a816589177 100644 --- a/substrate/primitives/trie/src/node_codec.rs +++ b/substrate/primitives/trie/src/node_codec.rs @@ -118,10 +118,7 @@ where if padding && nibble_ops::pad_left(data[input.offset]) != 0 { return Err(Error::BadFormat) } - let partial = input.take( - (nibble_count + (nibble_ops::NIBBLE_PER_BYTE - 1)) / - nibble_ops::NIBBLE_PER_BYTE, - )?; + let partial = input.take(nibble_count.div_ceil(nibble_ops::NIBBLE_PER_BYTE))?; let partial_padding = nibble_ops::number_padding(nibble_count); let bitmap_range = input.take(BITMAP_LENGTH)?; let bitmap = Bitmap::decode(&data[bitmap_range])?; @@ -166,10 +163,7 @@ where if padding && nibble_ops::pad_left(data[input.offset]) != 0 { return Err(Error::BadFormat) } - let partial = input.take( - (nibble_count + (nibble_ops::NIBBLE_PER_BYTE - 1)) / - nibble_ops::NIBBLE_PER_BYTE, - )?; + let partial = input.take(nibble_count.div_ceil(nibble_ops::NIBBLE_PER_BYTE))?; let partial_padding = nibble_ops::number_padding(nibble_count); let value = if contains_hash { ValuePlan::Node(input.take(H::LENGTH)?) diff --git a/templates/parachain/runtime/src/apis.rs b/templates/parachain/runtime/src/apis.rs index 53fa753946d84..19a88dd6869dc 100644 --- a/templates/parachain/runtime/src/apis.rs +++ b/templates/parachain/runtime/src/apis.rs @@ -265,6 +265,7 @@ impl_runtime_apis! { (list, storage_info) } + #[allow(non_local_definitions)] fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig ) -> Result, alloc::string::String> { diff --git a/templates/solochain/runtime/src/apis.rs b/templates/solochain/runtime/src/apis.rs index 536e8250056d3..02880708f9228 100644 --- a/templates/solochain/runtime/src/apis.rs +++ b/templates/solochain/runtime/src/apis.rs @@ -241,6 +241,7 @@ impl_runtime_apis! { (list, storage_info) } + #[allow(non_local_definitions)] fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig ) -> Result, alloc::string::String> {