Skip to content

Commit

Permalink
Fix warnings for rust 1.80 (#5150)
Browse files Browse the repository at this point in the history
Fix warnings for rust 1.80
  • Loading branch information
gui1117 authored Jul 26, 2024
1 parent 7e4433e commit 7250937
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 47 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
1 change: 0 additions & 1 deletion substrate/frame/support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
41 changes: 0 additions & 41 deletions substrate/frame/support/src/storage/generator/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 0 additions & 3 deletions substrate/primitives/runtime-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions substrate/primitives/weights/src/weight_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7250937

Please sign in to comment.