From c7743cd86bcb37edbd27d30ebd0dab8d6470a7d7 Mon Sep 17 00:00:00 2001 From: Wei Tang Date: Wed, 27 Nov 2019 18:03:45 +0100 Subject: [PATCH] Mark unreachable match clause as unreachable! (#620) * Mark unreachable match clause as unreachable! * Fix indentation --- polkadot/validation/src/lib.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/polkadot/validation/src/lib.rs b/polkadot/validation/src/lib.rs index f77aa79f3b..915ac29027 100644 --- a/polkadot/validation/src/lib.rs +++ b/polkadot/validation/src/lib.rs @@ -835,7 +835,13 @@ impl futures03::Future for CreateProposal where data }, - CreateProposalState::Switching => return Poll::Pending, + CreateProposalState::Switching => + unreachable!( + "State Switching are only created on call, \ + and immediately swapped out; \ + the data being read is from state; \ + thus Switching will never be reachable here; qed" + ), CreateProposalState::Fired(mut future) => { let ret = Pin::new(&mut future).poll(cx); self.state = CreateProposalState::Fired(future); @@ -844,17 +850,14 @@ impl futures03::Future for CreateProposal where }; // 2. propose - let future = tokio_executor::blocking::run(move || { + let mut future = tokio_executor::blocking::run(move || { let proposed_candidates = data.table.proposed_set(); data.propose_with(proposed_candidates) }); + let polled = Pin::new(&mut future).poll(cx); self.state = CreateProposalState::Fired(future); - match &mut self.state { - CreateProposalState::Fired(future) => Pin::new(future).poll(cx), - CreateProposalState::Switching | CreateProposalState::Pending(_) => - Poll::Pending, - } + polled } }