Skip to content

Commit 2a7f868

Browse files
authored
Rollup merge of #75750 - poliorcetics:intra-links-std-thread, r=jyn514
Move to intra doc links for std::thread documentation Helps with #75080. @rustbot modify labels: T-doc, A-intra-doc-links, T-rustdoc r? @jyn514
2 parents cccb889 + fb3f927 commit 2a7f868

File tree

2 files changed

+40
-87
lines changed

2 files changed

+40
-87
lines changed

library/std/src/thread/local.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,7 @@ use crate::fmt;
7171
/// not guard typically have a synthetic limit after which point no more
7272
/// destructors are run.
7373
///
74-
/// [`with`]: ../../std/thread/struct.LocalKey.html#method.with
75-
/// [`thread_local!`]: ../../std/macro.thread_local.html
76-
/// [`Drop`]: ../../std/ops/trait.Drop.html
74+
/// [`with`]: LocalKey::with
7775
#[stable(feature = "rust1", since = "1.0.0")]
7876
pub struct LocalKey<T: 'static> {
7977
// This outer `LocalKey<T>` type is what's going to be stored in statics,
@@ -118,10 +116,10 @@ impl<T: 'static> fmt::Debug for LocalKey<T> {
118116
/// # fn main() {}
119117
/// ```
120118
///
121-
/// See [LocalKey documentation][`std::thread::LocalKey`] for more
119+
/// See [`LocalKey` documentation][`std::thread::LocalKey`] for more
122120
/// information.
123121
///
124-
/// [`std::thread::LocalKey`]: ../std/thread/struct.LocalKey.html
122+
/// [`std::thread::LocalKey`]: crate::thread::LocalKey
125123
#[macro_export]
126124
#[stable(feature = "rust1", since = "1.0.0")]
127125
#[allow_internal_unstable(thread_local_internals)]

library/std/src/thread/mod.rs

+37-82
Original file line numberDiff line numberDiff line change
@@ -129,30 +129,19 @@
129129
//!
130130
//! Note that the stack size of the main thread is *not* determined by Rust.
131131
//!
132-
//! [channels]: ../../std/sync/mpsc/index.html
133-
//! [`Arc`]: ../../std/sync/struct.Arc.html
134-
//! [`spawn`]: ../../std/thread/fn.spawn.html
135-
//! [`JoinHandle`]: ../../std/thread/struct.JoinHandle.html
136-
//! [`JoinHandle::thread`]: ../../std/thread/struct.JoinHandle.html#method.thread
137-
//! [`join`]: ../../std/thread/struct.JoinHandle.html#method.join
138-
//! [`Result`]: ../../std/result/enum.Result.html
139-
//! [`Ok`]: ../../std/result/enum.Result.html#variant.Ok
140-
//! [`Err`]: ../../std/result/enum.Result.html#variant.Err
141-
//! [`panic!`]: ../../std/macro.panic.html
142-
//! [`Builder`]: ../../std/thread/struct.Builder.html
143-
//! [`Builder::stack_size`]: ../../std/thread/struct.Builder.html#method.stack_size
144-
//! [`Builder::name`]: ../../std/thread/struct.Builder.html#method.name
145-
//! [`thread::current`]: ../../std/thread/fn.current.html
146-
//! [`thread::Result`]: ../../std/thread/type.Result.html
147-
//! [`Thread`]: ../../std/thread/struct.Thread.html
148-
//! [`park`]: ../../std/thread/fn.park.html
149-
//! [`unpark`]: ../../std/thread/struct.Thread.html#method.unpark
150-
//! [`Thread::name`]: ../../std/thread/struct.Thread.html#method.name
151-
//! [`thread::park_timeout`]: ../../std/thread/fn.park_timeout.html
152-
//! [`Cell`]: ../cell/struct.Cell.html
153-
//! [`RefCell`]: ../cell/struct.RefCell.html
154-
//! [`thread_local!`]: ../macro.thread_local.html
155-
//! [`with`]: struct.LocalKey.html#method.with
132+
//! [channels]: crate::sync::mpsc
133+
//! [`join`]: JoinHandle::join
134+
//! [`Result`]: crate::result::Result
135+
//! [`Ok`]: crate::result::Result::Ok
136+
//! [`Err`]: crate::result::Result::Err
137+
//! [`thread::current`]: current
138+
//! [`thread::Result`]: Result
139+
//! [`unpark`]: Thread::unpark
140+
//! [`Thread::name`]: Thread::name
141+
//! [`thread::park_timeout`]: park_timeout
142+
//! [`Cell`]: crate::cell::Cell
143+
//! [`RefCell`]: crate::cell::RefCell
144+
//! [`with`]: LocalKey::with
156145
157146
#![stable(feature = "rust1", since = "1.0.0")]
158147

