From bc6fca3c44b4c2a512b34aca900754ecb3d51e6d Mon Sep 17 00:00:00 2001
From: Gavin Wood <gavin@parity.io>
Date: Sun, 3 Sep 2023 15:11:26 +0200
Subject: [PATCH] Ensure cumulus/bridges is ignored by formatter and run it
 (#1369)

---
 .rustfmt.toml                                      |  4 ++--
 substrate/client/network/src/service.rs            | 14 ++++++++------
 .../rpc-spec-v2/src/chain_head/chain_head.rs       |  6 ++++--
 .../src/chain_head/chain_head_storage.rs           |  4 +---
 substrate/frame/broker/src/dispatchable_impls.rs   |  4 ++--
 substrate/frame/broker/src/tick_impls.rs           |  4 ++--
 substrate/frame/safe-mode/src/lib.rs               |  2 +-
 7 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/.rustfmt.toml b/.rustfmt.toml
index 10568e49680..0dc11bdb8a3 100644
--- a/.rustfmt.toml
+++ b/.rustfmt.toml
@@ -19,9 +19,9 @@ trailing_comma = "Vertical"
 trailing_semicolon = false
 use_field_init_shorthand = true
 ignore = [
-    "bridges",
+    "cumulus/bridges",
 ]
 edition = "2021"
 # Format comments
 comment_width = 100
-wrap_comments = true
\ No newline at end of file
+wrap_comments = true
diff --git a/substrate/client/network/src/service.rs b/substrate/client/network/src/service.rs
index aca0072a31d..c1df48ad785 100644
--- a/substrate/client/network/src/service.rs
+++ b/substrate/client/network/src/service.rs
@@ -943,9 +943,10 @@ where
 		peers: HashSet<Multiaddr>,
 	) -> Result<(), String> {
 		let Some(set_id) = self.notification_protocol_ids.get(&protocol) else {
-			return Err(
-				format!("Cannot add peers to reserved set of unknown protocol: {}", protocol)
-			)
+			return Err(format!(
+				"Cannot add peers to reserved set of unknown protocol: {}",
+				protocol
+			))
 		};
 
 		let peers = self.split_multiaddr_and_peer_id(peers)?;
@@ -974,9 +975,10 @@ where
 		peers: Vec<PeerId>,
 	) -> Result<(), String> {
 		let Some(set_id) = self.notification_protocol_ids.get(&protocol) else {
-			return Err(
-				format!("Cannot remove peers from reserved set of unknown protocol: {}", protocol)
-			)
+			return Err(format!(
+				"Cannot remove peers from reserved set of unknown protocol: {}",
+				protocol
+			))
 		};
 
 		for peer_id in peers.into_iter() {
diff --git a/substrate/client/rpc-spec-v2/src/chain_head/chain_head.rs b/substrate/client/rpc-spec-v2/src/chain_head/chain_head.rs
index bae7c84df0e..14364c331e6 100644
--- a/substrate/client/rpc-spec-v2/src/chain_head/chain_head.rs
+++ b/substrate/client/rpc-spec-v2/src/chain_head/chain_head.rs
@@ -462,7 +462,8 @@ where
 		follow_subscription: String,
 		operation_id: String,
 	) -> RpcResult<()> {
-		let Some(operation) = self.subscriptions.get_operation(&follow_subscription, &operation_id) else {
+		let Some(operation) = self.subscriptions.get_operation(&follow_subscription, &operation_id)
+		else {
 			return Ok(())
 		};
 
@@ -479,7 +480,8 @@ where
 		follow_subscription: String,
 		operation_id: String,
 	) -> RpcResult<()> {
-		let Some(operation) = self.subscriptions.get_operation(&follow_subscription, &operation_id) else {
+		let Some(operation) = self.subscriptions.get_operation(&follow_subscription, &operation_id)
+		else {
 			return Ok(())
 		};
 
diff --git a/substrate/client/rpc-spec-v2/src/chain_head/chain_head_storage.rs b/substrate/client/rpc-spec-v2/src/chain_head/chain_head_storage.rs
index 5e1f38f9a99..48a673f47e3 100644
--- a/substrate/client/rpc-spec-v2/src/chain_head/chain_head_storage.rs
+++ b/substrate/client/rpc-spec-v2/src/chain_head/chain_head_storage.rs
@@ -166,9 +166,7 @@ where
 
 		let mut ret = Vec::with_capacity(self.operation_max_storage_items);
 		for _ in 0..self.operation_max_storage_items {
-			let Some(key) = keys_iter.next() else {
-				break
-			};
+			let Some(key) = keys_iter.next() else { break };
 
 			let result = match ty {
 				IterQueryType::Value => self.query_storage_value(hash, &key, child_key),
diff --git a/substrate/frame/broker/src/dispatchable_impls.rs b/substrate/frame/broker/src/dispatchable_impls.rs
index 7c1d5a786b7..8dc0c9de393 100644
--- a/substrate/frame/broker/src/dispatchable_impls.rs
+++ b/substrate/frame/broker/src/dispatchable_impls.rs
@@ -334,10 +334,10 @@ impl<T: Config> Pallet<T> {
 			contribution.length.saturating_dec();
 
 			let Some(mut pool_record) = InstaPoolHistory::<T>::get(r) else {
-				continue;
+				continue
 			};
 			let Some(total_payout) = pool_record.maybe_payout else {
-				break;
+				break
 			};
 			let p = total_payout
 				.saturating_mul(contributed_parts.into())
diff --git a/substrate/frame/broker/src/tick_impls.rs b/substrate/frame/broker/src/tick_impls.rs
index d65b8968f3c..909af6caf73 100644
--- a/substrate/frame/broker/src/tick_impls.rs
+++ b/substrate/frame/broker/src/tick_impls.rs
@@ -96,7 +96,7 @@ impl<T: Config> Pallet<T> {
 
 	pub(crate) fn process_revenue() -> bool {
 		let Some((until, amount)) = T::Coretime::check_notify_revenue_info() else {
-			return false;
+			return false
 		};
 		let when: Timeslice =
 			(until / T::TimeslicePeriod::get()).saturating_sub(One::one()).saturated_into();
@@ -290,7 +290,7 @@ impl<T: Config> Pallet<T> {
 		core: CoreIndex,
 	) {
 		let Some(workplan) = Workplan::<T>::take((timeslice, core)) else {
-			return;
+			return
 		};
 		let workload = Workload::<T>::get(core);
 		let parts_used = workplan.iter().map(|i| i.mask).fold(CoreMask::void(), |a, i| a | i);
diff --git a/substrate/frame/safe-mode/src/lib.rs b/substrate/frame/safe-mode/src/lib.rs
index ff045b964af..b8e8378fa9e 100644
--- a/substrate/frame/safe-mode/src/lib.rs
+++ b/substrate/frame/safe-mode/src/lib.rs
@@ -398,7 +398,7 @@ pub mod pallet {
 		/// [`EnteredUntil`].
 		fn on_initialize(current: BlockNumberFor<T>) -> Weight {
 			let Some(limit) = EnteredUntil::<T>::get() else {
-				return T::WeightInfo::on_initialize_noop();
+				return T::WeightInfo::on_initialize_noop()
 			};
 
 			if current > limit {
-- 
GitLab