Skip to content

Commit ba6e0f2

Browse files
committed
std: update broken links in thread module
1 parent e072337 commit ba6e0f2

File tree

6 files changed

+38
-17
lines changed

6 files changed

+38
-17
lines changed

library/std/src/thread/builder.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use crate::io;
3939
/// [`stack_size`]: Builder::stack_size
4040
/// [`name`]: Builder::name
4141
/// [`spawn`]: Builder::spawn
42-
/// [`thread::spawn`]: spawn
42+
/// [`thread::spawn`]: super::spawn
4343
/// [`io::Result`]: crate::io::Result
4444
/// [`unwrap`]: crate::result::Result::unwrap
4545
/// [naming-threads]: ./index.html#naming-threads
@@ -133,10 +133,12 @@ impl Builder {
133133
self
134134
}
135135

136-
/// Disables running and inheriting [spawn hooks](add_spawn_hook).
136+
/// Disables running and inheriting [spawn hooks].
137137
///
138138
/// Use this if the parent thread is in no way relevant for the child thread.
139139
/// For example, when lazily spawning threads for a thread pool.
140+
///
141+
/// [spawn hooks]: super::add_spawn_hook
140142
#[unstable(feature = "thread_spawn_hook", issue = "132951")]
141143
pub fn no_hooks(mut self) -> Builder {
142144
self.no_hooks = true;
@@ -151,7 +153,7 @@ impl Builder {
151153
/// thread finishes). The join handle can be used to block on
152154
/// termination of the spawned thread, including recovering its panics.
153155
///
154-
/// For a more complete documentation see [`thread::spawn`][`spawn`].
156+
/// For a more complete documentation see [`thread::spawn`].
155157
///
156158
/// # Errors
157159
///
@@ -178,6 +180,9 @@ impl Builder {
178180
///
179181
/// handler.join().unwrap();
180182
/// ```
183+
///
184+
/// [`thread::spawn`]: super::spawn
185+
/// [`spawn`]: super::spawn
181186
#[stable(feature = "rust1", since = "1.0.0")]
182187
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
183188
pub fn spawn<F, T>(self, f: F) -> io::Result<JoinHandle<T>>
@@ -199,7 +204,7 @@ impl Builder {
199204
///
200205
/// This method is identical to [`thread::Builder::spawn`][`Builder::spawn`],
201206
/// except for the relaxed lifetime bounds, which render it unsafe.
202-
/// For a more complete documentation see [`thread::spawn`][`spawn`].
207+
/// For a more complete documentation see [`thread::spawn`].
203208
///
204209
/// # Errors
205210
///
@@ -221,7 +226,7 @@ impl Builder {
221226
/// data is dropped
222227
/// - use only types with `'static` lifetime bounds, i.e., those with no or only
223228
/// `'static` references (both [`thread::Builder::spawn`][`Builder::spawn`]
224-
/// and [`thread::spawn`][`spawn`] enforce this property statically)
229+
/// and [`thread::spawn`] enforce this property statically)
225230
///
226231
/// # Examples
227232
///
@@ -246,6 +251,8 @@ impl Builder {
246251
/// ```
247252
///
248253
/// [`io::Result`]: crate::io::Result
254+
/// [`thread::spawn`]: super::spawn
255+
/// [`spawn`]: super::spawn
249256
#[stable(feature = "thread_spawn_unchecked", since = "1.82.0")]
250257
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
251258
pub unsafe fn spawn_unchecked<F, T>(self, f: F) -> io::Result<JoinHandle<T>>

library/std/src/thread/functions.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,8 @@ impl Drop for PanicGuard {
517517
/// parked_thread.join().unwrap();
518518
/// ```
519519
///
520-
/// [`unpark`]: Thread::unpark
520+
/// [`Thread`]: super::Thread
521+
/// [`unpark`]: super::Thread::unpark
521522
/// [`thread::park_timeout`]: park_timeout
522523
/// [release sequence]: https://en.cppreference.com/w/cpp/atomic/memory_order#Release_sequence
523524
#[stable(feature = "rust1", since = "1.0.0")]

library/std/src/thread/id.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ use crate::sync::atomic::{Atomic, Ordering};
2424
/// assert!(thread::current().id() != other_thread_id);
2525
/// ```
2626
///
27-
/// [`id`]: Thread::id
27+
/// [`Thread`]: super::Thread
28+
/// [`id`]: super::Thread::id
2829
#[stable(feature = "thread_id", since = "1.19.0")]
2930
#[derive(Eq, PartialEq, Clone, Copy, Hash, Debug)]
3031
pub struct ThreadId(NonZero<u64>);

library/std/src/thread/join_handle.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ use crate::sys_common::{AsInner, IntoInner};
6565
/// thread::sleep(Duration::from_millis(1000));
6666
/// ```
6767
///
68-
/// [`thread::Builder::spawn`]: Builder::spawn
69-
/// [`thread::spawn`]: spawn
68+
/// [`thread::Builder::spawn`]: super::Builder::spawn
69+
/// [`thread::spawn`]: super::spawn
7070
#[stable(feature = "rust1", since = "1.0.0")]
7171
#[cfg_attr(target_os = "teeos", must_use)]
7272
pub struct JoinHandle<T>(pub(super) JoinInner<'static, T>);
@@ -143,7 +143,7 @@ impl<T> JoinHandle<T> {
143143
/// type.
144144
///
145145
/// [`catch_unwind`]: ../../std/panic/fn.catch_unwind.html
146-
/// [`thread::spawn`]: spawn
146+
/// [`thread::spawn`]: super::spawn
147147
#[stable(feature = "rust1", since = "1.0.0")]
148148
pub fn join(self) -> Result<T> {
149149
self.0.join()

library/std/src/thread/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@
137137
//! Note that the stack size of the main thread is *not* determined by Rust.
138138
//!
139139
//! [channels]: crate::sync::mpsc
140+
//! [`Arc`]: crate::sync::Arc
140141
//! [`join`]: JoinHandle::join
141142
//! [`Result`]: crate::result::Result
142143
//! [`Ok`]: crate::result::Result::Ok

library/std/src/thread/thread.rs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,8 @@ impl Inner {
6565
/// Threads are represented via the `Thread` type, which you can get in one of
6666
/// two ways:
6767
///
68-
/// * By spawning a new thread, e.g., using the [`thread::spawn`][`spawn`]
69-
/// function, and calling [`thread`][`JoinHandle::thread`] on the
70-
/// [`JoinHandle`].
68+
/// * By spawning a new thread, e.g., using the [`thread::spawn`]
69+
/// function, and calling [`thread`] on the [`JoinHandle`].
7170
/// * By requesting the current thread, using the [`thread::current`] function.
7271
///
7372
/// The [`thread::current`] function is available even for threads not spawned
@@ -77,7 +76,12 @@ impl Inner {
7776
/// should instead use a function like `spawn` to create new threads, see the
7877
/// docs of [`Builder`] and [`spawn`] for more details.
7978
///
80-
/// [`thread::current`]: current::current
79+
/// [`thread::spawn`]: super::spawn
80+
/// [`thread`]: super::JoinHandle::thread
81+
/// [`JoinHandle`]: super::JoinHandle
82+
/// [`thread::current`]: super::current::current
83+
/// [`Builder`]: super::Builder
84+
/// [`spawn`]: super::spawn
8185
pub struct Thread {
8286
// We use the System allocator such that creating or dropping this handle
8387
// does not interfere with a potential Global allocator using thread-local
@@ -111,6 +115,8 @@ impl Thread {
111115
///
112116
/// # Safety
113117
/// May only be called from the thread to which this handle belongs.
118+
///
119+
/// [`park`]: super::park
114120
pub(crate) unsafe fn park(&self) {
115121
unsafe { self.inner.as_ref().parker().park() }
116122
}
@@ -120,17 +126,19 @@ impl Thread {
120126
///
121127
/// # Safety
122128
/// May only be called from the thread to which this handle belongs.
129+
///
130+
/// [`park_timeout`]: super::park_timeout
123131
pub(crate) unsafe fn park_timeout(&self, dur: Duration) {
124132
unsafe { self.inner.as_ref().parker().park_timeout(dur) }
125133
}
126134

127135
/// Atomically makes the handle's token available if it is not already.
128136
///
129137
/// Every thread is equipped with some basic low-level blocking support, via
130-
/// the [`park`][park] function and the `unpark()` method. These can be
131-
/// used as a more CPU-efficient implementation of a spinlock.
138+
/// the [`park`] function and the `unpark()` method. These can be used as a
139+
/// more CPU-efficient implementation of a spinlock.
132140
///
133-
/// See the [park documentation][park] for more details.
141+
/// See the [park documentation] for more details.
134142
///
135143
/// # Examples
136144
///
@@ -167,6 +175,9 @@ impl Thread {
167175
///
168176
/// parked_thread.join().unwrap();
169177
/// ```
178+
///
179+
/// [`park`]: super::park
180+
/// [park documentation]: super::park
170181
#[stable(feature = "rust1", since = "1.0.0")]
171182
#[inline]
172183
pub fn unpark(&self) {

0 commit comments

Comments
 (0)