Skip to content

Commit

Permalink
Merge pull request eclipse-zenoh#1541 from eclipse-zenoh/fix-clippy-e…
Browse files Browse the repository at this point in the history
…rrors-1.82.0

Fix Clippy errors from Rust 1.82.0
  • Loading branch information
Mallets authored Oct 17, 2024
2 parents 45c0740 + f397ec7 commit 4a8bd68
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
16 changes: 10 additions & 6 deletions commons/zenoh-buffers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,21 @@ macro_rules! unsafe_slice_mut {
#[cfg(all(not(test), not(feature = "test")))]
#[macro_export]
macro_rules! unsafe_slice {
($s:expr,$r:expr) => {
unsafe { $s.get_unchecked($r) }
};
($s:expr,$r:expr) => {{
let slice = &*$s;
let index = $r;
unsafe { slice.get_unchecked(index) }
}};
}

#[cfg(all(not(test), not(feature = "test")))]
#[macro_export]
macro_rules! unsafe_slice_mut {
($s:expr,$r:expr) => {
unsafe { $s.get_unchecked_mut($r) }
};
($s:expr,$r:expr) => {{
let slice = &mut *$s;
let index = $r;
unsafe { slice.get_unchecked_mut(index) }
}};
}

pub mod buffer {
Expand Down
6 changes: 5 additions & 1 deletion commons/zenoh-keyexpr/src/key_expr/format/support.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,11 @@ impl<'s> IKeFormatStorage<'s> for Vec<Segment<'s>> {
constructor: IterativeConstructor<Self, Self::PartialConstruct, Self::ConstructionError>,
segment: Segment<'s>,
) -> IterativeConstructor<Self, Self::PartialConstruct, Self::ConstructionError> {
let IterativeConstructor::Complete(mut this) = constructor else {
// NOTE(fuzzypixelz): Rust 1.82.0 can detect that this pattern is irrefutable but that's not
// necessarily the case for prior versions. Thus we silence this lint to keep the MSRV minimal.
#[allow(irrefutable_let_patterns)]
let IterativeConstructor::Complete(mut this) = constructor
else {
unsafe { core::hint::unreachable_unchecked() }
};
this.push(segment);
Expand Down

0 comments on commit 4a8bd68

Please sign in to comment.