@@ -245,12 +234,12 @@ pub use self::local::statik::Key as __StaticLocalKeyInner;
245234
/// handler.join().unwrap();
246235
/// ```
247236
///
248-
/// [`thread::spawn`]: ../../std/thread/fn.spawn.html
249-
/// [`stack_size`]: ../../std/thread/struct.Builder.html#method.stack_size
250-
/// [`name`]: ../../std/thread/struct.Builder.html#method.name
251-
/// [`spawn`]: ../../std/thread/struct.Builder.html#method.spawn
252-
/// [`io::Result`]: ../../std/io/type.Result.html
253-
/// [`unwrap`]: ../../std/result/enum.Result.html#method.unwrap
237+
/// [`stack_size`]: Builder::stack_size
238+
/// [`name`]: Builder::name
239+
/// [`spawn`]: Builder::spawn
240+
/// [`thread::spawn`]: spawn
241+
/// [`io::Result`]: crate::io::Result
242+
/// [`unwrap`]: crate::result::Result::unwrap
254243
/// [naming-threads]: ./index.html#naming-threads
255244
/// [stack-size]: ./index.html#stack-size
256245
#[stable(feature = "rust1", since = "1.0.0")]
@@ -355,9 +344,7 @@ impl Builder {
355344
/// [`io::Result`] to capture any failure to create the thread at
356345
/// the OS level.
357346
///
358-
/// [`spawn`]: ../../std/thread/fn.spawn.html
359-
/// [`io::Result`]: ../../std/io/type.Result.html
360-
/// [`JoinHandle`]: ../../std/thread/struct.JoinHandle.html
347+
/// [`io::Result`]: crate::io::Result
361348
///
362349
/// # Panics
363350
///
@@ -443,11 +430,7 @@ impl Builder {
443430
/// handler.join().unwrap();
444431
/// ```
445432
///
446-
/// [`spawn`]: ../../std/thread/fn.spawn.html
447-
/// [`Builder::spawn`]: ../../std/thread/struct.Builder.html#method.spawn
448-
/// [`io::Result`]: ../../std/io/type.Result.html
449-
/// [`JoinHandle`]: ../../std/thread/struct.JoinHandle.html
450-
/// [`JoinHandle::join`]: ../../std/thread/struct.JoinHandle.html#method.join
433+
/// [`io::Result`]: crate::io::Result
451434
#[unstable(feature = "thread_spawn_unchecked", issue = "55132")]
452435
pub unsafe fn spawn_unchecked<'a, F, T>(self, f: F) -> io::Result<JoinHandle<T>>
453436
where
@@ -513,7 +496,7 @@ impl Builder {
513496
/// the main thread finishes). Additionally, the join handle provides a [`join`]
514497
/// method that can be used to join the child thread. If the child thread
515498
/// panics, [`join`] will return an [`Err`] containing the argument given to
516-
/// [`panic`].
499+
/// [`panic!`].
517500
///
518501
/// This will create a thread using default parameters of [`Builder`], if you
519502
/// want to specify the stack size or the name of the thread, use this API
@@ -600,15 +583,9 @@ impl Builder {
600583
/// println!("{}", result);
601584
/// ```
602585
///
603-
/// [`channels`]: ../../std/sync/mpsc/index.html
604-
/// [`JoinHandle`]: ../../std/thread/struct.JoinHandle.html
605-
/// [`join`]: ../../std/thread/struct.JoinHandle.html#method.join
606-
/// [`Err`]: ../../std/result/enum.Result.html#variant.Err
607-
/// [`panic`]: ../../std/macro.panic.html
608-
/// [`Builder::spawn`]: ../../std/thread/struct.Builder.html#method.spawn
609-
/// [`Builder`]: ../../std/thread/struct.Builder.html
610-
/// [`Send`]: ../../std/marker/trait.Send.html
611-
/// [`Sync`]: ../../std/marker/trait.Sync.html
586+
/// [`channels`]: crate::sync::mpsc
587+
/// [`join`]: JoinHandle::join
588+
/// [`Err`]: crate::result::Result::Err
612589
#[stable(feature = "rust1", since = "1.0.0")]
613590
pub fn spawn<F, T>(f: F) -> JoinHandle<T>
614591
where
@@ -673,11 +650,8 @@ pub fn current() -> Thread {
673650
/// thread::yield_now();
674651
/// ```
675652
///
676-
/// [`channel`]: ../../std/sync/mpsc/index.html
677-
/// [`spawn`]: ../../std/thread/fn.spawn.html
678-
/// [`join`]: ../../std/thread/struct.JoinHandle.html#method.join
679-
/// [`Mutex`]: ../../std/sync/struct.Mutex.html
680-
/// [`Condvar`]: ../../std/sync/struct.Condvar.html
653+
/// [`channel`]: crate::sync::mpsc
654+
/// [`join`]: JoinHandle::join
681655
#[stable(feature = "rust1", since = "1.0.0")]
682656
pub fn yield_now() {
683657
imp::Thread::yield_now()
@@ -723,8 +697,6 @@ pub fn yield_now() {
723697
/// panic!()
724698
/// }
725699
/// ```
726-
///
727-
/// [Mutex]: ../../std/sync/struct.Mutex.html
728700
#[inline]
729701
#[stable(feature = "rust1", since = "1.0.0")]
730702
pub fn panicking() -> bool {
@@ -881,10 +853,8 @@ const NOTIFIED: usize = 2;
881853
/// parked_thread.join().unwrap();
882854
/// ```
883855
///
884-
/// [`Thread`]: ../../std/thread/struct.Thread.html
885-
/// [`park`]: ../../std/thread/fn.park.html
886-
/// [`unpark`]: ../../std/thread/struct.Thread.html#method.unpark
887-
/// [`thread::park_timeout`]: ../../std/thread/fn.park_timeout.html
856+
/// [`unpark`]: Thread::unpark
857+
/// [`thread::park_timeout`]: park_timeout
888858
//
889859
// The implementation currently uses the trivial strategy of a Mutex+Condvar
890860
// with wakeup flag, which does not actually allow spurious wakeups. In the
@@ -939,9 +909,6 @@ pub fn park() {
939909
/// amount of time waited to be precisely `ms` long.
940910
///
941911
/// See the [park documentation][`park`] for more detail.
942-
///
943-
/// [`park_timeout`]: fn.park_timeout.html
944-
/// [`park`]: ../../std/thread/fn.park.html
945912
#[stable(feature = "rust1", since = "1.0.0")]
946913
#[rustc_deprecated(since = "1.6.0", reason = "replaced by `std::thread::park_timeout`")]
947914
pub fn park_timeout_ms(ms: u32) {
@@ -986,8 +953,6 @@ pub fn park_timeout_ms(ms: u32) {
986953
/// timeout_remaining = timeout - elapsed;
987954
/// }
988955
/// ```
989-
///
990-
/// [park]: fn.park.html
991956
#[stable(feature = "park_timeout", since = "1.4.0")]
992957
pub fn park_timeout(dur: Duration) {
993958
let thread = current();
@@ -1046,8 +1011,7 @@ pub fn park_timeout(dur: Duration) {
10461011
/// assert!(thread::current().id() != other_thread_id);
10471012
/// ```
10481013
///
1049-
/// [`id`]: ../../std/thread/struct.Thread.html#method.id
1050-
/// [`Thread`]: ../../std/thread/struct.Thread.html
1014+
/// [`id`]: Thread::id
10511015
#[stable(feature = "thread_id", since = "1.19.0")]
10521016
#[derive(Eq, PartialEq, Clone, Copy, Hash, Debug)]
10531017
pub struct ThreadId(NonZeroU64);
@@ -1124,12 +1088,7 @@ struct Inner {
11241088
/// should instead use a function like `spawn` to create new threads, see the
11251089
/// docs of [`Builder`] and [`spawn`] for more details.
11261090
///
1127-
/// [`Builder`]: ../../std/thread/struct.Builder.html
1128-
/// [`JoinHandle::thread`]: ../../std/thread/struct.JoinHandle.html#method.thread
1129-
/// [`JoinHandle`]: ../../std/thread/struct.JoinHandle.html
1130-
/// [`thread::current`]: ../../std/thread/fn.current.html
1131-
/// [`spawn`]: ../../std/thread/fn.spawn.html
1132-
1091+
/// [`thread::current`]: current
11331092
pub struct Thread {
11341093
inner: Arc<Inner>,
11351094
}
@@ -1181,8 +1140,6 @@ impl Thread {
11811140
///
11821141
/// parked_thread.join().unwrap();
11831142
/// ```
1184-
///
1185-
/// [park]: fn.park.html
11861143
#[stable(feature = "rust1", since = "1.0.0")]
11871144
pub fn unpark(&self) {
11881145
// To ensure the unparked thread will observe any writes we made
@@ -1326,7 +1283,7 @@ impl fmt::Debug for Thread {
13261283
/// }
13271284
/// ```
13281285
///
1329-
/// [`Result`]: ../../std/result/enum.Result.html
1286+
/// [`Result`]: crate::result::Result
13301287
#[stable(feature = "rust1", since = "1.0.0")]
13311288
pub type Result<T> = crate::result::Result<T, Box<dyn Any + Send + 'static>>;
13321289

@@ -1421,9 +1378,8 @@ impl<T> JoinInner<T> {
14211378
/// thread::sleep(Duration::from_millis(1000));
14221379
/// ```
14231380
///
1424-
/// [`Clone`]: ../../std/clone/trait.Clone.html
1425-
/// [`thread::spawn`]: fn.spawn.html
1426-
/// [`thread::Builder::spawn`]: struct.Builder.html#method.spawn
1381+
/// [`thread::Builder::spawn`]: Builder::spawn
1382+
/// [`thread::spawn`]: spawn
14271383
#[stable(feature = "rust1", since = "1.0.0")]
14281384
pub struct JoinHandle<T>(JoinInner<T>);
14291385

@@ -1462,11 +1418,10 @@ impl<T> JoinHandle<T> {
14621418
/// operations that happen after `join` returns.
14631419
///
14641420
/// If the child thread panics, [`Err`] is returned with the parameter given
1465-
/// to [`panic`].
1421+
/// to [`panic!`].
14661422
///
1467-
/// [`Err`]: ../../std/result/enum.Result.html#variant.Err
1468-
/// [`panic`]: ../../std/macro.panic.html
1469-
/// [atomic memory orderings]: ../../std/sync/atomic/index.html
1423+
/// [`Err`]: crate::result::Result::Err
1424+
/// [atomic memory orderings]: crate::sync::atomic
14701425
///
14711426
/// # Panics
14721427
///

0 commit comments

Comments
 (0)