Skip to content

Commit 8d7eafd

Browse files
committed
chore: Appease clippy
1 parent fa9776f commit 8d7eafd

2 files changed

Lines changed: 16 additions & 22 deletions

File tree

src/olm/session/mod.rs

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -308,19 +308,11 @@ impl Session {
308308
let initial_ratchet_key = RemoteRatchetKey(self.session_keys().signed_pre_key);
309309

310310
// Interolm immediately initializes a receiving chain, using the signed prekey
311-
// as the initial (remote) ratchet key, even though it never received a
311+
// as the initial (remote) ratchet key, even though it's never received a
312312
// message from the other side. Therefore we need to filter that chain
313313
// out when trying to determine whether we've ever received a message
314314
// from the other side.
315-
let is_empty = self
316-
.receiving_chains
317-
.inner
318-
.iter()
319-
.filter(|c| !c.belongs_to(&initial_ratchet_key))
320-
.next()
321-
.is_none();
322-
323-
!is_empty
315+
self.receiving_chains.inner.iter().any(|c| !c.belongs_to(&initial_ratchet_key))
324316
}
325317

326318
pub fn is_message_for_this_session(&self, message: &AnyMessage) -> Option<bool> {
@@ -612,6 +604,7 @@ impl Session {
612604
impl TryFrom<Pickle> for Session {
613605
type Error = crate::LibolmPickleError;
614606

607+
#[allow(unreachable_code, clippy::diverging_sub_expression)]
615608
fn try_from(pickle: Pickle) -> Result<Self, Self::Error> {
616609
let mut receiving_chains = ChainStore::new();
617610

@@ -628,13 +621,16 @@ impl Session {
628621
}
629622
}
630623

631-
let session_keys = SessionKeys {
624+
let _session_keys = SessionKeys {
632625
identity_key: pickle.session_keys.identity_key,
633626
base_key: pickle.session_keys.base_key,
634627
signed_pre_key: pickle.session_keys.one_time_key,
635628
one_time_key: None,
636-
other_identity_key: todo!("libolm session pickles don't contain this information, \
637-
so there's not enough information to reconstruct a `Session`"),
629+
// TODO: Figure out what to do with libolm session pickles
630+
other_identity_key: unimplemented!(
631+
"libolm session pickles don't contain this information, \
632+
so there's not enough information to reconstruct a `Session`"
633+
),
638634
};
639635

640636
if let Some(chain) = pickle.sender_chains.first() {
@@ -654,7 +650,7 @@ impl Session {
654650
DoubleRatchet::from_ratchet_and_chain_key(ratchet, chain_key);
655651

656652
Ok(Self {
657-
session_keys,
653+
session_keys: _session_keys,
658654
sending_ratchet,
659655
receiving_chains,
660656
config: SessionConfig::version_1(),
@@ -668,7 +664,7 @@ impl Session {
668664
);
669665

670666
Ok(Self {
671-
session_keys,
667+
session_keys: _session_keys,
672668
sending_ratchet,
673669
receiving_chains,
674670
config: SessionConfig::version_1(),
@@ -794,7 +790,7 @@ mod test {
794790
bob.generate_one_time_keys(2);
795791

796792
let mut bob_prekeys: Vec<(KeyId, Curve25519PublicKey)> =
797-
bob.one_time_keys().iter().map(|(t1, t2)| (t1.clone(), t2.clone())).take(2).collect();
793+
bob.one_time_keys().iter().map(|(t1, t2)| (*t1, *t2)).take(2).collect();
798794
let (otk_id, otk) =
799795
bob_prekeys.pop().expect("Bob should have an OTK because we just generated it");
800796
let (skey_id, skey) = bob_prekeys
@@ -817,10 +813,8 @@ mod test {
817813
let ciphertext = alice_session.encrypt_interolm(message);
818814

819815
if let AnyMessage::Interolm(AnyInterolmMessage::PreKey(m)) = ciphertext.into() {
820-
let InboundCreationResult { session, .. } = bob.create_inbound_session(
821-
alice.identity_keys().curve25519,
822-
&m.try_into().expect("We should be able to establish the session"),
823-
)?;
816+
let InboundCreationResult { session, .. } =
817+
bob.create_inbound_session(alice.identity_keys().curve25519, &m.into())?;
824818

825819
Ok((alice, bob, alice_session, session))
826820
} else {

src/xeddsa/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ mod test {
124124
verify(key_pair.public_key().as_bytes(), corrupted_message.as_bytes(), signature)
125125
.expect_err("The signature should be invalid");
126126

127-
let mut corrupted_signature = signature.clone();
128-
corrupted_signature.0[0] = signature.0[0] + 1;
127+
let mut corrupted_signature = signature;
128+
corrupted_signature.0[0] += 1;
129129
verify(key_pair.public_key().as_bytes(), message.as_bytes(), corrupted_signature)
130130
.expect_err("The signature should be invalid");
131131
}

0 commit comments

Comments
 (0)