Skip to content

Commit 8d4b87f

Browse files
committed
rust: rearrange code to avoid #[allow]
Signed-off-by: Gary Guo <[email protected]>
1 parent 6a00a41 commit 8d4b87f

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

rust/kernel/str.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,10 @@ impl Index<ops::RangeFrom<usize>> for CStr {
193193
type Output = CStr;
194194

195195
#[inline]
196-
// Clippy false positive
197-
#[allow(clippy::unnecessary_operation)]
198196
fn index(&self, index: ops::RangeFrom<usize>) -> &Self::Output {
199197
// Delegate bounds checking to slice.
200-
&self.as_bytes()[index.start..];
198+
// Assign to _ to mute clippy's unnecessary operation warning.
199+
let _ = &self.as_bytes()[index.start..];
201200
// SAFETY: We just checked the bounds.
202201
unsafe { Self::from_bytes_with_nul_unchecked(&self.0[index.start..]) }
203202
}

0 commit comments

Comments
 (0)