Skip to content

Commit

Permalink
Add #[inline] to fmt impls
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Mar 15, 2024
1 parent 2b9c48a commit b623e70
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1406,15 +1406,15 @@ impl<T> From<*mut T> for AtomicPtr<T> {
}

impl<T> fmt::Debug for AtomicPtr<T> {
#[allow(clippy::missing_inline_in_public_items)] // fmt is not hot path
#[inline] // fmt is not hot path, but #[inline] on fmt seems to still be useful: https://github.com/rust-lang/rust/pull/117727
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// std atomic types use Relaxed in Debug::fmt: https://github.com/rust-lang/rust/blob/1.70.0/library/core/src/sync/atomic.rs#L2024
fmt::Debug::fmt(&self.load(Ordering::Relaxed), f)
}
}

impl<T> fmt::Pointer for AtomicPtr<T> {
#[allow(clippy::missing_inline_in_public_items)] // fmt is not hot path
#[inline] // fmt is not hot path, but #[inline] on fmt seems to still be useful: https://github.com/rust-lang/rust/pull/117727
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// std atomic types use Relaxed in Debug::fmt: https://github.com/rust-lang/rust/blob/1.70.0/library/core/src/sync/atomic.rs#L2024
fmt::Pointer::fmt(&self.load(Ordering::Relaxed), f)
Expand Down
2 changes: 1 addition & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ macro_rules! const_fn {
macro_rules! impl_debug_and_serde {
($atomic_type:ident) => {
impl fmt::Debug for $atomic_type {
#[allow(clippy::missing_inline_in_public_items)] // fmt is not hot path
#[inline] // fmt is not hot path, but #[inline] on fmt seems to still be useful: https://github.com/rust-lang/rust/pull/117727
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// std atomic types use Relaxed in Debug::fmt: https://github.com/rust-lang/rust/blob/1.70.0/library/core/src/sync/atomic.rs#L2024
fmt::Debug::fmt(&self.load(Ordering::Relaxed), f)
Expand Down

0 comments on commit b623e70

Please sign in to comment.