Skip to content

Commit 0d8bf5f

Browse files
committed
revert clippy::collapsible_match changes
1 parent 103f208 commit 0d8bf5f

6 files changed

Lines changed: 183 additions & 129 deletions

File tree

rs/nns/governance/src/governance.rs

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4660,15 +4660,18 @@ impl Governance {
46604660
));
46614661
}
46624662
}
4663-
Command::Follow(follow) if follow.followees.len() > MAX_FOLLOWEES_PER_TOPIC => {
4664-
return Err(GovernanceError::new_with_message(
4665-
ErrorType::InvalidCommand,
4666-
format!(
4667-
"Too many followees: {} (max: {})",
4668-
follow.followees.len(),
4669-
MAX_FOLLOWEES_PER_TOPIC
4670-
),
4671-
));
4663+
#[allow(clippy::collapsible_match)]
4664+
Command::Follow(follow) => {
4665+
if follow.followees.len() > MAX_FOLLOWEES_PER_TOPIC {
4666+
return Err(GovernanceError::new_with_message(
4667+
ErrorType::InvalidCommand,
4668+
format!(
4669+
"Too many followees: {} (max: {})",
4670+
follow.followees.len(),
4671+
MAX_FOLLOWEES_PER_TOPIC
4672+
),
4673+
));
4674+
}
46724675
}
46734676
Command::SetFollowing(set_following) => {
46744677
set_following.validate_intrinsically()?;
@@ -4953,10 +4956,13 @@ impl Governance {
49534956
Self::validate_add_or_remove_data_centers_payload(&update.payload)
49544957
.map_err(invalid_proposal_error)?;
49554958
}
4956-
ValidNnsFunction::SplitSubnet if !are_subnet_splitting_proposals_enabled() => {
4957-
return Err(invalid_proposal_error(String::from(
4958-
"Subnet Splitting proposals not yet enabled",
4959-
)));
4959+
#[allow(clippy::collapsible_match)]
4960+
ValidNnsFunction::SplitSubnet => {
4961+
if !are_subnet_splitting_proposals_enabled() {
4962+
return Err(invalid_proposal_error(String::from(
4963+
"Subnet Splitting proposals not yet enabled",
4964+
)));
4965+
}
49604966
}
49614967
_ => {}
49624968
};

rs/recovery/src/app_subnet_recovery.rs

Lines changed: 52 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -313,17 +313,20 @@ impl RecoveryIterator<StepType, StepTypeIter> for AppSubnetRecovery {
313313
wait_for_confirmation(&self.logger);
314314
}
315315

316-
StepType::DownloadConsensusPool if self.params.download_pool_node.is_none() => {
317-
// We could pick a node with highest finalization and CUP height automatically,
318-
// but we might have a preference between nodes of same heights.
319-
print_height_info(
320-
&self.logger,
321-
&self.recovery.registry_helper,
322-
self.params.subnet_id,
323-
);
316+
#[allow(clippy::collapsible_match)]
317+
StepType::DownloadConsensusPool => {
318+
if self.params.download_pool_node.is_none() {
319+
// We could pick a node with highest finalization and CUP height automatically,
320+
// but we might have a preference between nodes of same heights.
321+
print_height_info(
322+
&self.logger,
323+
&self.recovery.registry_helper,
324+
self.params.subnet_id,
325+
);
324326

325-
self.params.download_pool_node =
326-
Some(read(&self.logger, "Enter consensus pool download IP:"));
327+
self.params.download_pool_node =
328+
Some(read(&self.logger, "Enter consensus pool download IP:"));
329+
}
327330
}
328331

329332
StepType::DownloadState => {
@@ -352,21 +355,30 @@ impl RecoveryIterator<StepType, StepTypeIter> for AppSubnetRecovery {
352355
}
353356
}
354357

355-
StepType::ICReplay if self.params.replay_until_height.is_none() => {
356-
self.params.replay_until_height =
357-
read_optional(&self.logger, "Replay until height: ");
358+
#[allow(clippy::collapsible_match)]
359+
StepType::ICReplay => {
360+
if self.params.replay_until_height.is_none() {
361+
self.params.replay_until_height =
362+
read_optional(&self.logger, "Replay until height: ");
363+
}
358364
}
359365

360-
StepType::ElectVersion if self.params.upgrade_version.is_none() => {
361-
self.params.upgrade_version =
362-
read_optional(&self.logger, "Version to bless (and upgrade to): ");
366+
#[allow(clippy::collapsible_match)]
367+
StepType::ElectVersion => {
368+
if self.params.upgrade_version.is_none() {
369+
self.params.upgrade_version =
370+
read_optional(&self.logger, "Version to bless (and upgrade to): ");
371+
}
363372
}
364373

365-
StepType::UpgradeVersion if self.params.upgrade_version.is_none() => {
366-
self.params.upgrade_version = read_optional(
367-
&self.logger,
368-
"Version to upgrade to (WARN: it should already be blessed): ",
369-
);
374+
#[allow(clippy::collapsible_match)]
375+
StepType::UpgradeVersion => {
376+
if self.params.upgrade_version.is_none() {
377+
self.params.upgrade_version = read_optional(
378+
&self.logger,
379+
"Version to upgrade to (WARN: it should already be blessed): ",
380+
);
381+
}
370382
}
371383

372384
StepType::ProposeCup => {
@@ -390,21 +402,27 @@ impl RecoveryIterator<StepType, StepTypeIter> for AppSubnetRecovery {
390402
}
391403
}
392404

393-
StepType::UploadState if self.params.upload_method.is_none() => {
394-
self.params.upload_method = Some(read_data_location(
395-
&self.logger,
396-
"Are you performing a local recovery directly on the node, or a remote recovery? [local/<ipv6>]",
397-
));
405+
#[allow(clippy::collapsible_match)]
406+
StepType::UploadState => {
407+
if self.params.upload_method.is_none() {
408+
self.params.upload_method = Some(read_data_location(
409+
&self.logger,
410+
"Are you performing a local recovery directly on the node, or a remote recovery? [local/<ipv6>]",
411+
));
412+
}
398413
}
399414

400-
StepType::WaitForCUP if self.params.wait_for_cup_node.is_none() => {
401-
if let Some(DataLocation::Remote(ip)) = self.params.upload_method {
402-
self.params.wait_for_cup_node = Some(ip);
403-
} else {
404-
self.params.wait_for_cup_node = read_optional(
405-
&self.logger,
406-
"Enter IP of the node to be polled for the recovery CUP:",
407-
);
415+
#[allow(clippy::collapsible_match)]
416+
StepType::WaitForCUP => {
417+
if self.params.wait_for_cup_node.is_none() {
418+
if let Some(DataLocation::Remote(ip)) = self.params.upload_method {
419+
self.params.wait_for_cup_node = Some(ip);
420+
} else {
421+
self.params.wait_for_cup_node = read_optional(
422+
&self.logger,
423+
"Enter IP of the node to be polled for the recovery CUP:",
424+
);
425+
}
408426
}
409427
}
410428

rs/recovery/src/nns_recovery_failover_nodes.rs

Lines changed: 42 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -184,27 +184,31 @@ impl RecoveryIterator<StepType, StepTypeIter> for NNSRecoveryFailoverNodes {
184184
// Depending on the next step we might require some user interaction before we can execute
185185
// it.
186186
match step_type {
187-
StepType::StopReplica | StepType::DownloadConsensusPool | StepType::DownloadState
188-
if self.params.download_node.is_none() =>
189-
{
190-
// We could pick a node with highest finalization and CUP height automatically,
191-
// but we might have a preference between nodes of same heights.
192-
print_height_info(
193-
&self.logger,
194-
&self.recovery.registry_helper,
195-
self.params.subnet_id,
196-
);
187+
#[allow(clippy::collapsible_match)]
188+
StepType::StopReplica | StepType::DownloadConsensusPool | StepType::DownloadState => {
189+
if self.params.download_node.is_none() {
190+
// We could pick a node with highest finalization and CUP height automatically,
191+
// but we might have a preference between nodes of same heights.
192+
print_height_info(
193+
&self.logger,
194+
&self.recovery.registry_helper,
195+
self.params.subnet_id,
196+
);
197197

198-
self.params.download_node = read_optional(&self.logger, "Enter download IP:");
198+
self.params.download_node = read_optional(&self.logger, "Enter download IP:");
199+
}
199200
}
200201
_ => {}
201202
}
202203
match step_type {
203-
StepType::DownloadState if self.params.download_state_height.is_none() => {
204-
self.params.download_state_height = read_optional(
205-
&self.logger,
206-
"Enter the height of the checkpoint to download (leave empty for latest checkpoint):",
207-
);
204+
#[allow(clippy::collapsible_match)]
205+
StepType::DownloadState => {
206+
if self.params.download_state_height.is_none() {
207+
self.params.download_state_height = read_optional(
208+
&self.logger,
209+
"Enter the height of the checkpoint to download (leave empty for latest checkpoint):",
210+
);
211+
}
208212
}
209213
StepType::ProposeToCreateSubnet => {
210214
if self.params.replica_version.is_none() {
@@ -221,16 +225,22 @@ impl RecoveryIterator<StepType, StepTypeIter> for NNSRecoveryFailoverNodes {
221225
}
222226
}
223227

224-
StepType::DownloadParentNNSStore if self.params.parent_nns_host_ip.is_none() => {
225-
self.params.parent_nns_host_ip = read_optional(
226-
&self.logger,
227-
"Enter parent NNS IP to download the registry store from:",
228-
);
228+
#[allow(clippy::collapsible_match)]
229+
StepType::DownloadParentNNSStore => {
230+
if self.params.parent_nns_host_ip.is_none() {
231+
self.params.parent_nns_host_ip = read_optional(
232+
&self.logger,
233+
"Enter parent NNS IP to download the registry store from:",
234+
);
235+
}
229236
}
230237

231-
StepType::ICReplayWithRegistryContent if self.params.replay_until_height.is_none() => {
232-
self.params.replay_until_height =
233-
read_optional(&self.logger, "Replay until height: ");
238+
#[allow(clippy::collapsible_match)]
239+
StepType::ICReplayWithRegistryContent => {
240+
if self.params.replay_until_height.is_none() {
241+
self.params.replay_until_height =
242+
read_optional(&self.logger, "Replay until height: ");
243+
}
234244
}
235245

236246
StepType::UploadAndHostTar => {
@@ -250,11 +260,14 @@ impl RecoveryIterator<StepType, StepTypeIter> for NNSRecoveryFailoverNodes {
250260
}
251261
}
252262

253-
StepType::WaitForCUP if self.params.upload_method.is_none() => {
254-
self.params.upload_method = read_optional_data_location(
255-
&self.logger,
256-
"Are you performing a local recovery directly on the node, or a remote recovery? [local/<ipv6>]",
257-
);
263+
#[allow(clippy::collapsible_match)]
264+
StepType::WaitForCUP => {
265+
if self.params.upload_method.is_none() {
266+
self.params.upload_method = read_optional_data_location(
267+
&self.logger,
268+
"Are you performing a local recovery directly on the node, or a remote recovery? [local/<ipv6>]",
269+
);
270+
}
258271
}
259272
_ => {}
260273
}

rs/recovery/src/nns_recovery_same_nodes.rs

Lines changed: 48 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -244,30 +244,34 @@ impl RecoveryIterator<StepType, StepTypeIter> for NNSRecoverySameNodes {
244244
// Depending on the next step we might require some user interaction before we can execute
245245
// it.
246246
match step_type {
247-
StepType::StopReplica | StepType::DownloadState | StepType::UploadState
248-
if self.params.admin_access_location.is_none() =>
249-
{
250-
self.params.admin_access_location = Some(read_data_location(
251-
&self.logger,
252-
"Enter state download/upload location (admin access required) [local/<ipv6>]:",
253-
));
247+
#[allow(clippy::collapsible_match)]
248+
StepType::StopReplica | StepType::DownloadState | StepType::UploadState => {
249+
if self.params.admin_access_location.is_none() {
250+
self.params.admin_access_location = Some(read_data_location(
251+
&self.logger,
252+
"Enter state download/upload location (admin access required) [local/<ipv6>]:",
253+
));
254+
}
254255
}
255256
_ => {}
256257
}
257258
match step_type {
258-
StepType::DownloadConsensusPool if self.params.download_pool_node.is_none() => {
259-
// We could pick a node with highest finalization and CUP height automatically,
260-
// but we might have a preference between nodes of same heights.
261-
print_height_info(
262-
&self.logger,
263-
&self.recovery.registry_helper,
264-
self.params.subnet_id,
265-
);
259+
#[allow(clippy::collapsible_match)]
260+
StepType::DownloadConsensusPool => {
261+
if self.params.download_pool_node.is_none() {
262+
// We could pick a node with highest finalization and CUP height automatically,
263+
// but we might have a preference between nodes of same heights.
264+
print_height_info(
265+
&self.logger,
266+
&self.recovery.registry_helper,
267+
self.params.subnet_id,
268+
);
266269

267-
self.params.download_pool_node = Some(read(
268-
&self.logger,
269-
"Enter consensus pool download IP (backup access required):",
270-
));
270+
self.params.download_pool_node = Some(read(
271+
&self.logger,
272+
"Enter consensus pool download IP (backup access required):",
273+
));
274+
}
271275
}
272276

273277
StepType::DownloadState => {
@@ -308,32 +312,38 @@ impl RecoveryIterator<StepType, StepTypeIter> for NNSRecoverySameNodes {
308312
}
309313
}
310314

311-
StepType::CreateArtifacts if self.params.output_dir.is_none() => {
312-
self.params.output_dir = read_optional(
313-
&self.logger,
314-
&format!(
315-
"Enter output directory for recovery artifacts (must be in a shared mount if doing local recovery, default: {}):",
316-
self.recovery.recovery_dir.join("output").display()
317-
),
318-
);
315+
#[allow(clippy::collapsible_match)]
316+
StepType::CreateArtifacts => {
317+
if self.params.output_dir.is_none() {
318+
self.params.output_dir = read_optional(
319+
&self.logger,
320+
&format!(
321+
"Enter output directory for recovery artifacts (must be in a shared mount if doing local recovery, default: {}):",
322+
self.recovery.recovery_dir.join("output").display()
323+
),
324+
);
325+
}
319326
}
320327

321-
StepType::UploadCUPAndRegistry if self.params.wait_for_cup_node.is_none() => {
322-
self.params.wait_for_cup_node = if let Some(DataLocation::Remote(ip)) =
323-
self.params.admin_access_location
324-
{
325-
consent_given(
328+
#[allow(clippy::collapsible_match)]
329+
StepType::UploadCUPAndRegistry => {
330+
if self.params.wait_for_cup_node.is_none() {
331+
self.params.wait_for_cup_node = if let Some(DataLocation::Remote(ip)) =
332+
self.params.admin_access_location
333+
{
334+
consent_given(
326335
&self.logger,
327336
&format!(
328337
"Would you like to recover the admin node now, i.e. upload the CUP and registry local store to it? ({ip})"
329338
),
330339
).then_some(ip)
331-
} else {
332-
read_optional(
333-
&self.logger,
334-
"If you would like to recover the admin node now, i.e. upload the CUP and registry local store to it, enter its IP address:",
335-
)
336-
};
340+
} else {
341+
read_optional(
342+
&self.logger,
343+
"If you would like to recover the admin node now, i.e. upload the CUP and registry local store to it, enter its IP address:",
344+
)
345+
};
346+
}
337347
}
338348

339349
_ => {}

0 commit comments

Comments
 (0)