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

Address clippy lints #224

Merged
merged 1 commit into from
Oct 29, 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
1 change: 1 addition & 0 deletions crates/private/tests/microkit/reset/src/bin/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#![no_std]
#![no_main]
#![allow(static_mut_refs)]

use sel4_microkit::{debug_println, protection_domain, NullHandler};
use sel4_reset::reset;
Expand Down
4 changes: 2 additions & 2 deletions crates/private/tests/root-task/c/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#![no_std]
#![no_main]

use core::ffi::{c_char, CStr};
use core::ffi::c_char;

use sel4_newlib as _;
use sel4_root_task::{debug_println, root_task};
Expand All @@ -18,7 +18,7 @@ extern "C" {

#[root_task]
fn main(_: &sel4::BootInfoPtr) -> ! {
let s = CStr::from_bytes_with_nul(b"1234\0").unwrap();
let s = c"1234";
let n = unsafe { test(s.as_ptr()) };
debug_println!("n = {}", n);
assert_eq!(n, 1234 + 234);
Expand Down
2 changes: 1 addition & 1 deletion crates/sel4-async/time/src/timer_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ pub struct IterExpired<'a, T, U, V> {
queue: &'a mut TimerQueue<T, U, V>,
}

impl<'a, T: Ord + Clone, U: Ord, V> Iterator for IterExpired<'a, T, U, V> {
impl<T: Ord + Clone, U: Ord, V> Iterator for IterExpired<'_, T, U, V> {
type Item = Expired<T, U, V>;

fn next(&mut self) -> Option<Self::Item> {
Expand Down
4 changes: 2 additions & 2 deletions crates/sel4-atomic-ptr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub struct AtomicPtr<'a, T> {
reference: PhantomData<&'a T>,
}

impl<'a, T> Copy for AtomicPtr<'a, T> {}
impl<T> Copy for AtomicPtr<'_, T> {}

impl<T> Clone for AtomicPtr<'_, T> {
fn clone(&self) -> Self {
Expand All @@ -40,7 +40,7 @@ impl<T> fmt::Debug for AtomicPtr<'_, T> {
}
}

impl<'a, T> AtomicPtr<'a, T> {
impl<T> AtomicPtr<'_, T> {
/// # Safety
///
/// Necessary but not sufficient:
Expand Down
4 changes: 2 additions & 2 deletions crates/sel4-atomic-ptr/src/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use core::sync::atomic::Ordering;

use super::{generic, Atomic, AtomicPtr};

impl<'a, T> AtomicPtr<'a, T> {
impl<T> AtomicPtr<'_, T> {
fn as_mut_ptr(self) -> *mut T {
self.pointer.as_ptr()
}
Expand All @@ -18,7 +18,7 @@ impl<'a, T> AtomicPtr<'a, T> {
}
}

impl<'a, T: Atomic> AtomicPtr<'a, T> {
impl<T: Atomic> AtomicPtr<'_, T> {
#[inline]
pub fn load(self, order: Ordering) -> T {
// SAFETY: data races are prevented by atomic intrinsics.
Expand Down
2 changes: 1 addition & 1 deletion crates/sel4-backtrace/types/src/with_alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl<T> Backtrace<T> {
pub struct DisplayHex<'a, T>(&'a Backtrace<T>);

#[cfg(feature = "postcard")]
impl<'a, T: Serialize> fmt::Display for DisplayHex<'a, T> {
impl<T: Serialize> fmt::Display for DisplayHex<'_, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
for b in self.0.send_to_vec().map_err(|_| fmt::Error)? {
write!(f, "{:02x}", b)?;
Expand Down
2 changes: 1 addition & 1 deletion crates/sel4-capdl-initializer/add-spec/src/render_elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub(crate) struct RenderElfArgs<'a> {
pub(crate) heap_size: usize,
}

impl<'a> RenderElfArgs<'a> {
impl RenderElfArgs<'_> {
pub(crate) fn call_with<T: FileHeader<Word: NumCast + PatchValue>>(
&self,
orig_elf: &object::read::elf::ElfFile<T>,
Expand Down
12 changes: 6 additions & 6 deletions crates/sel4-capdl-initializer/types/src/cap_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub trait HasCapTable {
}
}

impl<'a> object::Tcb<'a> {
impl object::Tcb<'_> {
pub const SLOT_CSPACE: CapSlot = 0;
pub const SLOT_VSPACE: CapSlot = 1;
pub const SLOT_IPC_BUFFER: CapSlot = 4;
Expand Down Expand Up @@ -93,31 +93,31 @@ impl<'a> object::Tcb<'a> {
}
}

impl<'a> object::Irq<'a> {
impl object::Irq<'_> {
pub const SLOT_NOTIFICATION: CapSlot = 0;

pub fn notification(&self) -> Option<&cap::Notification> {
self.maybe_slot_as(Self::SLOT_NOTIFICATION)
}
}

impl<'a> object::ArmIrq<'a> {
impl object::ArmIrq<'_> {
pub const SLOT_NOTIFICATION: CapSlot = 0;

pub fn notification(&self) -> Option<&cap::Notification> {
self.maybe_slot_as(Self::SLOT_NOTIFICATION)
}
}

impl<'a> object::IrqMsi<'a> {
impl object::IrqMsi<'_> {
pub const SLOT_NOTIFICATION: CapSlot = 0;

pub fn notification(&self) -> Option<&cap::Notification> {
self.maybe_slot_as(Self::SLOT_NOTIFICATION)
}
}

impl<'a> object::IrqIOApic<'a> {
impl object::IrqIOApic<'_> {
pub const SLOT_NOTIFICATION: CapSlot = 0;

pub fn notification(&self) -> Option<&cap::Notification> {
Expand All @@ -127,7 +127,7 @@ impl<'a> object::IrqIOApic<'a> {

// // //

impl<'a> object::PageTable<'a> {
impl object::PageTable<'_> {
pub fn entries(&self) -> impl Iterator<Item = (CapSlot, PageTableEntry)> {
self.slots_as()
}
Expand Down
14 changes: 7 additions & 7 deletions crates/sel4-capdl-initializer/types/src/footprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl Footprint for IndirectEmbeddedFrame {}
#[cfg(feature = "deflate")]
impl Footprint for IndirectDeflatedBytesContent {}

impl<'a, T: Sized + Footprint> Footprint for Indirect<'a, T> {
impl<T: Sized + Footprint> Footprint for Indirect<'_, T> {
fn external_footprint(&self) -> usize {
self.inner().total_footprint()
}
Expand All @@ -51,27 +51,27 @@ impl<T: Footprint> Footprint for Option<T> {
}
}

impl<'a, T: Footprint> Footprint for Indirect<'a, [T]> {
impl<T: Footprint> Footprint for Indirect<'_, [T]> {
fn external_footprint(&self) -> usize {
self.inner().iter().map(Footprint::total_footprint).sum()
}
}

impl<'a, N: Footprint, D: Footprint, M: Footprint> Footprint for Spec<'a, N, D, M> {
impl<N: Footprint, D: Footprint, M: Footprint> Footprint for Spec<'_, N, D, M> {
fn external_footprint(&self) -> usize {
self.objects.external_footprint()
+ self.irqs.external_footprint()
+ self.asid_slots.external_footprint()
}
}

impl<'a, N: Footprint, D: Footprint, M: Footprint> Footprint for NamedObject<'a, N, D, M> {
impl<N: Footprint, D: Footprint, M: Footprint> Footprint for NamedObject<'_, N, D, M> {
fn external_footprint(&self) -> usize {
self.name.external_footprint() + self.object.external_footprint()
}
}

impl<'a, D: Footprint, M: Footprint> Footprint for Object<'a, D, M> {
impl<D: Footprint, M: Footprint> Footprint for Object<'_, D, M> {
fn external_footprint(&self) -> usize {
match self {
Self::CNode(obj) => obj.slots.external_footprint(),
Expand All @@ -85,7 +85,7 @@ impl<'a, D: Footprint, M: Footprint> Footprint for Object<'a, D, M> {
}
}

impl<'a, D: Footprint, M: Footprint> Footprint for FrameInit<'a, D, M> {
impl<D: Footprint, M: Footprint> Footprint for FrameInit<'_, D, M> {
fn external_footprint(&self) -> usize {
match self {
Self::Fill(fill) => fill.external_footprint(),
Expand All @@ -94,7 +94,7 @@ impl<'a, D: Footprint, M: Footprint> Footprint for FrameInit<'a, D, M> {
}
}

impl<'a, D: Footprint> Footprint for Fill<'a, D> {
impl<D: Footprint> Footprint for Fill<'_, D> {
fn external_footprint(&self) -> usize {
self.entries.external_footprint()
}
Expand Down
16 changes: 8 additions & 8 deletions crates/sel4-capdl-initializer/types/src/frame_init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl<'a, D> FrameInit<'a, D, NeverEmbedded> {
}
}

impl<'a, D> object::Frame<'a, D, NeverEmbedded> {
impl<D> object::Frame<'_, D, NeverEmbedded> {
pub fn can_embed(&self, granule_size_bits: usize, is_root: bool) -> bool {
is_root
&& self.paddr.is_none()
Expand Down Expand Up @@ -167,7 +167,7 @@ pub struct Fill<'a, D> {
pub entries: Indirect<'a, [FillEntry<D>]>,
}

impl<'a, D> Fill<'a, D> {
impl<D> Fill<'_, D> {
pub fn depends_on_bootinfo(&self) -> bool {
self.entries.iter().any(|entry| entry.content.is_bootinfo())
}
Expand Down Expand Up @@ -278,19 +278,19 @@ pub struct BytesContent<'a> {
}

#[cfg(feature = "alloc")]
impl<'a> BytesContent<'a> {
impl BytesContent<'_> {
pub fn pack(raw_content: &[u8]) -> Vec<u8> {
raw_content.to_vec()
}
}

impl<'a> SelfContainedContent for BytesContent<'a> {
impl SelfContainedContent for BytesContent<'_> {
fn self_contained_copy_out(&self, dst: &mut [u8]) {
dst.copy_from_slice(self.bytes)
}
}

impl<'a> fmt::Debug for BytesContent<'a> {
impl fmt::Debug for BytesContent<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("BytesContent")
.field("bytes", &"&[...]")
Expand All @@ -306,14 +306,14 @@ pub struct DeflatedBytesContent<'a> {
}

#[cfg(all(feature = "alloc", feature = "deflate"))]
impl<'a> DeflatedBytesContent<'a> {
impl DeflatedBytesContent<'_> {
pub fn pack(raw_content: &[u8]) -> Vec<u8> {
miniz_oxide::deflate::compress_to_vec(raw_content, 10)
}
}

#[cfg(feature = "deflate")]
impl<'a> SelfContainedContent for DeflatedBytesContent<'a> {
impl SelfContainedContent for DeflatedBytesContent<'_> {
fn self_contained_copy_out(&self, dst: &mut [u8]) {
let n = miniz_oxide::inflate::decompress_slice_iter_to_slice(
dst,
Expand All @@ -327,7 +327,7 @@ impl<'a> SelfContainedContent for DeflatedBytesContent<'a> {
}

#[cfg(feature = "deflate")]
impl<'a> fmt::Debug for DeflatedBytesContent<'a> {
impl fmt::Debug for DeflatedBytesContent<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("DeflatedBytesContent")
.field("deflated_bytes", &"&[...]")
Expand Down
3 changes: 2 additions & 1 deletion crates/sel4-capdl-initializer/types/src/indirect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ enum IndirectImpl<'a, T: ?Sized> {
},
}

#[allow(clippy::needless_lifetimes)]
impl<'a, T: ?Sized> Indirect<'a, T> {
#[cfg(feature = "borrowed-indirect")]
pub const fn from_borrowed(borrowed: &'a T) -> Self {
Expand Down Expand Up @@ -121,7 +122,7 @@ impl<T: fmt::Debug + ?Sized> fmt::Debug for Indirect<'_, T> {
}
}

impl<'a, 'b, T: ?Sized, U: ?Sized> PartialEq<Indirect<'b, U>> for Indirect<'a, T>
impl<'b, T: ?Sized, U: ?Sized> PartialEq<Indirect<'b, U>> for Indirect<'_, T>
where
T: PartialEq<U>,
{
Expand Down
2 changes: 1 addition & 1 deletion crates/sel4-capdl-initializer/types/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub enum Object<'a, D, M> {
Reply,
}

impl<'a, D, M> Object<'a, D, M> {
impl<D, M> Object<'_, D, M> {
pub fn paddr(&self) -> Option<usize> {
match self {
Object::Untyped(obj) => obj.paddr,
Expand Down
2 changes: 1 addition & 1 deletion crates/sel4-capdl-initializer/types/src/when_sel4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use sel4::{ObjectBlueprint, VmAttributes};

use crate::{cap, Badge, Cap, FillEntryContentBootInfoId, Object, Rights};

impl<'a, D, M> Object<'a, D, M> {
impl<D, M> Object<'_, D, M> {
pub fn blueprint(&self) -> Option<ObjectBlueprint> {
Some(sel4::sel4_cfg_wrap_match! {
match self {
Expand Down
2 changes: 1 addition & 1 deletion crates/sel4-kernel-loader/payload-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pub struct DirectRegionContent<'a> {
pub content: &'a [u8],
}

impl<'a> RegionContent for DirectRegionContent<'a> {
impl RegionContent for DirectRegionContent<'_> {
type Source = ();

fn len(&self) -> usize {
Expand Down
2 changes: 1 addition & 1 deletion crates/sel4-logging/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ struct DisplayWrapper<'a> {
record: &'a Record<'a>,
}

impl<'a> fmt::Display for DisplayWrapper<'a> {
impl fmt::Display for DisplayWrapper<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
(self.fmt)(self.record, f)
}
Expand Down
4 changes: 2 additions & 2 deletions crates/sel4-mod-in-out-dir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ use syn::{parse_macro_input, ItemMod, MetaNameValue, Result};
/// #[path = concat!(env!("OUT_DIR"), "/foo.rs")]
/// mod foo;
/// ```

///
/// This macro does exactly that:
/// ```ignore
/// #[in_out_dir]
/// mod foo;
/// ```

///
/// This works too:
/// ```ignore
/// #[in_out_dir(relative_path = "path/to/bar.rs")]
Expand Down
3 changes: 1 addition & 2 deletions crates/sel4-panicking/env/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ pub struct AbortInfo<'a> {
location: Option<&'a Location<'a>>,
}

impl<'a> AbortInfo<'a> {
impl AbortInfo<'_> {
/// The `core::fmt::Arguments` with which [`abort!`] was called.
pub fn message(&self) -> Option<&fmt::Arguments> {
self.message
Expand Down Expand Up @@ -211,7 +211,6 @@ pub fn __abort_macro_helper(message: Option<fmt::Arguments>) -> ! {
/// the [`AbortInfo`] argument using [`debug_print!`].
///
/// [`register_abort_hook`] provides a typesafe way to define that symbol.

#[macro_export]
macro_rules! abort {
() => ($crate::__abort_macro_helper(::core::option::Option::None));
Expand Down
2 changes: 1 addition & 1 deletion crates/sel4-panicking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub struct ExternalPanicInfo<'a> {
can_unwind: bool,
}

impl<'a> ExternalPanicInfo<'a> {
impl ExternalPanicInfo<'_> {
pub fn payload(&self) -> &Payload {
&self.payload
}
Expand Down
2 changes: 1 addition & 1 deletion crates/sel4-reset/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct Regions<'a> {
data: &'a [u8],
}

impl<'a> Regions<'a> {
impl Regions<'_> {
unsafe fn reset_memory(&self) {
for meta in self.meta {
let dst = unsafe { slice::from_raw_parts_mut(meta.vaddr as *mut _, meta.memsz) };
Expand Down
8 changes: 4 additions & 4 deletions crates/sel4-shared-ring-buffer/block-io/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ impl<'a, N, P: Access, A: AbstractBounceBufferAllocator, F: FnMut()> RequestFutu
}
}

impl<'a, N, P: Access, A: AbstractBounceBufferAllocator, F: FnMut()> Future
for RequestFuture<'a, N, P, A, F>
impl<N, P: Access, A: AbstractBounceBufferAllocator, F: FnMut()> Future
for RequestFuture<'_, N, P, A, F>
{
type Output = Result<(), Error>;

Expand All @@ -182,8 +182,8 @@ impl<'a, N, P: Access, A: AbstractBounceBufferAllocator, F: FnMut()> Future
}
}

impl<'a, N, P: Access, A: AbstractBounceBufferAllocator, F: FnMut()> Drop
for RequestFuture<'a, N, P, A, F>
impl<N, P: Access, A: AbstractBounceBufferAllocator, F: FnMut()> Drop
for RequestFuture<'_, N, P, A, F>
{
fn drop(&mut self) {
if !self.poll_returned_ready {
Expand Down
Loading
Loading