Skip to content

Commit

Permalink
Disallow unreachable as well
Browse files Browse the repository at this point in the history
  • Loading branch information
poljar committed Jan 17, 2025
1 parent df7f7a2 commit ca06697
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ rust_2018_idioms = "deny"

[lints.clippy]
panic = "deny"
unreachable = "deny"
expect_used = "deny"
unwrap_used = "deny"
mem_forget = "deny"
Expand Down
1 change: 1 addition & 0 deletions src/megolm/inbound_group_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ impl InboundGroupSession {
//
// After that we compare the raw ratchet bytes in constant time.

#[allow(clippy::unreachable)]
if self.config != other.config || self.signing_key != other.signing_key {
// Short circuit if session configs differ or the signing keys
// differ. This is comparing public key material.
Expand Down
6 changes: 4 additions & 2 deletions src/megolm/ratchet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,22 +109,24 @@ struct RatchetParts<'a> {

impl<'a> RatchetParts<'a> {
fn update(&'a mut self, from: usize, to: usize) {
#[allow(clippy::unreachable)]
let from = match from {
0 => &self.r_0,
1 => &self.r_1,
2 => &self.r_2,
3 => &self.r_3,
_ => unreachable!(),
_ => unreachable!("We only have 4 ratchet parts"),
};

let result = from.hash(ADVANCEMENT_SEEDS[to]);

#[allow(clippy::unreachable)]
let to = match to {
0 => &mut self.r_0,
1 => &mut self.r_1,
2 => &mut self.r_2,
3 => &mut self.r_3,
_ => unreachable!(),
_ => unreachable!("We only have 4 ratchet parts"),
};

to.update(&result.into_bytes());
Expand Down

0 comments on commit ca06697

Please sign in to comment.