From 72509375d17ce3d78ee3794792cabcea5e560a15 Mon Sep 17 00:00:00 2001
From: Guillaume Thiolliere <gui.thiolliere@gmail.com>
Date: Sat, 27 Jul 2024 02:27:59 +0900
Subject: [PATCH] Fix warnings for rust 1.80 (#5150)

Fix warnings for rust 1.80
---
 Cargo.toml                                    |  2 +
 substrate/frame/support/src/lib.rs            |  1 -
 .../support/src/storage/generator/map.rs      | 41 -------------------
 .../primitives/runtime-interface/src/lib.rs   |  3 --
 substrate/primitives/weights/src/weight_v2.rs |  4 +-
 5 files changed, 4 insertions(+), 47 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index 50c9fc88836..a3582fbda13 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -542,6 +542,8 @@ default-members = [
 
 [workspace.lints.rust]
 suspicious_double_ref_op = { level = "allow", priority = 2 }
+# `substrate_runtime` is a common `cfg` condition name used in the repo.
+unexpected_cfgs = { level = "allow", check-cfg = ['cfg(substrate_runtime)'] }
 
 [workspace.lints.clippy]
 all = { level = "allow", priority = 0 }
diff --git a/substrate/frame/support/src/lib.rs b/substrate/frame/support/src/lib.rs
index 4864059167a..e1e1e0153de 100644
--- a/substrate/frame/support/src/lib.rs
+++ b/substrate/frame/support/src/lib.rs
@@ -869,7 +869,6 @@ macro_rules! hypothetically_ok {
 pub use serde::{Deserialize, Serialize};
 
 #[doc(hidden)]
-#[cfg(not(no_std))]
 pub use macro_magic;
 
 /// Prelude to be used for pallet testing, for ease of use.
diff --git a/substrate/frame/support/src/storage/generator/map.rs b/substrate/frame/support/src/storage/generator/map.rs
index b41f9c71716..7a74308fdea 100644
--- a/substrate/frame/support/src/storage/generator/map.rs
+++ b/substrate/frame/support/src/storage/generator/map.rs
@@ -74,47 +74,6 @@ pub trait StorageMap<K: FullEncode, V: FullCodec> {
 	}
 }
 
-/// Utility to iterate through items in a storage map.
-pub struct StorageMapIterator<K, V, Hasher> {
-	prefix: Vec<u8>,
-	previous_key: Vec<u8>,
-	drain: bool,
-	_phantom: ::core::marker::PhantomData<(K, V, Hasher)>,
-}
-
-impl<K: Decode + Sized, V: Decode + Sized, Hasher: ReversibleStorageHasher> Iterator
-	for StorageMapIterator<K, V, Hasher>
-{
-	type Item = (K, V);
-
-	fn next(&mut self) -> Option<(K, V)> {
-		loop {
-			let maybe_next = sp_io::storage::next_key(&self.previous_key)
-				.filter(|n| n.starts_with(&self.prefix));
-			break match maybe_next {
-				Some(next) => {
-					self.previous_key = next;
-					match unhashed::get::<V>(&self.previous_key) {
-						Some(value) => {
-							if self.drain {
-								unhashed::kill(&self.previous_key)
-							}
-							let mut key_material =
-								Hasher::reverse(&self.previous_key[self.prefix.len()..]);
-							match K::decode(&mut key_material) {
-								Ok(key) => Some((key, value)),
-								Err(_) => continue,
-							}
-						},
-						None => continue,
-					}
-				},
-				None => None,
-			}
-		}
-	}
-}
-
 impl<K: FullCodec, V: FullCodec, G: StorageMap<K, V>> storage::IterableStorageMap<K, V> for G
 where
 	G::Hasher: ReversibleStorageHasher,
diff --git a/substrate/primitives/runtime-interface/src/lib.rs b/substrate/primitives/runtime-interface/src/lib.rs
index d6dcb69958a..1de8543c461 100644
--- a/substrate/primitives/runtime-interface/src/lib.rs
+++ b/substrate/primitives/runtime-interface/src/lib.rs
@@ -15,9 +15,6 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-// Custom inner attributes are unstable, so we need to faky disable the attribute.
-// rustfmt still honors the attribute to not format the rustdocs below.
-#![cfg_attr(feature = "never", rustfmt::skip)]
 //! Substrate runtime interface
 //!
 //! This crate provides types, traits and macros around runtime interfaces. A runtime interface is
diff --git a/substrate/primitives/weights/src/weight_v2.rs b/substrate/primitives/weights/src/weight_v2.rs
index 3c10929f433..0f92e6448ca 100644
--- a/substrate/primitives/weights/src/weight_v2.rs
+++ b/substrate/primitives/weights/src/weight_v2.rs
@@ -401,14 +401,14 @@ where
 	}
 }
 
-#[cfg(any(test, feature = "std", feature = "runtime-benchmarks"))]
+#[cfg(any(test, feature = "std"))]
 impl From<u64> for Weight {
 	fn from(value: u64) -> Self {
 		Self::from_parts(value, value)
 	}
 }
 
-#[cfg(any(test, feature = "std", feature = "runtime-benchmarks"))]
+#[cfg(any(test, feature = "std"))]
 impl From<(u64, u64)> for Weight {
 	fn from(value: (u64, u64)) -> Self {
 		Self::from_parts(value.0, value.1)
-- 
GitLab