Address lints in bevy_platform_support
(#18477)
# Objective @mockersf noticed there were some failing lints in `bevy_platform_support`. ## Solution Addressed the lints! ## Testing - CI
This commit is contained in:
parent
39b1ffc905
commit
04a0a74157
@ -1,12 +1,12 @@
|
||||
//! Provides `Barrier` and `BarrierWaitResult`
|
||||
|
||||
pub use barrier::{Barrier, BarrierWaitResult};
|
||||
pub use implementation::{Barrier, BarrierWaitResult};
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use std::sync as barrier;
|
||||
use std::sync as implementation;
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
mod barrier {
|
||||
mod implementation {
|
||||
use core::fmt;
|
||||
|
||||
/// Fallback implementation of `Barrier` from the standard library.
|
||||
|
@ -1,11 +1,11 @@
|
||||
//! Provides `LazyLock`
|
||||
|
||||
pub use lazy_lock::LazyLock;
|
||||
pub use implementation::LazyLock;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use std::sync as lazy_lock;
|
||||
use std::sync as implementation;
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
mod lazy_lock {
|
||||
mod implementation {
|
||||
pub use spin::Lazy as LazyLock;
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
//! Provides `Mutex` and `MutexGuard`
|
||||
|
||||
pub use mutex::{Mutex, MutexGuard};
|
||||
pub use implementation::{Mutex, MutexGuard};
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use std::sync as mutex;
|
||||
use std::sync as implementation;
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
mod mutex {
|
||||
mod implementation {
|
||||
use crate::sync::{LockResult, TryLockError, TryLockResult};
|
||||
use core::fmt;
|
||||
|
||||
@ -81,7 +81,7 @@ mod mutex {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: ?Sized + Default> Default for Mutex<T> {
|
||||
impl<T: Default> Default for Mutex<T> {
|
||||
fn default() -> Mutex<T> {
|
||||
Mutex::new(Default::default())
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
//! Provides `Once`, `OnceState`, `OnceLock`
|
||||
|
||||
pub use once::{Once, OnceLock, OnceState};
|
||||
pub use implementation::{Once, OnceLock, OnceState};
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use std::sync as once;
|
||||
use std::sync as implementation;
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
mod once {
|
||||
mod implementation {
|
||||
use core::{
|
||||
fmt,
|
||||
panic::{RefUnwindSafe, UnwindSafe},
|
||||
@ -145,6 +145,7 @@ mod once {
|
||||
/// Creates a new `Once` value.
|
||||
///
|
||||
/// See the standard library for further details.
|
||||
#[expect(clippy::new_without_default, reason = "matching std::sync::Once")]
|
||||
pub const fn new() -> Self {
|
||||
Self {
|
||||
inner: OnceLock::new(),
|
||||
|
@ -1,12 +1,12 @@
|
||||
//! Provides `LockResult`, `PoisonError`, `TryLockError`, `TryLockResult`
|
||||
|
||||
pub use poison::{LockResult, PoisonError, TryLockError, TryLockResult};
|
||||
pub use implementation::{LockResult, PoisonError, TryLockError, TryLockResult};
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use std::sync as poison;
|
||||
use std::sync as implementation;
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
mod poison {
|
||||
mod implementation {
|
||||
use core::{error::Error, fmt};
|
||||
|
||||
/// Fallback implementation of `PoisonError` from the standard library.
|
||||
|
@ -1,12 +1,12 @@
|
||||
//! TODO: Implement `RwLock`, `RwLockReadGuard`, `RwLockWriteGuard`
|
||||
//! Provides `RwLock`, `RwLockReadGuard`, `RwLockWriteGuard`
|
||||
|
||||
pub use rwlock::{RwLock, RwLockReadGuard, RwLockWriteGuard};
|
||||
pub use implementation::{RwLock, RwLockReadGuard, RwLockWriteGuard};
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use std::sync as rwlock;
|
||||
use std::sync as implementation;
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
mod rwlock {
|
||||
mod implementation {
|
||||
use crate::sync::{LockResult, TryLockError, TryLockResult};
|
||||
use core::fmt;
|
||||
|
||||
|
@ -36,7 +36,7 @@ impl Instant {
|
||||
let getter = ELAPSED_GETTER.load(Ordering::Acquire);
|
||||
|
||||
// SAFETY: Function pointer is always valid
|
||||
let getter = unsafe { core::mem::transmute::<_, fn() -> Duration>(getter) };
|
||||
let getter = unsafe { core::mem::transmute::<*mut (), fn() -> Duration>(getter) };
|
||||
|
||||
Self((getter)())
|
||||
}
|
||||
@ -149,28 +149,29 @@ impl fmt::Debug for Instant {
|
||||
}
|
||||
|
||||
fn unset_getter() -> Duration {
|
||||
let _nanos: u64;
|
||||
|
||||
#[cfg(target_arch = "x86")]
|
||||
unsafe {
|
||||
_nanos = core::arch::x86::_rdtsc();
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(target_arch = "x86")] {
|
||||
// SAFETY: standard technique for getting a nanosecond counter on x86
|
||||
let nanos = unsafe {
|
||||
core::arch::x86::_rdtsc()
|
||||
};
|
||||
Duration::from_nanos(nanos)
|
||||
} else if #[cfg(target_arch = "x86_64")] {
|
||||
// SAFETY: standard technique for getting a nanosecond counter on x86_64
|
||||
let nanos = unsafe {
|
||||
core::arch::x86_64::_rdtsc()
|
||||
};
|
||||
Duration::from_nanos(nanos)
|
||||
} else if #[cfg(target_arch = "aarch64")] {
|
||||
// SAFETY: standard technique for getting a nanosecond counter of aarch64
|
||||
let nanos = unsafe {
|
||||
let mut ticks: u64;
|
||||
core::arch::asm!("mrs {}, cntvct_el0", out(reg) ticks);
|
||||
ticks
|
||||
};
|
||||
Duration::from_nanos(nanos)
|
||||
} else {
|
||||
panic!("An elapsed time getter has not been provided to `Instant`. Please use `Instant::set_elapsed(...)` before calling `Instant::now()`")
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
unsafe {
|
||||
_nanos = core::arch::x86_64::_rdtsc();
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
unsafe {
|
||||
let mut ticks: u64;
|
||||
core::arch::asm!("mrs {}, cntvct_el0", out(reg) ticks);
|
||||
_nanos = ticks;
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64", target_arch = "aarch64")))]
|
||||
panic!("An elapsed time getter has not been provided to `Instant`. Please use `Instant::set_elapsed(...)` before calling `Instant::now()`");
|
||||
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64", target_arch = "aarch64"))]
|
||||
return Duration::from_nanos(_nanos);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user