Skip to content

Commit 003d799

Browse files
committed
rust: arc: improve sentences in comments from mainline
This is part of the effort to minimize the differences of the `rust` branch with respect to mainline in order to eventually drop it. Signed-off-by: Miguel Ojeda <[email protected]>
1 parent 25d4f09 commit 003d799

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

rust/kernel/sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//! Synchronisation primitives.
44
//!
55
//! This module contains the kernel APIs related to synchronisation that have been ported or
6-
//! wrapped for usage by Rust code in the kernel and is shared by all of them.
6+
//! wrapped for usage by Rust code in the kernel.
77
//!
88
//! # Examples
99
//!

rust/kernel/sync/arc.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,13 @@ impl<T: ?Sized + Unsize<U>, U: ?Sized> core::ops::DispatchFromDyn<Arc<U>> for Ar
142142

143143
// SAFETY: It is safe to send `Arc<T>` to another thread when the underlying `T` is `Sync` because
144144
// it effectively means sharing `&T` (which is safe because `T` is `Sync`); additionally, it needs
145-
// `T` to be `Send` because any thread that has a `Arc<T>` may ultimately access `T` directly, for
145+
// `T` to be `Send` because any thread that has an `Arc<T>` may ultimately access `T` directly, for
146146
// example, when the reference count reaches zero and `T` is dropped.
147147
unsafe impl<T: ?Sized + Sync + Send> Send for Arc<T> {}
148148

149-
// SAFETY: It is safe to send `&Arc<T>` to another thread when the underlying `T` is `Sync` for
150-
// the same reason as above. `T` needs to be `Send` as well because a thread can clone a `&Arc<T>`
151-
// into a `Arc<T>`, which may lead to `T` being accessed by the same reasoning as above.
149+
// SAFETY: It is safe to send `&Arc<T>` to another thread when the underlying `T` is `Sync` for the
150+
// same reason as above. `T` needs to be `Send` as well because a thread can clone an `&Arc<T>`
151+
// into an `Arc<T>`, which may lead to `T` being accessed by the same reasoning as above.
152152
unsafe impl<T: ?Sized + Sync + Send> Sync for Arc<T> {}
153153

154154
impl<T> Arc<T> {
@@ -237,8 +237,9 @@ impl<T: ?Sized> Arc<T> {
237237
/// receiver), but we have a [`Arc`] instead. Getting a [`ArcBorrow`] is free when optimised.
238238
#[inline]
239239
pub fn as_arc_borrow(&self) -> ArcBorrow<'_, T> {
240-
// SAFETY: The constraint that lifetime of the shared reference must outlive that of
241-
// the returned `ArcBorrow` ensures that the object remains alive.
240+
// SAFETY: The constraint that the lifetime of the shared reference must outlive that of
241+
// the returned `ArcBorrow` ensures that the object remains alive and that no mutable
242+
// reference can be created.
242243
unsafe { ArcBorrow::new(self.ptr) }
243244
}
244245
}
@@ -402,8 +403,8 @@ impl<T: ?Sized> ArcBorrow<'_, T> {
402403
/// # Safety
403404
///
404405
/// Callers must ensure the following for the lifetime of the returned [`ArcBorrow`] instance:
405-
/// 1. That `obj` remains valid;
406-
/// 2. That no mutable references to `obj` are created.
406+
/// 1. That `inner` remains valid;
407+
/// 2. That no mutable references to `inner` are created.
407408
unsafe fn new(inner: NonNull<ArcInner<T>>) -> Self {
408409
// INVARIANT: The safety requirements guarantee the invariants.
409410
Self {
@@ -436,15 +437,15 @@ impl<T: ?Sized> Deref for ArcBorrow<'_, T> {
436437

437438
/// A refcounted object that is known to have a refcount of 1.
438439
///
439-
/// It is mutable and can be converted to a [`Arc`] so that it can be shared.
440+
/// It is mutable and can be converted to an [`Arc`] so that it can be shared.
440441
///
441442
/// # Invariants
442443
///
443444
/// `inner` always has a reference count of 1.
444445
///
445446
/// # Examples
446447
///
447-
/// In the following example, we make changes to the inner object before turning it into a
448+
/// In the following example, we make changes to the inner object before turning it into an
448449
/// `Arc<Test>` object (after which point, it cannot be mutated directly). Note that `x.into()`
449450
/// cannot fail.
450451
///

0 commit comments

Comments
 (0)