Skip to content

Commit

Permalink
Add missing inline arguments, fix warnings.
Browse files Browse the repository at this point in the history
Signed-off-by: Tin Svagelj <tin.svagelj@live.com>
  • Loading branch information
Caellian committed Aug 29, 2023
1 parent ab4c5e9 commit 079c373
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
- name: Build default
run: cargo build --verbose
- name: Build no_std
run: cargo build --verbose --no-default-features --features no_std,error_in_core
- name: Build no_std with error_in_core
run: cargo build --verbose --no-default-features --features no_std
- name: Build no_std with error_in_core
run: cargo build --verbose --no-default-features --features no_std,error_in_core
- name: Build with ptr_metadata
run: cargo build --verbose --features ptr_metadata
- name: Build restrictive
Expand Down
11 changes: 10 additions & 1 deletion src/details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ impl MemoryImpl for ImplConcurrent {
Ok(())
}

#[inline(always)]
fn shrink_tracker(state: &mut Self::State) -> Result<Option<usize>, LockingError> {
let mut lock = state.tracker.lock_named(MutexKind::AllocationTracker)?;
Ok(lock.shrink_to_fit())
Expand Down Expand Up @@ -252,6 +253,7 @@ impl MemoryImpl for ImplDefault {
state.tracker.borrow_mut().resize(new_capacity)
}

#[inline(always)]
fn shrink_tracker(state: &mut Self::State) -> Result<Option<usize>, LockingError> {
Ok(state.tracker.borrow_mut().shrink_to_fit())
}
Expand Down Expand Up @@ -283,6 +285,7 @@ impl MemoryImpl for ImplFixed {
type StoreResult<T> = Result<*mut T, ContiguousMemoryError>;
type LockResult<T> = T;

#[inline(always)]
fn build_state(
base: *mut u8,
capacity: usize,
Expand Down Expand Up @@ -335,6 +338,7 @@ impl MemoryImpl for ImplFixed {
Err(ContiguousMemoryError::NoStorageLeft)
}

#[inline(always)]
fn shrink_tracker(state: &mut Self::State) -> Result<Option<usize>, LockingError> {
Ok(state.tracker.shrink_to_fit())
}
Expand Down Expand Up @@ -368,13 +372,14 @@ pub trait ReferenceImpl: Sized {
fn free_region(state: &mut Self::MemoryState, range: ByteRange) -> Option<*mut ()>;

/// Builds a reference for the stored data.
fn build_ref<T: 'static>(
fn build_ref<T: StoreRequirements>(
state: &Self::MemoryState,
addr: *mut T,
range: &ByteRange,
) -> Self::Type<T>;

/// Marks reference state as no longer being borrowed.
#[inline(always)]
fn unborrow_ref<T: ?Sized>(_state: &Self::RefState<T>) {}

unsafe fn cast<T, R>(from: Self::Type<T>) -> Self::Type<R>;
Expand Down Expand Up @@ -424,6 +429,7 @@ impl ReferenceImpl for ImplConcurrent {
}
}

#[inline(always)]
unsafe fn cast<T, R>(from: Self::Type<T>) -> Self::Type<R> {
SyncContiguousMemoryRef {
inner: core::mem::transmute(from.inner),
Expand Down Expand Up @@ -476,10 +482,12 @@ impl ReferenceImpl for ImplDefault {
}
}

#[inline(always)]
fn unborrow_ref<T: ?Sized>(state: &Self::RefState<T>) {
state.already_borrowed.set(false)
}

#[inline(always)]
unsafe fn cast<T, R>(from: Self::Type<T>) -> Self::Type<R> {
ContiguousMemoryRef {
inner: core::mem::transmute(from.inner),
Expand Down Expand Up @@ -514,6 +522,7 @@ impl ReferenceImpl for ImplFixed {
addr
}

#[inline(always)]
unsafe fn cast<T, R>(from: Self::Type<T>) -> Self::Type<R> {
from as *mut R
}
Expand Down
4 changes: 3 additions & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ use std::sync::MutexGuard;
use std::sync::PoisonError;

use core::alloc::LayoutError;
use core::fmt::{Debug, Display, Formatter, Result as FmtResult};
use core::fmt::Debug;
#[cfg(any(feature = "std", feature = "error_in_core"))]
use core::fmt::{Display, Formatter, Result as FmtResult};

use crate::range::ByteRange;

Expand Down
1 change: 1 addition & 0 deletions src/tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use core::alloc::Layout;

#[cfg(any(feature = "no_std"))]
use crate::types::*;
use crate::{error::ContiguousMemoryError, range::ByteRange};

Expand Down

0 comments on commit 079c373

Please sign in to comment.