Skip to content

Commit

Permalink
(not to be included in message) use fully qualified path on traits an…
Browse files Browse the repository at this point in the history
…d macros for better readability
  • Loading branch information
dingxiangfei2009 committed Nov 28, 2024
1 parent c92d770 commit 507c541
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions rust/kernel/sync/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ use crate::{
try_init,
types::{ForeignOwnable, Opaque},
};
#[cfg(CONFIG_RUST_COERCE_POINTEE)]
use core::marker::CoercePointee;
#[cfg(not(CONFIG_RUST_COERCE_POINTEE))]
use core::marker::Unsize;
use core::{
alloc::Layout,
fmt,
Expand Down Expand Up @@ -130,7 +126,7 @@ mod std_vendor;
/// # Ok::<(), Error>(())
/// ```
#[repr(transparent)]
#[cfg_attr(CONFIG_RUST_COERCE_POINTEE, derive(CoercePointee))]
#[cfg_attr(CONFIG_RUST_COERCE_POINTEE, derive(core::marker::CoercePointee))]
pub struct Arc<T: ?Sized> {
ptr: NonNull<ArcInner<T>>,
_p: PhantomData<ArcInner<T>>,
Expand Down Expand Up @@ -179,11 +175,11 @@ impl<T: ?Sized> ArcInner<T> {
// This is to allow coercion from `Arc<T>` to `Arc<U>` if `T` can be converted to the
// dynamically-sized type (DST) `U`.
#[cfg(not(CONFIG_RUST_COERCE_POINTEE))]
impl<T: ?Sized + Unsize<U>, U: ?Sized> core::ops::CoerceUnsized<Arc<U>> for Arc<T> {}
impl<T: ?Sized + core::marker::Unsize<U>, U: ?Sized> core::ops::CoerceUnsized<Arc<U>> for Arc<T> {}

// This is to allow `Arc<U>` to be dispatched on when `Arc<T>` can be coerced into `Arc<U>`.
#[cfg(not(CONFIG_RUST_COERCE_POINTEE))]
impl<T: ?Sized + Unsize<U>, U: ?Sized> core::ops::DispatchFromDyn<Arc<U>> for Arc<T> {}
impl<T: ?Sized + core::marker::Unsize<U>, U: ?Sized> core::ops::DispatchFromDyn<Arc<U>> for Arc<T> {}

// SAFETY: It is safe to send `Arc<T>` to another thread when the underlying `T` is `Sync` because
// it effectively means sharing `&T` (which is safe because `T` is `Sync`); additionally, it needs
Expand Down Expand Up @@ -480,7 +476,7 @@ impl<T: ?Sized> From<Pin<UniqueArc<T>>> for Arc<T> {
/// # Ok::<(), Error>(())
/// ```
#[repr(transparent)]
#[cfg_attr(CONFIG_RUST_COERCE_POINTEE, derive(CoercePointee))]
#[cfg_attr(CONFIG_RUST_COERCE_POINTEE, derive(core::marker::CoercePointee))]
pub struct ArcBorrow<'a, T: ?Sized + 'a> {
inner: NonNull<ArcInner<T>>,
_p: PhantomData<&'a ()>,
Expand All @@ -489,7 +485,7 @@ pub struct ArcBorrow<'a, T: ?Sized + 'a> {
// This is to allow `ArcBorrow<U>` to be dispatched on when `ArcBorrow<T>` can be coerced into
// `ArcBorrow<U>`.
#[cfg(not(CONFIG_RUST_COERCE_POINTEE))]
impl<T: ?Sized + Unsize<U>, U: ?Sized> core::ops::DispatchFromDyn<ArcBorrow<'_, U>>
impl<T: ?Sized + core::marker::Unsize<U>, U: ?Sized> core::ops::DispatchFromDyn<ArcBorrow<'_, U>>
for ArcBorrow<'_, T>
{
}
Expand Down

0 comments on commit 507c541

Please sign in to comment.