message: Ensure that states don't regress
  There were cases when testing retry where a connection would go from
  Closed to Closing.  That isn't good, so let's safeguard against that.
diff: #![allow(dead_code)]
  use std::cell::RefCell;
  -use std::cmp::{max, min};
  +use std::cmp::{max, min, Ordering};
  use std::collections::HashMap;
  use std::fmt::{self, Debug};
  use std::mem;
  @@ -87,6 +87,28 @@ pub enum State {
  Closed(ConnectionError),
  }
  +// Implement Ord so that we can enforce monotonic state progression.
  +impl PartialOrd for State {
  + fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
  + if std::mem::discriminant(self) == std::mem::discriminant(other) {
  + return Some(Ordering::Equal);
  + }
  + Some(match (self, other) {
  + (State::Init, _) => Ordering::Less,
  + (_, State::Init) => Ordering::Greater,
  + (State::WaitInitial, _) => Ordering::Less,
  + (_, State::WaitInitial) => Ordering::Greater,
  + (State::Handshaking, _) => Ordering::Less,
  + (_, State::Handshaking) => Ordering::Greater,
  + (State::Connected, _) => Ordering::Less,
  + (_, State::Connected) => Ordering::Greater,
  + (State::Closing { .. }, _) => Ordering::Less,
  + (_, State::Closing { .. }) => Ordering::Greater,
  + (State::Closed(_), _) => unreachable!(),
  + })
  + }
  +}
  +
  #[derive(Clone, Copy, Debug, PartialEq)]
  enum ZeroRttState {
  Init,
  @@ -397,6 +419,9 @@ impl Connection {
  let msg = format!("{:?}", v);
  #[cfg(not(debug_assertions))]
  let msg = String::from("");
  + if let State::Closed(err) | State::Closing { error: err, .. } = &self.state {
  + qwarn!([self] "Closing again after error {:?}", err);
  + } else {
  self.set_state(State::Closing {
  error: ConnectionError::Transport(v.clone()),
  frame_type,
  @@ -404,6 +429,7 @@ impl Connection {
  timeout: self.get_closing_period_time(now),
  });
  }
  + }
  res
  }
  