Skip to content

Commit

Permalink
Fix Clippy errors from Rust 1.82.0
Browse files Browse the repository at this point in the history
It is possible to preview unreleased rust versions like so:

```console
RUSTUP_DIST_SERVER=https://dev-static.rust-lang.org rustup install 1.82.0
```
  • Loading branch information
fuzzypixelz committed Oct 17, 2024
1 parent 363e817 commit f397ec7
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 f397ec7

Please sign in to comment.