summaryrefslogtreecommitdiff
path: root/tests/rustdoc-ui
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2023-03-31 22:32:48 +0200
committerGitHub <noreply@github.com>2023-03-31 22:32:48 +0200
commit8fe5b56b66ebd1a125275b6219301cf797fc5ff9 (patch)
treee0a11c2952fb8b2ed780e14a851b80165e30325e /tests/rustdoc-ui
parent480068c2359ea65df4481788b5ce717a548ce171 (diff)
parent415a3ca909084e83441306b21db5232ee8952fc4 (diff)
downloadrust-8fe5b56b66ebd1a125275b6219301cf797fc5ff9.tar.gz
Rollup merge of #109104 - GuillaumeGomez:fix-invalid-suggestion-ambiguous-intra-doc2, r=oli-obk,notriddle
rustdoc: Fix invalid suggestions on ambiguous intra doc links v2 Fixes https://github.com/rust-lang/rust/issues/108653. This is another approach to fixing the same issue. This time, we keep the computed information around instead of re-computing it. Strangely enough, the order for ambiguities seem to have been changed. Not an issue but it creates a lot of diff... So which version do you prefer? r? `@notriddle`
Diffstat (limited to 'tests/rustdoc-ui')
-rw-r--r--tests/rustdoc-ui/intra-doc/ambiguity.rs2
-rw-r--r--tests/rustdoc-ui/intra-doc/ambiguity.stderr54
-rw-r--r--tests/rustdoc-ui/intra-doc/errors.rs4
-rw-r--r--tests/rustdoc-ui/intra-doc/errors.stderr4
-rw-r--r--tests/rustdoc-ui/intra-doc/issue-108653-associated-items-10.rs22
-rw-r--r--tests/rustdoc-ui/intra-doc/issue-108653-associated-items-2.rs17
-rw-r--r--tests/rustdoc-ui/intra-doc/issue-108653-associated-items-2.stderr37
-rw-r--r--tests/rustdoc-ui/intra-doc/issue-108653-associated-items-3.rs16
-rw-r--r--tests/rustdoc-ui/intra-doc/issue-108653-associated-items-3.stderr37
-rw-r--r--tests/rustdoc-ui/intra-doc/issue-108653-associated-items-4.rs21
-rw-r--r--tests/rustdoc-ui/intra-doc/issue-108653-associated-items-4.stderr22
-rw-r--r--tests/rustdoc-ui/intra-doc/issue-108653-associated-items-5.rs8
-rw-r--r--tests/rustdoc-ui/intra-doc/issue-108653-associated-items-5.stderr22
-rw-r--r--tests/rustdoc-ui/intra-doc/issue-108653-associated-items-6.rs8
-rw-r--r--tests/rustdoc-ui/intra-doc/issue-108653-associated-items-6.stderr22
-rw-r--r--tests/rustdoc-ui/intra-doc/issue-108653-associated-items-7.rs12
-rw-r--r--tests/rustdoc-ui/intra-doc/issue-108653-associated-items-7.stderr22
-rw-r--r--tests/rustdoc-ui/intra-doc/issue-108653-associated-items-8.rs12
-rw-r--r--tests/rustdoc-ui/intra-doc/issue-108653-associated-items-8.stderr22
-rw-r--r--tests/rustdoc-ui/intra-doc/issue-108653-associated-items-9.rs11
-rw-r--r--tests/rustdoc-ui/intra-doc/issue-108653-associated-items.rs35
-rw-r--r--tests/rustdoc-ui/intra-doc/issue-108653-associated-items.stderr67
-rw-r--r--tests/rustdoc-ui/intra-doc/non-path-primitives.stderr8
-rw-r--r--tests/rustdoc-ui/intra-doc/prim-conflict.rs10
-rw-r--r--tests/rustdoc-ui/intra-doc/prim-conflict.stderr12
25 files changed, 460 insertions, 47 deletions
diff --git a/tests/rustdoc-ui/intra-doc/ambiguity.rs b/tests/rustdoc-ui/intra-doc/ambiguity.rs
index 1f3dc722eff..0290b858204 100644
--- a/tests/rustdoc-ui/intra-doc/ambiguity.rs
+++ b/tests/rustdoc-ui/intra-doc/ambiguity.rs
@@ -35,6 +35,6 @@ pub mod foo {
/// Ambiguous non-implied shortcut link [`foo::bar`]. //~ERROR `foo::bar`
pub struct Docs {}
-/// [true] //~ ERROR `true` is both a module and a builtin type
+/// [true] //~ ERROR `true` is both a module and a primitive type
/// [primitive@true]
pub mod r#true {}
diff --git a/tests/rustdoc-ui/intra-doc/ambiguity.stderr b/tests/rustdoc-ui/intra-doc/ambiguity.stderr
index 7974796e47b..47853e0b589 100644
--- a/tests/rustdoc-ui/intra-doc/ambiguity.stderr
+++ b/tests/rustdoc-ui/intra-doc/ambiguity.stderr
@@ -1,4 +1,4 @@
-error: `true` is both a module and a builtin type
+error: `true` is both a module and a primitive type
--> $DIR/ambiguity.rs:38:6
|
LL | /// [true]
@@ -13,89 +13,89 @@ help: to link to the module, prefix with `mod@`
|
LL | /// [mod@true]
| ++++
-help: to link to the builtin type, prefix with `prim@`
+help: to link to the primitive type, prefix with `prim@`
|
LL | /// [prim@true]
| +++++
-error: `ambiguous` is both a struct and a function
+error: `ambiguous` is both a function and a struct
--> $DIR/ambiguity.rs:27:7
|
LL | /// [`ambiguous`] is ambiguous.
| ^^^^^^^^^ ambiguous link
|
-help: to link to the struct, prefix with `struct@`
- |
-LL | /// [`struct@ambiguous`] is ambiguous.
- | +++++++
help: to link to the function, add parentheses
|
LL | /// [`ambiguous()`] is ambiguous.
| ++
+help: to link to the struct, prefix with `struct@`
+ |
+LL | /// [`struct@ambiguous`] is ambiguous.
+ | +++++++
-error: `ambiguous` is both a struct and a function
+error: `ambiguous` is both a function and a struct
--> $DIR/ambiguity.rs:29:6
|
LL | /// [ambiguous] is ambiguous.
| ^^^^^^^^^ ambiguous link
|
-help: to link to the struct, prefix with `struct@`
- |
-LL | /// [struct@ambiguous] is ambiguous.
- | +++++++
help: to link to the function, add parentheses
|
LL | /// [ambiguous()] is ambiguous.
| ++
+help: to link to the struct, prefix with `struct@`
+ |
+LL | /// [struct@ambiguous] is ambiguous.
+ | +++++++
-error: `multi_conflict` is a struct, a function, and a macro
+error: `multi_conflict` is a function, a struct, and a macro
--> $DIR/ambiguity.rs:31:7
|
LL | /// [`multi_conflict`] is a three-way conflict.
| ^^^^^^^^^^^^^^ ambiguous link
|
-help: to link to the struct, prefix with `struct@`
- |
-LL | /// [`struct@multi_conflict`] is a three-way conflict.
- | +++++++
help: to link to the function, add parentheses
|
LL | /// [`multi_conflict()`] is a three-way conflict.
| ++
+help: to link to the struct, prefix with `struct@`
+ |
+LL | /// [`struct@multi_conflict`] is a three-way conflict.
+ | +++++++
help: to link to the macro, add an exclamation mark
|
LL | /// [`multi_conflict!`] is a three-way conflict.
| +
-error: `type_and_value` is both a module and a constant
+error: `type_and_value` is both a constant and a module
--> $DIR/ambiguity.rs:33:16
|
LL | /// Ambiguous [type_and_value].
| ^^^^^^^^^^^^^^ ambiguous link
|
-help: to link to the module, prefix with `mod@`
- |
-LL | /// Ambiguous [mod@type_and_value].
- | ++++
help: to link to the constant, prefix with `const@`
|
LL | /// Ambiguous [const@type_and_value].
| ++++++
+help: to link to the module, prefix with `mod@`
+ |
+LL | /// Ambiguous [mod@type_and_value].
+ | ++++
-error: `foo::bar` is both an enum and a function
+error: `foo::bar` is both a function and an enum
--> $DIR/ambiguity.rs:35:43
|
LL | /// Ambiguous non-implied shortcut link [`foo::bar`].
| ^^^^^^^^ ambiguous link
|
-help: to link to the enum, prefix with `enum@`
- |
-LL | /// Ambiguous non-implied shortcut link [`enum@foo::bar`].
- | +++++
help: to link to the function, add parentheses
|
LL | /// Ambiguous non-implied shortcut link [`foo::bar()`].
| ++
+help: to link to the enum, prefix with `enum@`
+ |
+LL | /// Ambiguous non-implied shortcut link [`enum@foo::bar`].
+ | +++++
error: aborting due to 6 previous errors
diff --git a/tests/rustdoc-ui/intra-doc/errors.rs b/tests/rustdoc-ui/intra-doc/errors.rs
index 95dd2b98e03..f37f49c24cc 100644
--- a/tests/rustdoc-ui/intra-doc/errors.rs
+++ b/tests/rustdoc-ui/intra-doc/errors.rs
@@ -54,11 +54,11 @@
/// [u8::not_found]
//~^ ERROR unresolved link
-//~| NOTE the builtin type `u8` has no associated item named `not_found`
+//~| NOTE the primitive type `u8` has no associated item named `not_found`
/// [std::primitive::u8::not_found]
//~^ ERROR unresolved link
-//~| NOTE the builtin type `u8` has no associated item named `not_found`
+//~| NOTE the primitive type `u8` has no associated item named `not_found`
/// [type@Vec::into_iter]
//~^ ERROR unresolved link
diff --git a/tests/rustdoc-ui/intra-doc/errors.stderr b/tests/rustdoc-ui/intra-doc/errors.stderr
index 1b2416d7da7..a982bba0095 100644
--- a/tests/rustdoc-ui/intra-doc/errors.stderr
+++ b/tests/rustdoc-ui/intra-doc/errors.stderr
@@ -80,13 +80,13 @@ error: unresolved link to `u8::not_found`
--> $DIR/errors.rs:55:6
|
LL | /// [u8::not_found]
- | ^^^^^^^^^^^^^ the builtin type `u8` has no associated item named `not_found`
+ | ^^^^^^^^^^^^^ the primitive type `u8` has no associated item named `not_found`
error: unresolved link to `std::primitive::u8::not_found`
--> $DIR/errors.rs:59:6
|
LL | /// [std::primitive::u8::not_found]
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the builtin type `u8` has no associated item named `not_found`
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the primitive type `u8` has no associated item named `not_found`
error: unresolved link to `Vec::into_iter`
--> $DIR/errors.rs:63:6
diff --git a/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-10.rs b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-10.rs
new file mode 100644
index 00000000000..464c5f0d543
--- /dev/null
+++ b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-10.rs
@@ -0,0 +1,22 @@
+// This test ensures that this warning doesn't show up:
+// warning: `PartialEq` is both a trait and a derive macro
+// --> tests/rustdoc-ui/intra-doc/issue-108653-associated-items-10.rs:1:7
+// |
+// 1 | //! [`PartialEq`]
+// | ^^^^^^^^^ ambiguous link
+// |
+// = note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default
+// help: to link to the trait, prefix with `trait@`
+// |
+// 1 | //! [`trait@PartialEq`]
+// | ++++++
+// help: to link to the derive macro, prefix with `derive@`
+// |
+// 1 | //! [`derive@PartialEq`]
+// | +++++++
+
+// check-pass
+
+#![deny(rustdoc::broken_intra_doc_links)]
+
+//! [`PartialEq`]
diff --git a/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-2.rs b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-2.rs
new file mode 100644
index 00000000000..cbe60f746b6
--- /dev/null
+++ b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-2.rs
@@ -0,0 +1,17 @@
+// This is ensuring that the UI output for associated items is as expected.
+
+#![deny(rustdoc::broken_intra_doc_links)]
+
+/// [`Trait::IDENT`]
+//~^ ERROR both an associated constant and an associated type
+pub trait Trait {
+ type IDENT;
+ const IDENT: usize;
+}
+
+/// [`Trait2::IDENT`]
+//~^ ERROR both an associated function and an associated type
+pub trait Trait2 {
+ type IDENT;
+ fn IDENT() {}
+}
diff --git a/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-2.stderr b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-2.stderr
new file mode 100644
index 00000000000..952392548da
--- /dev/null
+++ b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-2.stderr
@@ -0,0 +1,37 @@
+error: `Trait::IDENT` is both an associated constant and an associated type
+ --> $DIR/issue-108653-associated-items-2.rs:5:7
+ |
+LL | /// [`Trait::IDENT`]
+ | ^^^^^^^^^^^^ ambiguous link
+ |
+note: the lint level is defined here
+ --> $DIR/issue-108653-associated-items-2.rs:3:9
+ |
+LL | #![deny(rustdoc::broken_intra_doc_links)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+help: to link to the associated constant, prefix with `const@`
+ |
+LL | /// [`const@Trait::IDENT`]
+ | ++++++
+help: to link to the associated type, prefix with `type@`
+ |
+LL | /// [`type@Trait::IDENT`]
+ | +++++
+
+error: `Trait2::IDENT` is both an associated function and an associated type
+ --> $DIR/issue-108653-associated-items-2.rs:12:7
+ |
+LL | /// [`Trait2::IDENT`]
+ | ^^^^^^^^^^^^^ ambiguous link
+ |
+help: to link to the associated function, add parentheses
+ |
+LL | /// [`Trait2::IDENT()`]
+ | ++
+help: to link to the associated type, prefix with `type@`
+ |
+LL | /// [`type@Trait2::IDENT`]
+ | +++++
+
+error: aborting due to 2 previous errors
+
diff --git a/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-3.rs b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-3.rs
new file mode 100644
index 00000000000..7ffd0a40e7c
--- /dev/null
+++ b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-3.rs
@@ -0,0 +1,16 @@
+// This is ensuring that the UI output for associated items works when it's being documented
+// from another item.
+
+#![deny(rustdoc::broken_intra_doc_links)]
+#![allow(nonstandard_style)]
+
+pub trait Trait {
+ type Trait;
+ const Trait: usize;
+}
+
+/// [`Trait`]
+//~^ ERROR both a constant and a trait
+/// [`Trait::Trait`]
+//~^ ERROR both an associated constant and an associated type
+pub const Trait: usize = 0;
diff --git a/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-3.stderr b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-3.stderr
new file mode 100644
index 00000000000..6401dacb57a
--- /dev/null
+++ b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-3.stderr
@@ -0,0 +1,37 @@
+error: `Trait` is both a constant and a trait
+ --> $DIR/issue-108653-associated-items-3.rs:12:7
+ |
+LL | /// [`Trait`]
+ | ^^^^^ ambiguous link
+ |
+note: the lint level is defined here
+ --> $DIR/issue-108653-associated-items-3.rs:4:9
+ |
+LL | #![deny(rustdoc::broken_intra_doc_links)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+help: to link to the constant, prefix with `const@`
+ |
+LL | /// [`const@Trait`]
+ | ++++++
+help: to link to the trait, prefix with `trait@`
+ |
+LL | /// [`trait@Trait`]
+ | ++++++
+
+error: `Trait::Trait` is both an associated constant and an associated type
+ --> $DIR/issue-108653-associated-items-3.rs:14:7
+ |
+LL | /// [`Trait::Trait`]
+ | ^^^^^^^^^^^^ ambiguous link
+ |
+help: to link to the associated constant, prefix with `const@`
+ |
+LL | /// [`const@Trait::Trait`]
+ | ++++++
+help: to link to the associated type, prefix with `type@`
+ |
+LL | /// [`type@Trait::Trait`]
+ | +++++
+
+error: aborting due to 2 previous errors
+
diff --git a/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-4.rs b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-4.rs
new file mode 100644
index 00000000000..537d61364bb
--- /dev/null
+++ b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-4.rs
@@ -0,0 +1,21 @@
+// This is ensuring that the UI output for associated items works when it's being documented
+// from another item.
+
+#![deny(rustdoc::broken_intra_doc_links)]
+#![allow(nonstandard_style)]
+
+pub trait Trait {
+ type Trait;
+}
+
+/// [`Struct::Trait`]
+//~^ ERROR both an associated constant and an associated type
+pub struct Struct;
+
+impl Trait for Struct {
+ type Trait = Struct;
+}
+
+impl Struct {
+ pub const Trait: usize = 0;
+}
diff --git a/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-4.stderr b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-4.stderr
new file mode 100644
index 00000000000..a8dc91204c0
--- /dev/null
+++ b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-4.stderr
@@ -0,0 +1,22 @@
+error: `Struct::Trait` is both an associated constant and an associated type
+ --> $DIR/issue-108653-associated-items-4.rs:11:7
+ |
+LL | /// [`Struct::Trait`]
+ | ^^^^^^^^^^^^^ ambiguous link
+ |
+note: the lint level is defined here
+ --> $DIR/issue-108653-associated-items-4.rs:4:9
+ |
+LL | #![deny(rustdoc::broken_intra_doc_links)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+help: to link to the associated constant, prefix with `const@`
+ |
+LL | /// [`const@Struct::Trait`]
+ | ++++++
+help: to link to the associated type, prefix with `type@`
+ |
+LL | /// [`type@Struct::Trait`]
+ | +++++
+
+error: aborting due to previous error
+
diff --git a/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-5.rs b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-5.rs
new file mode 100644
index 00000000000..bc28bc54421
--- /dev/null
+++ b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-5.rs
@@ -0,0 +1,8 @@
+#![deny(rustdoc::broken_intra_doc_links)]
+#![allow(nonstandard_style)]
+
+/// [`u32::MAX`]
+//~^ ERROR both an associated constant and a trait
+pub mod u32 {
+ pub trait MAX {}
+}
diff --git a/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-5.stderr b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-5.stderr
new file mode 100644
index 00000000000..7430044ac3f
--- /dev/null
+++ b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-5.stderr
@@ -0,0 +1,22 @@
+error: `u32::MAX` is both an associated constant and a trait
+ --> $DIR/issue-108653-associated-items-5.rs:4:7
+ |
+LL | /// [`u32::MAX`]
+ | ^^^^^^^^ ambiguous link
+ |
+note: the lint level is defined here
+ --> $DIR/issue-108653-associated-items-5.rs:1:9
+ |
+LL | #![deny(rustdoc::broken_intra_doc_links)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+help: to link to the associated constant, prefix with `const@`
+ |
+LL | /// [`const@u32::MAX`]
+ | ++++++
+help: to link to the trait, prefix with `trait@`
+ |
+LL | /// [`trait@u32::MAX`]
+ | ++++++
+
+error: aborting due to previous error
+
diff --git a/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-6.rs b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-6.rs
new file mode 100644
index 00000000000..8fde74d0ddb
--- /dev/null
+++ b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-6.rs
@@ -0,0 +1,8 @@
+#![deny(rustdoc::broken_intra_doc_links)]
+#![allow(nonstandard_style)]
+
+/// [`u32::MAX`]
+//~^ ERROR both an associated constant and a primitive type
+pub mod u32 {
+ pub use std::primitive::u32 as MAX;
+}
diff --git a/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-6.stderr b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-6.stderr
new file mode 100644
index 00000000000..fe2d8cafa30
--- /dev/null
+++ b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-6.stderr
@@ -0,0 +1,22 @@
+error: `u32::MAX` is both an associated constant and a primitive type
+ --> $DIR/issue-108653-associated-items-6.rs:4:7
+ |
+LL | /// [`u32::MAX`]
+ | ^^^^^^^^ ambiguous link
+ |
+note: the lint level is defined here
+ --> $DIR/issue-108653-associated-items-6.rs:1:9
+ |
+LL | #![deny(rustdoc::broken_intra_doc_links)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+help: to link to the associated constant, prefix with `const@`
+ |
+LL | /// [`const@u32::MAX`]
+ | ++++++
+help: to link to the primitive type, prefix with `prim@`
+ |
+LL | /// [`prim@u32::MAX`]
+ | +++++
+
+error: aborting due to previous error
+
diff --git a/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-7.rs b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-7.rs
new file mode 100644
index 00000000000..6e99f4365a7
--- /dev/null
+++ b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-7.rs
@@ -0,0 +1,12 @@
+#![deny(rustdoc::broken_intra_doc_links)]
+#![allow(nonstandard_style)]
+
+pub trait Trait {
+ type MAX;
+}
+
+/// [`u32::MAX`]
+//~^ ERROR both an associated constant and an associated type
+impl Trait for u32 {
+ type MAX = u32;
+}
diff --git a/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-7.stderr b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-7.stderr
new file mode 100644
index 00000000000..1d302ff42e8
--- /dev/null
+++ b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-7.stderr
@@ -0,0 +1,22 @@
+error: `u32::MAX` is both an associated constant and an associated type
+ --> $DIR/issue-108653-associated-items-7.rs:8:7
+ |
+LL | /// [`u32::MAX`]
+ | ^^^^^^^^ ambiguous link
+ |
+note: the lint level is defined here
+ --> $DIR/issue-108653-associated-items-7.rs:1:9
+ |
+LL | #![deny(rustdoc::broken_intra_doc_links)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+help: to link to the associated constant, prefix with `const@`
+ |
+LL | /// [`const@u32::MAX`]
+ | ++++++
+help: to link to the associated type, prefix with `type@`
+ |
+LL | /// [`type@u32::MAX`]
+ | +++++
+
+error: aborting due to previous error
+
diff --git a/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-8.rs b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-8.rs
new file mode 100644
index 00000000000..2f8ee1566bd
--- /dev/null
+++ b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-8.rs
@@ -0,0 +1,12 @@
+#![deny(rustdoc::broken_intra_doc_links)]
+#![allow(nonstandard_style)]
+
+/// [`u32::MAX`]
+//~^ ERROR both an associated constant and an associated type
+pub trait T {
+ type MAX;
+}
+
+impl T for u32 {
+ type MAX = ();
+}
diff --git a/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-8.stderr b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-8.stderr
new file mode 100644
index 00000000000..efed0e2ce0f
--- /dev/null
+++ b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-8.stderr
@@ -0,0 +1,22 @@
+error: `u32::MAX` is both an associated constant and an associated type
+ --> $DIR/issue-108653-associated-items-8.rs:4:7
+ |
+LL | /// [`u32::MAX`]
+ | ^^^^^^^^ ambiguous link
+ |
+note: the lint level is defined here
+ --> $DIR/issue-108653-associated-items-8.rs:1:9
+ |
+LL | #![deny(rustdoc::broken_intra_doc_links)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+help: to link to the associated constant, prefix with `const@`
+ |
+LL | /// [`const@u32::MAX`]
+ | ++++++
+help: to link to the associated type, prefix with `type@`
+ |
+LL | /// [`type@u32::MAX`]
+ | +++++
+
+error: aborting due to previous error
+
diff --git a/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-9.rs b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-9.rs
new file mode 100644
index 00000000000..3357ccf2460
--- /dev/null
+++ b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items-9.rs
@@ -0,0 +1,11 @@
+// check-pass
+
+#![deny(warnings)]
+
+//! [usize::Item]
+
+pub trait Foo { type Item; }
+pub trait Bar { type Item; }
+
+impl Foo for usize { type Item = u32; }
+impl Bar for usize { type Item = i32; }
diff --git a/tests/rustdoc-ui/intra-doc/issue-108653-associated-items.rs b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items.rs
new file mode 100644
index 00000000000..0a393e26d6a
--- /dev/null
+++ b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items.rs
@@ -0,0 +1,35 @@
+// This is ensuring that the UI output for associated items is as expected.
+
+#![deny(rustdoc::broken_intra_doc_links)]
+
+pub enum Enum {
+ IDENT,
+}
+
+/// [`Self::IDENT`]
+//~^ ERROR both an associated function and an associated type
+pub trait Trait {
+ type IDENT;
+ fn IDENT();
+}
+
+/// [`Self::IDENT`]
+//~^ ERROR both an associated function and a variant
+impl Trait for Enum {
+ type IDENT = usize;
+ fn IDENT() {}
+}
+
+/// [`Self::IDENT2`]
+//~^ ERROR both an associated constant and an associated type
+pub trait Trait2 {
+ type IDENT2;
+ const IDENT2: usize;
+}
+
+/// [`Self::IDENT2`]
+//~^ ERROR both an associated constant and an associated type
+impl Trait2 for Enum {
+ type IDENT2 = usize;
+ const IDENT2: usize = 0;
+}
diff --git a/tests/rustdoc-ui/intra-doc/issue-108653-associated-items.stderr b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items.stderr
new file mode 100644
index 00000000000..084aefc97c8
--- /dev/null
+++ b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items.stderr
@@ -0,0 +1,67 @@
+error: `Self::IDENT` is both an associated function and an associated type
+ --> $DIR/issue-108653-associated-items.rs:9:7
+ |
+LL | /// [`Self::IDENT`]
+ | ^^^^^^^^^^^ ambiguous link
+ |
+note: the lint level is defined here
+ --> $DIR/issue-108653-associated-items.rs:3:9
+ |
+LL | #![deny(rustdoc::broken_intra_doc_links)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+help: to link to the associated function, add parentheses
+ |
+LL | /// [`Self::IDENT()`]
+ | ++
+help: to link to the associated type, prefix with `type@`
+ |
+LL | /// [`type@Self::IDENT`]
+ | +++++
+
+error: `Self::IDENT2` is both an associated constant and an associated type
+ --> $DIR/issue-108653-associated-items.rs:23:7
+ |
+LL | /// [`Self::IDENT2`]
+ | ^^^^^^^^^^^^ ambiguous link
+ |
+help: to link to the associated constant, prefix with `const@`
+ |
+LL | /// [`const@Self::IDENT2`]
+ | ++++++
+help: to link to the associated type, prefix with `type@`
+ |
+LL | /// [`type@Self::IDENT2`]
+ | +++++
+
+error: `Self::IDENT2` is both an associated constant and an associated type
+ --> $DIR/issue-108653-associated-items.rs:30:7
+ |
+LL | /// [`Self::IDENT2`]
+ | ^^^^^^^^^^^^ ambiguous link
+ |
+help: to link to the associated constant, prefix with `const@`
+ |
+LL | /// [`const@Self::IDENT2`]
+ | ++++++
+help: to link to the associated type, prefix with `type@`
+ |
+LL | /// [`type@Self::IDENT2`]
+ | +++++
+
+error: `Self::IDENT` is both an associated function and a variant
+ --> $DIR/issue-108653-associated-items.rs:16:7
+ |
+LL | /// [`Self::IDENT`]
+ | ^^^^^^^^^^^ ambiguous link
+ |
+help: to link to the associated function, add parentheses
+ |
+LL | /// [`Self::IDENT()`]
+ | ++
+help: to link to the variant, prefix with `type@`
+ |
+LL | /// [`type@Self::IDENT`]
+ | +++++
+
+error: aborting due to 4 previous errors
+
diff --git a/tests/rustdoc-ui/intra-doc/non-path-primitives.stderr b/tests/rustdoc-ui/intra-doc/non-path-primitives.stderr
index 8ec894d101b..6e08a923963 100644
--- a/tests/rustdoc-ui/intra-doc/non-path-primitives.stderr
+++ b/tests/rustdoc-ui/intra-doc/non-path-primitives.stderr
@@ -39,25 +39,25 @@ error: unresolved link to `unit::eq`
--> $DIR/non-path-primitives.rs:28:6
|
LL | //! [unit::eq]
- | ^^^^^^^^ the builtin type `unit` has no associated item named `eq`
+ | ^^^^^^^^ the primitive type `unit` has no associated item named `eq`
error: unresolved link to `tuple::eq`
--> $DIR/non-path-primitives.rs:29:6
|
LL | //! [tuple::eq]
- | ^^^^^^^^^ the builtin type `tuple` has no associated item named `eq`
+ | ^^^^^^^^^ the primitive type `tuple` has no associated item named `eq`
error: unresolved link to `fn::eq`
--> $DIR/non-path-primitives.rs:30:6
|
LL | //! [fn::eq]
- | ^^^^^^ the builtin type `fn` has no associated item named `eq`
+ | ^^^^^^ the primitive type `fn` has no associated item named `eq`
error: unresolved link to `reference::deref`
--> $DIR/non-path-primitives.rs:34:6
|
LL | //! [reference::deref]
- | ^^^^^^^^^^^^^^^^ the builtin type `reference` has no associated item named `deref`
+ | ^^^^^^^^^^^^^^^^ the primitive type `reference` has no associated item named `deref`
error: aborting due to 8 previous errors
diff --git a/tests/rustdoc-ui/intra-doc/prim-conflict.rs b/tests/rustdoc-ui/intra-doc/prim-conflict.rs
index 2c1a8b5357a..e87ce095cd4 100644
--- a/tests/rustdoc-ui/intra-doc/prim-conflict.rs
+++ b/tests/rustdoc-ui/intra-doc/prim-conflict.rs
@@ -2,16 +2,16 @@
//~^ NOTE lint level is defined
/// [char]
-//~^ ERROR both a module and a builtin type
+//~^ ERROR both a module and a primitive type
//~| NOTE ambiguous link
//~| HELP to link to the module
-//~| HELP to link to the builtin type
+//~| HELP to link to the primitive type
/// [type@char]
-//~^ ERROR both a module and a builtin type
+//~^ ERROR both a module and a primitive type
//~| NOTE ambiguous link
//~| HELP to link to the module
-//~| HELP to link to the builtin type
+//~| HELP to link to the primitive type
/// [mod@char] // ok
/// [prim@char] // ok
@@ -26,5 +26,5 @@ pub mod inner {
//! [struct@char]
//~^ ERROR incompatible link
//~| HELP prefix with `prim@`
- //~| NOTE resolved to a builtin type
+ //~| NOTE resolved to a primitive type
}
diff --git a/tests/rustdoc-ui/intra-doc/prim-conflict.stderr b/tests/rustdoc-ui/intra-doc/prim-conflict.stderr
index 6ef3b7eab3b..03ce8f15f0a 100644
--- a/tests/rustdoc-ui/intra-doc/prim-conflict.stderr
+++ b/tests/rustdoc-ui/intra-doc/prim-conflict.stderr
@@ -1,4 +1,4 @@
-error: `char` is both a module and a builtin type
+error: `char` is both a module and a primitive type
--> $DIR/prim-conflict.rs:4:6
|
LL | /// [char]
@@ -13,12 +13,12 @@ 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 primitive type, prefix with `prim@`
|
LL | /// [prim@char]
| +++++
-error: `char` is both a module and a builtin type
+error: `char` is both a module and a primitive type
--> $DIR/prim-conflict.rs:10:6
|
LL | /// [type@char]
@@ -28,7 +28,7 @@ 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 primitive type, prefix with `prim@`
|
LL | /// [prim@char]
| ~~~~~
@@ -48,9 +48,9 @@ error: incompatible link kind for `char`
--> $DIR/prim-conflict.rs:26:10
|
LL | //! [struct@char]
- | ^^^^^^^^^^^ this link resolved to a builtin type, which is not a struct
+ | ^^^^^^^^^^^ this link resolved to a primitive type, which is not a struct
|
-help: to link to the builtin type, prefix with `prim@`
+help: to link to the primitive type, prefix with `prim@`
|
LL | //! [prim@char]
| ~~~~~