Skip to content

Commit 732bebd

Browse files
authored
Rollup merge of rust-lang#75629 - EllenNyan:ellen-intra-doc-links, r=jyn514
Use intra-doc links in `std::env`, `std::alloc` and `std::error` This is partial fixes for rust-lang#75080.
2 parents 791768e + e7a7279 commit 732bebd

File tree

3 files changed

+13
-65
lines changed

3 files changed

+13
-65
lines changed

library/std/src/alloc.rs

-9
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
//! like `cdylib`s and `staticlib`s are guaranteed to use the [`System`] by
88
//! default.
99
//!
10-
//! [`System`]: struct.System.html
11-
//!
1210
//! # The `#[global_allocator]` attribute
1311
//!
1412
//! This attribute allows configuring the choice of global allocator.
@@ -43,8 +41,6 @@
4341
//! The attribute is used on a `static` item whose type implements the
4442
//! [`GlobalAlloc`] trait. This type can be provided by an external library:
4543
//!
46-
//! [`GlobalAlloc`]: ../../core/alloc/trait.GlobalAlloc.html
47-
//!
4844
//! ```rust,ignore (demonstrates crates.io usage)
4945
//! extern crate jemallocator;
5046
//!
@@ -284,9 +280,6 @@ static HOOK: AtomicPtr<()> = AtomicPtr::new(ptr::null_mut());
284280
/// about the allocation that failed.
285281
///
286282
/// The allocation error hook is a global resource.
287-
///
288-
/// [`set_alloc_error_hook`]: fn.set_alloc_error_hook.html
289-
/// [`take_alloc_error_hook`]: fn.take_alloc_error_hook.html
290283
#[unstable(feature = "alloc_error_hook", issue = "51245")]
291284
pub fn set_alloc_error_hook(hook: fn(Layout)) {
292285
HOOK.store(hook as *mut (), Ordering::SeqCst);
@@ -297,8 +290,6 @@ pub fn set_alloc_error_hook(hook: fn(Layout)) {
297290
/// *See also the function [`set_alloc_error_hook`].*
298291
///
299292
/// If no custom hook is registered, the default hook will be returned.
300-
///
301-
/// [`set_alloc_error_hook`]: fn.set_alloc_error_hook.html
302293
#[unstable(feature = "alloc_error_hook", issue = "51245")]
303294
pub fn take_alloc_error_hook() -> fn(Layout) {
304295
let hook = HOOK.swap(ptr::null_mut(), Ordering::SeqCst);

library/std/src/env.rs

+10-31
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
//! There are several functions and structs in this module that have a
88
//! counterpart ending in `os`. Those ending in `os` will return an [`OsString`]
99
//! and those without will return a [`String`].
10-
//!
11-
//! [`OsString`]: ../../std/ffi/struct.OsString.html
12-
//! [`String`]: ../string/struct.String.html
1310
1411
#![stable(feature = "env", since = "1.0.0")]
1512

@@ -31,9 +28,6 @@ use crate::sys::os as os_imp;
3128
/// * Current directory does not exist.
3229
/// * There are insufficient permissions to access the current directory.
3330
///
34-
/// [`PathBuf`]: ../../std/path/struct.PathBuf.html
35-
/// [`Err`]: ../../std/result/enum.Result.html#method.err
36-
///
3731
/// # Examples
3832
///
3933
/// ```
@@ -54,8 +48,6 @@ pub fn current_dir() -> io::Result<PathBuf> {
5448
///
5549
/// Returns an [`Err`] if the operation fails.
5650
///
57-
/// [`Err`]: ../../std/result/enum.Result.html#method.err
58-
///
5951
/// # Examples
6052
///
6153
/// ```
@@ -76,7 +68,7 @@ pub fn set_current_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
7668
/// This structure is created by the [`std::env::vars`] function. See its
7769
/// documentation for more.
7870
///
79-
/// [`std::env::vars`]: fn.vars.html
71+
/// [`std::env::vars`]: vars
8072
#[stable(feature = "env", since = "1.0.0")]
8173
pub struct Vars {
8274
inner: VarsOs,
@@ -87,7 +79,7 @@ pub struct Vars {
8779
/// This structure is created by the [`std::env::vars_os`] function. See
8880
/// its documentation for more.
8981
///
90-
/// [`std::env::vars_os`]: fn.vars_os.html
82+
/// [`std::env::vars_os`]: vars_os
9183
#[stable(feature = "env", since = "1.0.0")]
9284
pub struct VarsOs {
9385
inner: os_imp::Env,
@@ -106,7 +98,7 @@ pub struct VarsOs {
10698
/// environment is not valid unicode. If this is not desired, consider using the
10799
/// [`env::vars_os`] function.
108100
///
109-
/// [`env::vars_os`]: fn.vars_os.html
101+
/// [`env::vars_os`]: vars_os
110102
///
111103
/// # Examples
112104
///
@@ -222,8 +214,6 @@ fn _var(key: &OsStr) -> Result<String, VarError> {
222214
/// Fetches the environment variable `key` from the current process, returning
223215
/// [`None`] if the variable isn't set.
224216
///
225-
/// [`None`]: ../option/enum.Option.html#variant.None
226-
///
227217
/// # Panics
228218
///
229219
/// This function may panic if `key` is empty, contains an ASCII equals sign
@@ -254,7 +244,7 @@ fn _var_os(key: &OsStr) -> Option<OsString> {
254244
/// The error type for operations interacting with environment variables.
255245
/// Possibly returned from the [`env::var`] function.
256246
///
257-
/// [`env::var`]: fn.var.html
247+
/// [`env::var`]: var
258248
#[derive(Debug, PartialEq, Eq, Clone)]
259249
#[stable(feature = "env", since = "1.0.0")]
260250
pub enum VarError {
@@ -382,8 +372,7 @@ fn _remove_var(k: &OsStr) {
382372
/// This structure is created by the [`std::env::split_paths`] function. See its
383373
/// documentation for more.
384374
///
385-
/// [`PathBuf`]: ../../std/path/struct.PathBuf.html
386-
/// [`std::env::split_paths`]: fn.split_paths.html
375+
/// [`std::env::split_paths`]: split_paths
387376
#[stable(feature = "env", since = "1.0.0")]
388377
pub struct SplitPaths<'a> {
389378
inner: os_imp::SplitPaths<'a>,
@@ -410,8 +399,6 @@ pub struct SplitPaths<'a> {
410399
/// None => println!("{} is not defined in the environment.", key)
411400
/// }
412401
/// ```
413-
///
414-
/// [`PathBuf`]: ../../std/path/struct.PathBuf.html
415402
#[stable(feature = "env", since = "1.0.0")]
416403
pub fn split_paths<T: AsRef<OsStr> + ?Sized>(unparsed: &T) -> SplitPaths<'_> {
417404
SplitPaths { inner: os_imp::split_paths(unparsed.as_ref()) }
@@ -438,7 +425,7 @@ impl fmt::Debug for SplitPaths<'_> {
438425
/// The error type for operations on the `PATH` variable. Possibly returned from
439426
/// the [`env::join_paths`] function.
440427
///
441-
/// [`env::join_paths`]: fn.join_paths.html
428+
/// [`env::join_paths`]: join_paths
442429
#[derive(Debug)]
443430
#[stable(feature = "env", since = "1.0.0")]
444431
pub struct JoinPathsError {
@@ -450,14 +437,10 @@ pub struct JoinPathsError {
450437
///
451438
/// # Errors
452439
///
453-
/// Returns an [`Err`][err] (containing an error message) if one of the input
440+
/// Returns an [`Err`] (containing an error message) if one of the input
454441
/// [`Path`]s contains an invalid character for constructing the `PATH`
455442
/// variable (a double quote on Windows or a colon on Unix).
456443
///
457-
/// [`Path`]: ../../std/path/struct.Path.html
458-
/// [`OsString`]: ../../std/ffi/struct.OsString.html
459-
/// [err]: ../../std/result/enum.Result.html#variant.Err
460-
///
461444
/// # Examples
462445
///
463446
/// Joining paths on a Unix-like platform:
@@ -508,7 +491,7 @@ pub struct JoinPathsError {
508491
/// }
509492
/// ```
510493
///
511-
/// [`env::split_paths`]: fn.split_paths.html
494+
/// [`env::split_paths`]: split_paths
512495
#[stable(feature = "env", since = "1.0.0")]
513496
pub fn join_paths<I, T>(paths: I) -> Result<OsString, JoinPathsError>
514497
where
@@ -688,8 +671,7 @@ pub fn current_exe() -> io::Result<PathBuf> {
688671
/// set to arbitrary text, and may not even exist. This means this property
689672
/// should not be relied upon for security purposes.
690673
///
691-
/// [`String`]: ../string/struct.String.html
692-
/// [`std::env::args`]: ./fn.args.html
674+
/// [`std::env::args`]: args
693675
#[stable(feature = "env", since = "1.0.0")]
694676
pub struct Args {
695677
inner: ArgsOs,
@@ -705,8 +687,7 @@ pub struct Args {
705687
/// set to arbitrary text, and may not even exist. This means this property
706688
/// should not be relied upon for security purposes.
707689
///
708-
/// [`OsString`]: ../ffi/struct.OsString.html
709-
/// [`std::env::args_os`]: ./fn.args_os.html
690+
/// [`std::env::args_os`]: args_os
710691
#[stable(feature = "env", since = "1.0.0")]
711692
pub struct ArgsOs {
712693
inner: sys::args::Args,
@@ -744,8 +725,6 @@ pub struct ArgsOs {
744725
/// println!("{}", argument);
745726
/// }
746727
/// ```
747-
///
748-
/// [`args_os`]: ./fn.args_os.html
749728
#[stable(feature = "env", since = "1.0.0")]
750729
pub fn args() -> Args {
751730
Args { inner: args_os() }

library/std/src/error.rs

+3-25
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,8 @@ use crate::string;
4040
/// provide its own errors while also revealing some of the implementation for
4141
/// debugging via [`source`] chains.
4242
///
43-
/// [`Result<T, E>`]: ../result/enum.Result.html
44-
/// [`Display`]: ../fmt/trait.Display.html
45-
/// [`Debug`]: ../fmt/trait.Debug.html
46-
/// [`source`]: trait.Error.html#method.source
43+
/// [`Result<T, E>`]: Result
44+
/// [`source`]: Error::source
4745
#[stable(feature = "rust1", since = "1.0.0")]
4846
pub trait Error: Debug + Display {
4947
/// The lower-level source of this error, if any.
@@ -164,8 +162,6 @@ mod private {
164162
impl<'a, E: Error + 'a> From<E> for Box<dyn Error + 'a> {
165163
/// Converts a type of [`Error`] into a box of dyn [`Error`].
166164
///
167-
/// [`Error`]: ../error/trait.Error.html
168-
///
169165
/// # Examples
170166
///
171167
/// ```
@@ -199,8 +195,6 @@ impl<'a, E: Error + Send + Sync + 'a> From<E> for Box<dyn Error + Send + Sync +
199195
/// Converts a type of [`Error`] + [`Send`] + [`Sync`] into a box of
200196
/// dyn [`Error`] + [`Send`] + [`Sync`].
201197
///
202-
/// [`Error`]: ../error/trait.Error.html
203-
///
204198
/// # Examples
205199
///
206200
/// ```
@@ -238,8 +232,6 @@ impl<'a, E: Error + Send + Sync + 'a> From<E> for Box<dyn Error + Send + Sync +
238232
impl From<String> for Box<dyn Error + Send + Sync> {
239233
/// Converts a [`String`] into a box of dyn [`Error`] + [`Send`] + [`Sync`].
240234
///
241-
/// [`Error`]: ../error/trait.Error.html
242-
///
243235
/// # Examples
244236
///
245237
/// ```
@@ -283,8 +275,6 @@ impl From<String> for Box<dyn Error + Send + Sync> {
283275
impl From<String> for Box<dyn Error> {
284276
/// Converts a [`String`] into a box of dyn [`Error`].
285277
///
286-
/// [`Error`]: ../error/trait.Error.html
287-
///
288278
/// # Examples
289279
///
290280
/// ```
@@ -306,8 +296,6 @@ impl From<String> for Box<dyn Error> {
306296
impl<'a> From<&str> for Box<dyn Error + Send + Sync + 'a> {
307297
/// Converts a [`str`] into a box of dyn [`Error`] + [`Send`] + [`Sync`].
308298
///
309-
/// [`Error`]: ../error/trait.Error.html
310-
///
311299
/// # Examples
312300
///
313301
/// ```
@@ -329,8 +317,6 @@ impl<'a> From<&str> for Box<dyn Error + Send + Sync + 'a> {
329317
impl From<&str> for Box<dyn Error> {
330318
/// Converts a [`str`] into a box of dyn [`Error`].
331319
///
332-
/// [`Error`]: ../error/trait.Error.html
333-
///
334320
/// # Examples
335321
///
336322
/// ```
@@ -350,9 +336,6 @@ impl From<&str> for Box<dyn Error> {
350336
impl<'a, 'b> From<Cow<'b, str>> for Box<dyn Error + Send + Sync + 'a> {
351337
/// Converts a [`Cow`] into a box of dyn [`Error`] + [`Send`] + [`Sync`].
352338
///
353-
/// [`Cow`]: ../borrow/enum.Cow.html
354-
/// [`Error`]: ../error/trait.Error.html
355-
///
356339
/// # Examples
357340
///
358341
/// ```
@@ -374,9 +357,6 @@ impl<'a, 'b> From<Cow<'b, str>> for Box<dyn Error + Send + Sync + 'a> {
374357
impl<'a> From<Cow<'a, str>> for Box<dyn Error> {
375358
/// Converts a [`Cow`] into a box of dyn [`Error`].
376359
///
377-
/// [`Cow`]: ../borrow/enum.Cow.html
378-
/// [`Error`]: ../error/trait.Error.html
379-
///
380360
/// # Examples
381361
///
382362
/// ```
@@ -703,7 +683,7 @@ impl dyn Error {
703683
/// assert!(iter.next().is_none());
704684
/// ```
705685
///
706-
/// [`source`]: trait.Error.html#method.source
686+
/// [`source`]: Error::source
707687
#[unstable(feature = "error_iter", issue = "58520")]
708688
#[inline]
709689
pub fn chain(&self) -> Chain<'_> {
@@ -715,8 +695,6 @@ impl dyn Error {
715695
///
716696
/// If you want to omit the initial error and only process
717697
/// its sources, use `skip(1)`.
718-
///
719-
/// [`Error`]: trait.Error.html
720698
#[unstable(feature = "error_iter", issue = "58520")]
721699
#[derive(Clone, Debug)]
722700
pub struct Chain<'a> {

0 commit comments

Comments
 (0)