Skip to content

Commit

Permalink
Mark unreachable match clause as unreachable! (paritytech#620)
Browse files Browse the repository at this point in the history
* Mark unreachable match clause as unreachable!

* Fix indentation
  • Loading branch information
sorpaas authored and bkchr committed Nov 27, 2019
1 parent 00e167f commit fba836e
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions validation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,13 @@ impl<C, TxApi> futures03::Future for CreateProposal<C, TxApi> 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);
Expand All @@ -844,17 +850,14 @@ impl<C, TxApi> futures03::Future for CreateProposal<C, TxApi> 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
}
}

Expand Down

0 comments on commit fba836e

Please sign in to comment.