Skip to content

Commit d2f7e0c

Browse files
committed
clippy
Signed-off-by: Ludvig Liljenberg <[email protected]>
1 parent 28cc6f7 commit d2f7e0c

File tree

9 files changed

+13
-20
lines changed

9 files changed

+13
-20
lines changed

src/hyperlight_common/src/flatbuffer_wrappers/host_function_details.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,8 @@ impl HostFunctionDetails {
5757
/// Sort the host functions by name.
5858
#[cfg_attr(feature = "tracing", instrument(skip_all, parent = Span::current(), level= "Trace"))]
5959
pub fn sort_host_functions_by_name(&mut self) {
60-
match &mut self.host_functions {
61-
Some(host_functions) => {
62-
host_functions.sort_by(|a, b| a.function_name.cmp(&b.function_name))
63-
}
64-
None => {}
60+
if let Some(host_functions) = &mut self.host_functions {
61+
host_functions.sort_by(|a, b| a.function_name.cmp(&b.function_name))
6562
}
6663
}
6764

src/hyperlight_common/src/flatbuffer_wrappers/util.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ pub trait FlatbufferSerializable {
4646
}
4747

4848
/// Implementations for basic types below
49-
5049
impl FlatbufferSerializable for () {
5150
fn serialize(&self, builder: &mut FlatBufferBuilder) -> FbFunctionCallResultArgs {
5251
FbFunctionCallResultArgs {

src/hyperlight_host/src/hypervisor/inprocess.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl Debug for InprocessDriver<'_> {
6666
}
6767
}
6868

69-
impl<'a> Hypervisor for InprocessDriver<'a> {
69+
impl Hypervisor for InprocessDriver<'_> {
7070
fn initialise(
7171
&mut self,
7272
_peb_addr: crate::mem::ptr::RawPtr,

src/hyperlight_host/src/mem/custom_drop.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub(crate) struct CustomPtrDrop<'a, EltT> {
3333
drop: Box<dyn Fn(*mut EltT) + 'a + Send>,
3434
}
3535

36-
impl<'a, EltT> CustomPtrDrop<'a, EltT> {
36+
impl<EltT> CustomPtrDrop<'_, EltT> {
3737
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
3838
pub(crate) fn new(elt: *mut EltT, drop_fn: Box<dyn Fn(*mut EltT) + Send>) -> Self {
3939
Self {
@@ -47,13 +47,13 @@ impl<'a, EltT> CustomPtrDrop<'a, EltT> {
4747
}
4848
}
4949

50-
impl<'a, EltT> Debug for CustomPtrDrop<'a, EltT> {
50+
impl<EltT> Debug for CustomPtrDrop<'_, EltT> {
5151
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5252
f.debug_struct("CustomDrop").finish()
5353
}
5454
}
5555

56-
impl<'a, EltT> Drop for CustomPtrDrop<'a, EltT> {
56+
impl<EltT> Drop for CustomPtrDrop<'_, EltT> {
5757
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
5858
fn drop(&mut self) {
5959
let drop_fn = &self.drop;

src/hyperlight_host/src/mem/layout.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -739,8 +739,7 @@ impl SandboxMemoryLayout {
739739

740740
// Get the number of pages needed for the PTs
741741

742-
let num_pages: usize = ((total_mapped_memory_size + AMOUNT_OF_MEMORY_PER_PT - 1)
743-
/ AMOUNT_OF_MEMORY_PER_PT)
742+
let num_pages: usize = total_mapped_memory_size.div_ceil(AMOUNT_OF_MEMORY_PER_PT)
744743
+ 1 // Round up
745744
+ 3; // PML4, PDPT, PD
746745

src/hyperlight_host/src/mem/mgr.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,7 @@ where
181181

182182
let mem_size = usize::try_from(mem_size)?;
183183

184-
let num_pages: usize =
185-
((mem_size + AMOUNT_OF_MEMORY_PER_PT - 1) / AMOUNT_OF_MEMORY_PER_PT) + 1;
184+
let num_pages: usize = mem_size.div_ceil(AMOUNT_OF_MEMORY_PER_PT) + 1;
186185

187186
// Create num_pages PT with 512 PTEs
188187
for p in 0..num_pages {

src/hyperlight_host/src/mem/pe/base_relocations.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl<'a> BaseRelocations<'a> {
7171
}
7272
}
7373

74-
impl<'a> Iterator for BaseRelocations<'a> {
74+
impl Iterator for BaseRelocations<'_> {
7575
type Item = BaseRelocation;
7676
fn next(&mut self) -> Option<Self::Item> {
7777
// Check if we can read 2 bytes from the array

src/hyperlight_host/src/sandbox/leaked_outb.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pub(crate) struct LeakedOutBWrapper<'a> {
7979
hdl_ptr: Arc<Mutex<CustomPtrDrop<'a, OutBHandlerWrapper>>>,
8080
}
8181

82-
impl<'a> LeakedOutBWrapper<'a> {
82+
impl LeakedOutBWrapper<'_> {
8383
#[instrument(skip_all, parent = Span::current(), level = "Trace")]
8484
pub(crate) fn new(
8585
mgr: &mut SandboxMemoryManager<GuestSharedMemory>,

src/hyperlight_host/src/sandbox_state/transition.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ impl<Cur: Sandbox, Next: Sandbox> TransitionMetadata<Cur, Next> for Noop<Cur, Ne
100100
/// };
101101
/// let mutating_cb = MultiUseContextCallback::from(my_cb_fn);
102102
/// ```
103-
104103
pub struct MultiUseContextCallback<'func, Cur: Sandbox, F>
105104
where
106105
F: FnOnce(&mut MultiUseGuestCallContext) -> Result<()> + 'func,
@@ -110,14 +109,14 @@ where
110109
cb: F,
111110
}
112111

113-
impl<'a, Cur: Sandbox, Next: Sandbox, F> TransitionMetadata<Cur, Next>
114-
for MultiUseContextCallback<'a, Cur, F>
112+
impl<Cur: Sandbox, Next: Sandbox, F> TransitionMetadata<Cur, Next>
113+
for MultiUseContextCallback<'_, Cur, F>
115114
where
116115
F: FnOnce(&mut MultiUseGuestCallContext) -> Result<()>,
117116
{
118117
}
119118

120-
impl<'a, Cur: Sandbox, F> MultiUseContextCallback<'a, Cur, F>
119+
impl<Cur: Sandbox, F> MultiUseContextCallback<'_, Cur, F>
121120
where
122121
F: FnOnce(&mut MultiUseGuestCallContext) -> Result<()>,
123122
{

0 commit comments

Comments
 (0)