From 901c9440a225864ae1f65f6554b1fec7096dca7e Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Thu, 24 Sep 2020 17:34:03 +0530 Subject: [PATCH 1/2] Remove `prim@` rustdoc intra-doc link prefix alias MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit “Prim” is rustc jargon; everywhere else uses the normal English word “primitive”, including the file names like primitive.u8.html, which it’s nice to match. This only touches the `prim@` disambiguation prefix. rustc still refers to “prim” internally in some places, but being an outsider to rustc I’m unqualified to judge whether any change is called for there. (The uses are: PrimIntCast/prim-int-cast; PrimTy, short for PrimitiveType; and an identifier prim, most commonly of type PrimitiveType.) --- library/alloc/src/string.rs | 12 ++-- library/core/src/str/mod.rs | 56 +++++++++---------- library/std/src/error.rs | 4 +- library/std/src/ffi/c_str.rs | 8 +-- library/std/src/io/mod.rs | 2 +- library/std/src/lib.rs | 2 +- library/std/src/primitive_docs.rs | 4 +- .../rustdoc/src/linking-to-items-by-name.md | 2 +- .../passes/collect_intra_doc_links.rs | 6 +- .../rustdoc-ui/intra-link-prim-conflict.rs | 4 +- .../intra-link-prim-conflict.stderr | 14 ++--- .../rustdoc/intra-link-prim-precedence.rs | 2 +- 12 files changed, 58 insertions(+), 58 deletions(-) diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs index d3598ccfce81f..ba3941ac54511 100644 --- a/library/alloc/src/string.rs +++ b/library/alloc/src/string.rs @@ -269,8 +269,8 @@ use crate::vec::Vec; /// /// Here, there's no need to allocate more memory inside the loop. /// -/// [`str`]: prim@str -/// [`&str`]: prim@str +/// [`str`]: primitive@str +/// [`&str`]: primitive@str /// [`Deref`]: core::ops::Deref /// [`as_str()`]: String::as_str #[derive(PartialOrd, Eq, Ord)] @@ -297,7 +297,7 @@ pub struct String { /// /// [`Utf8Error`]: core::str::Utf8Error /// [`std::str`]: core::str -/// [`&str`]: prim@str +/// [`&str`]: primitive@str /// [`utf8_error`]: Self::utf8_error /// /// # Examples @@ -473,7 +473,7 @@ impl String { /// /// [`from_utf8_unchecked`]: String::from_utf8_unchecked /// [`Vec`]: crate::vec::Vec - /// [`&str`]: prim@str + /// [`&str`]: primitive@str /// [`into_bytes`]: String::into_bytes #[inline] #[stable(feature = "rust1", since = "1.0.0")] @@ -1569,7 +1569,7 @@ impl String { /// /// This will drop any excess capacity. /// - /// [`str`]: prim@str + /// [`str`]: primitive@str /// /// # Examples /// @@ -1639,7 +1639,7 @@ impl FromUtf8Error { /// on using it. /// /// [`std::str`]: core::str - /// [`&str`]: prim@str + /// [`&str`]: primitive@str /// /// # Examples /// diff --git a/library/core/src/str/mod.rs b/library/core/src/str/mod.rs index e4a6b7e142a51..ab3b993068e94 100644 --- a/library/core/src/str/mod.rs +++ b/library/core/src/str/mod.rs @@ -465,7 +465,7 @@ Section: Iterators /// This struct is created by the [`chars`] method on [`str`]. /// See its documentation for more. /// -/// [`char`]: prim@char +/// [`char`]: primitive@char /// [`chars`]: str::chars #[derive(Clone)] #[stable(feature = "rust1", since = "1.0.0")] @@ -663,7 +663,7 @@ impl<'a> Chars<'a> { /// This struct is created by the [`char_indices`] method on [`str`]. /// See its documentation for more. /// -/// [`char`]: prim@char +/// [`char`]: primitive@char /// [`char_indices`]: str::char_indices #[derive(Clone, Debug)] #[stable(feature = "rust1", since = "1.0.0")] @@ -2261,7 +2261,7 @@ impl str { /// This length is in bytes, not [`char`]s or graphemes. In other words, /// it may not be what a human considers the length of the string. /// - /// [`char`]: prim@char + /// [`char`]: primitive@char /// /// # Examples /// @@ -2786,7 +2786,7 @@ impl str { /// /// Remember, [`char`]s may not match your intuition about characters: /// - /// [`char`]: prim@char + /// [`char`]: primitive@char /// /// ``` /// let y = "y̆"; @@ -2839,7 +2839,7 @@ impl str { /// /// Remember, [`char`]s may not match your intuition about characters: /// - /// [`char`]: prim@char + /// [`char`]: primitive@char /// /// ``` /// let yes = "y̆es"; @@ -3050,7 +3050,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: prim@char + /// [`char`]: primitive@char /// [pattern]: self::pattern /// /// # Examples @@ -3077,7 +3077,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: prim@char + /// [`char`]: primitive@char /// [pattern]: self::pattern /// /// # Examples @@ -3103,7 +3103,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: prim@char + /// [`char`]: primitive@char /// [pattern]: self::pattern /// /// # Examples @@ -3132,7 +3132,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: prim@char + /// [`char`]: primitive@char /// [pattern]: self::pattern /// /// # Examples @@ -3180,7 +3180,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: prim@char + /// [`char`]: primitive@char /// [pattern]: self::pattern /// /// # Examples @@ -3227,7 +3227,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: prim@char + /// [`char`]: primitive@char /// [pattern]: self::pattern /// /// # Iterator behavior @@ -3347,7 +3347,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: prim@char + /// [`char`]: primitive@char /// [pattern]: self::pattern /// /// # Examples @@ -3387,7 +3387,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: prim@char + /// [`char`]: primitive@char /// [pattern]: self::pattern /// /// # Iterator behavior @@ -3439,7 +3439,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: prim@char + /// [`char`]: primitive@char /// [pattern]: self::pattern /// /// Equivalent to [`split`], except that the trailing substring @@ -3484,7 +3484,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: prim@char + /// [`char`]: primitive@char /// [pattern]: self::pattern /// /// Equivalent to [`split`], except that the trailing substring is @@ -3533,7 +3533,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: prim@char + /// [`char`]: primitive@char /// [pattern]: self::pattern /// /// # Iterator behavior @@ -3586,7 +3586,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: prim@char + /// [`char`]: primitive@char /// [pattern]: self::pattern /// /// # Iterator behavior @@ -3675,7 +3675,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: prim@char + /// [`char`]: primitive@char /// [pattern]: self::pattern /// /// # Iterator behavior @@ -3712,7 +3712,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: prim@char + /// [`char`]: primitive@char /// [pattern]: self::pattern /// /// # Iterator behavior @@ -3754,7 +3754,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: prim@char + /// [`char`]: primitive@char /// [pattern]: self::pattern /// /// # Iterator behavior @@ -3797,7 +3797,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: prim@char + /// [`char`]: primitive@char /// [pattern]: self::pattern /// /// # Iterator behavior @@ -4016,7 +4016,7 @@ impl str { /// The [pattern] can be a [`char`], a slice of [`char`]s, or a function /// or closure that determines if a character matches. /// - /// [`char`]: prim@char + /// [`char`]: primitive@char /// [pattern]: self::pattern /// /// # Examples @@ -4064,7 +4064,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: prim@char + /// [`char`]: primitive@char /// [pattern]: self::pattern /// /// # Text directionality @@ -4109,7 +4109,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: prim@char + /// [`char`]: primitive@char /// [pattern]: self::pattern /// /// # Examples @@ -4137,7 +4137,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: prim@char + /// [`char`]: primitive@char /// [pattern]: self::pattern /// /// # Examples @@ -4164,7 +4164,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: prim@char + /// [`char`]: primitive@char /// [pattern]: self::pattern /// /// # Text directionality @@ -4213,7 +4213,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: prim@char + /// [`char`]: primitive@char /// [pattern]: self::pattern /// /// # Text directionality @@ -4250,7 +4250,7 @@ impl str { /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. /// - /// [`char`]: prim@char + /// [`char`]: primitive@char /// [pattern]: self::pattern /// /// # Text directionality diff --git a/library/std/src/error.rs b/library/std/src/error.rs index ee25311d3b7ee..3d5544bf64ea7 100644 --- a/library/std/src/error.rs +++ b/library/std/src/error.rs @@ -298,7 +298,7 @@ impl From for Box { impl<'a> From<&str> for Box { /// Converts a [`str`] into a box of dyn [`Error`] + [`Send`] + [`Sync`]. /// - /// [`str`]: prim@str + /// [`str`]: primitive@str /// /// # Examples /// @@ -321,7 +321,7 @@ impl<'a> From<&str> for Box { impl From<&str> for Box { /// Converts a [`str`] into a box of dyn [`Error`]. /// - /// [`str`]: prim@str + /// [`str`]: primitive@str /// /// # Examples /// diff --git a/library/std/src/ffi/c_str.rs b/library/std/src/ffi/c_str.rs index 13021738af139..d5f32be111c7a 100644 --- a/library/std/src/ffi/c_str.rs +++ b/library/std/src/ffi/c_str.rs @@ -73,7 +73,7 @@ use crate::sys; /// extern functions. See the documentation for that function for a /// discussion on ensuring the lifetime of the raw pointer. /// -/// [`&str`]: prim@str +/// [`&str`]: primitive@str /// [slice.as_ptr]: ../primitive.slice.html#method.as_ptr /// [slice.len]: ../primitive.slice.html#method.len /// [`Deref`]: ops::Deref @@ -184,7 +184,7 @@ pub struct CString { /// println!("string: {}", my_string_safe()); /// ``` /// -/// [`&str`]: prim@str +/// [`&str`]: primitive@str #[derive(Hash)] #[stable(feature = "rust1", since = "1.0.0")] // FIXME: @@ -1355,7 +1355,7 @@ impl CStr { /// function will return the corresponding [`&str`] slice. Otherwise, /// it will return an error with details of where UTF-8 validation failed. /// - /// [`&str`]: prim@str + /// [`&str`]: primitive@str /// /// # Examples /// @@ -1383,7 +1383,7 @@ impl CStr { /// [`U+FFFD REPLACEMENT CHARACTER`][U+FFFD] and return a /// [`Cow`]`::`[`Owned`]`(`[`String`]`)` with the result. /// - /// [`str`]: prim@str + /// [`str`]: primitive@str /// [`Borrowed`]: Cow::Borrowed /// [`Owned`]: Cow::Owned /// [U+FFFD]: crate::char::REPLACEMENT_CHARACTER diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index d9d0380781925..eeda530a661b7 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -482,7 +482,7 @@ where /// ``` /// /// [`read()`]: Read::read -/// [`&str`]: prim@str +/// [`&str`]: primitive@str /// [`std::io`]: self /// [`File`]: crate::fs::File /// [slice]: ../../std/primitive.slice.html diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index d03428dd08282..5da0004fb2c37 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -172,7 +172,7 @@ //! [`Vec`]: vec::Vec //! [`atomic`]: sync::atomic //! [`for`]: ../book/ch03-05-control-flow.html#looping-through-a-collection-with-for -//! [`str`]: prim@str +//! [`str`]: primitive@str //! [`mpsc`]: sync::mpsc //! [`std::cmp`]: cmp //! [`std::slice`]: slice diff --git a/library/std/src/primitive_docs.rs b/library/std/src/primitive_docs.rs index 81bbf37637875..251be12364986 100644 --- a/library/std/src/primitive_docs.rs +++ b/library/std/src/primitive_docs.rs @@ -98,7 +98,7 @@ mod prim_bool {} /// at all we know it can never produce a value which isn't a [`u32`]. This illustrates another /// behaviour of the `!` type - expressions with type `!` will coerce into any other type. /// -/// [`u32`]: prim@u32 +/// [`u32`]: primitive@u32 /// [`exit`]: process::exit /// /// # `!` and generics @@ -836,7 +836,7 @@ mod prim_f32 {} /// /// *[See also the `std::f64::consts` module][`crate::f64::consts`].* /// -/// [`f32`]: prim@f32 +/// [`f32`]: primitive@f32 /// [wikipedia]: https://en.wikipedia.org/wiki/Double-precision_floating-point_format #[stable(feature = "rust1", since = "1.0.0")] mod prim_f64 {} diff --git a/src/doc/rustdoc/src/linking-to-items-by-name.md b/src/doc/rustdoc/src/linking-to-items-by-name.md index 5e46ef583f60c..0dd6d8081686d 100644 --- a/src/doc/rustdoc/src/linking-to-items-by-name.md +++ b/src/doc/rustdoc/src/linking-to-items-by-name.md @@ -50,7 +50,7 @@ You can also link to sections using URL fragment specifiers: struct MySpecialFormatter; ``` -Paths in Rust have three namespaces: type, value, and macro. Items from these namespaces are allowed to overlap. In case of ambiguity, rustdoc will warn about the ambiguity and ask you to disambiguate, which can be done by using a prefix like `struct@`, `enum@`, `type@`, `trait@`, `union@`, `const@`, `static@`, `value@`, `function@`, `mod@`, `fn@`, `module@`, `method@`, `prim@`, `primitive@`, `macro@`, or `derive@`: +Paths in Rust have three namespaces: type, value, and macro. Items from these namespaces are allowed to overlap. In case of ambiguity, rustdoc will warn about the ambiguity and ask you to disambiguate, which can be done by using a prefix like `struct@`, `enum@`, `type@`, `trait@`, `union@`, `const@`, `static@`, `value@`, `function@`, `mod@`, `fn@`, `module@`, `method@`, `primitive@`, `macro@`, or `derive@`: ```rust /// See also: [`Foo`](struct@Foo) diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index cd6a7feb18029..02996d89169ed 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -964,7 +964,7 @@ impl LinkCollector<'_, '_> { ) && !matches!(res, Res::PrimTy(_)) { if let Some((path, prim)) = is_primitive(path_str, TypeNS) { - // `prim@char` + // `primitive@char` if matches!(disambiguator, Some(Disambiguator::Primitive)) { if fragment.is_some() { anchor_failure( @@ -1299,7 +1299,7 @@ impl Disambiguator { "type" => NS(Namespace::TypeNS), "value" => NS(Namespace::ValueNS), "macro" => NS(Namespace::MacroNS), - "prim" | "primitive" => Primitive, + "primitive" => Primitive, _ => return find_suffix(), }; Ok((d, &rest[1..])) @@ -1319,7 +1319,7 @@ impl Disambiguator { fn suggestion(self) -> Suggestion { let kind = match self { - Disambiguator::Primitive => return Suggestion::Prefix("prim"), + Disambiguator::Primitive => return Suggestion::Prefix("primitive"), Disambiguator::Kind(kind) => kind, Disambiguator::Namespace(_) => panic!("display_for cannot be used on namespaces"), }; diff --git a/src/test/rustdoc-ui/intra-link-prim-conflict.rs b/src/test/rustdoc-ui/intra-link-prim-conflict.rs index 85738ceae8e61..30d91a735da8f 100644 --- a/src/test/rustdoc-ui/intra-link-prim-conflict.rs +++ b/src/test/rustdoc-ui/intra-link-prim-conflict.rs @@ -14,7 +14,7 @@ //~| HELP to link to the builtin type /// [mod@char] // ok -/// [prim@char] // ok +/// [primitive@char] // ok /// [struct@char] //~^ ERROR incompatible link @@ -25,6 +25,6 @@ pub mod char {} pub mod inner { //! [struct@char] //~^ ERROR incompatible link - //~| HELP prefix with `prim@` + //~| HELP prefix with `primitive@` //~| NOTE resolved to a builtin type } diff --git a/src/test/rustdoc-ui/intra-link-prim-conflict.stderr b/src/test/rustdoc-ui/intra-link-prim-conflict.stderr index 43587a80021af..82952e3e3649f 100644 --- a/src/test/rustdoc-ui/intra-link-prim-conflict.stderr +++ b/src/test/rustdoc-ui/intra-link-prim-conflict.stderr @@ -13,10 +13,10 @@ help: to link to the module, prefix with `mod@` | LL | /// [mod@char] | ^^^^^^^^ -help: to link to the builtin type, prefix with `prim@` +help: to link to the builtin type, prefix with `primitive@` | -LL | /// [prim@char] - | ^^^^^^^^^ +LL | /// [primitive@char] + | ^^^^^^^^^^^^^^ error: `char` is both a module and a builtin type --> $DIR/intra-link-prim-conflict.rs:10:6 @@ -28,10 +28,10 @@ help: to link to the module, prefix with `mod@` | LL | /// [mod@char] | ^^^^^^^^ -help: to link to the builtin type, prefix with `prim@` +help: to link to the builtin type, prefix with `primitive@` | -LL | /// [prim@char] - | ^^^^^^^^^ +LL | /// [primitive@char] + | ^^^^^^^^^^^^^^ error: incompatible link kind for `char` --> $DIR/intra-link-prim-conflict.rs:19:6 @@ -45,7 +45,7 @@ error: incompatible link kind for `char` --> $DIR/intra-link-prim-conflict.rs:26:10 | LL | //! [struct@char] - | ^^^^^^^^^^^ help: to link to the builtin type, prefix with `prim@`: `prim@char` + | ^^^^^^^^^^^ help: to link to the builtin type, prefix with `primitive@`: `primitive@char` | = note: this link resolved to a builtin type, which is not a struct diff --git a/src/test/rustdoc/intra-link-prim-precedence.rs b/src/test/rustdoc/intra-link-prim-precedence.rs index 0a4e57ef643e7..e5d9d3fa690aa 100644 --- a/src/test/rustdoc/intra-link-prim-precedence.rs +++ b/src/test/rustdoc/intra-link-prim-precedence.rs @@ -7,7 +7,7 @@ pub mod char { pub struct Inner; } -/// See [prim@char] +/// See [primitive@char] // @has intra_link_prim_precedence/struct.MyString.html '//a/@href' 'https://doc.rust-lang.org/nightly/std/primitive.char.html' pub struct MyString; From 0f8c9339002f5ce3d5dec619dedc1278b183cd15 Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Thu, 24 Sep 2020 18:01:23 +0530 Subject: [PATCH 2/2] Remove some intra-doc link disambiguation aliases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Following on from what I think should be the fairly uncontroversial killing of the prim@ disambiguation prefix in favour of primitive@, we have a few more aliases that it may be worth evicting from rustdoc. - `function` is removed in favour of `fn`, which matches the keyword and the fn.*.html filenames. - `module` is removed in favour of `mod`, which matches the keyword. Modules become folders, so there’s no filename argument. I have kept two aliases at this time because I think more discussion is called for: - `method` is retained as an alias of `fn`; it matches the method.* fragment that methods are given. Well, unless they’re tymethod.*. Should tymethod therefore be allowed as an alias? As I say, discussion is called for. Also, subjectively people may prefer to call a thing a method than a function, though that argument could be applied to retaining the “function” and “module” spellings. - `constant` is retained as an alias of `const`; their filenames are currently of the form constant.*.html. --- src/doc/rustdoc/src/linking-to-items-by-name.md | 2 +- src/librustdoc/passes/collect_intra_doc_links.rs | 4 ++-- src/test/rustdoc/intra-doc-crate/auxiliary/hidden.rs | 2 +- src/test/rustdoc/intra-doc-link-mod-ambiguity.rs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/doc/rustdoc/src/linking-to-items-by-name.md b/src/doc/rustdoc/src/linking-to-items-by-name.md index 0dd6d8081686d..adde6378bb88b 100644 --- a/src/doc/rustdoc/src/linking-to-items-by-name.md +++ b/src/doc/rustdoc/src/linking-to-items-by-name.md @@ -50,7 +50,7 @@ You can also link to sections using URL fragment specifiers: struct MySpecialFormatter; ``` -Paths in Rust have three namespaces: type, value, and macro. Items from these namespaces are allowed to overlap. In case of ambiguity, rustdoc will warn about the ambiguity and ask you to disambiguate, which can be done by using a prefix like `struct@`, `enum@`, `type@`, `trait@`, `union@`, `const@`, `static@`, `value@`, `function@`, `mod@`, `fn@`, `module@`, `method@`, `primitive@`, `macro@`, or `derive@`: +Paths in Rust have three namespaces: type, value, and macro. Items from these namespaces are allowed to overlap. In case of ambiguity, rustdoc will warn about the ambiguity and ask you to disambiguate, which can be done by using a prefix like `struct@`, `enum@`, `type@`, `trait@`, `union@`, `const@`, `static@`, `value@`, `mod@`, `fn@`, `method@`, `primitive@`, `macro@`, or `derive@`: ```rust /// See also: [`Foo`](struct@Foo) diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 02996d89169ed..9c2f05a1b429a 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -1291,10 +1291,10 @@ impl Disambiguator { "enum" => Kind(DefKind::Enum), "trait" => Kind(DefKind::Trait), "union" => Kind(DefKind::Union), - "module" | "mod" => Kind(DefKind::Mod), + "mod" => Kind(DefKind::Mod), "const" | "constant" => Kind(DefKind::Const), "static" => Kind(DefKind::Static), - "function" | "fn" | "method" => Kind(DefKind::Fn), + "fn" | "method" => Kind(DefKind::Fn), "derive" => Kind(DefKind::Macro(MacroKind::Derive)), "type" => NS(Namespace::TypeNS), "value" => NS(Namespace::ValueNS), diff --git a/src/test/rustdoc/intra-doc-crate/auxiliary/hidden.rs b/src/test/rustdoc/intra-doc-crate/auxiliary/hidden.rs index b543ae764c05b..c64108b19b74e 100644 --- a/src/test/rustdoc/intra-doc-crate/auxiliary/hidden.rs +++ b/src/test/rustdoc/intra-doc-crate/auxiliary/hidden.rs @@ -9,7 +9,7 @@ pub mod __reexport { pub mod future { mod ready { - /// Link to [`ready`](function@ready) + /// Link to [`ready`](fn@ready) pub struct Ready; pub fn ready() {} diff --git a/src/test/rustdoc/intra-doc-link-mod-ambiguity.rs b/src/test/rustdoc/intra-doc-link-mod-ambiguity.rs index bd733e1023033..d74036d1d8030 100644 --- a/src/test/rustdoc/intra-doc-link-mod-ambiguity.rs +++ b/src/test/rustdoc/intra-doc-link-mod-ambiguity.rs @@ -9,7 +9,7 @@ pub fn foo() { pub mod foo {} // @has intra_doc_link_mod_ambiguity/struct.A.html '//a/@href' '../intra_doc_link_mod_ambiguity/foo/index.html' -/// Module is [`module@foo`] +/// Module is [`mod@foo`] pub struct A;