Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Clippy errors from Rust 1.82.0 #1541

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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