From c78ebab2580b9532ad58facc1f5731a3a1cfa42a Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 3 Mar 2023 14:54:56 +0100 Subject: [PATCH] Add regression tests for #108653 --- tests/rustdoc-ui/intra-doc/ambiguity.stderr | 50 +++++++------- .../issue-108653-associated-items-2.rs | 17 +++++ .../issue-108653-associated-items-2.stderr | 37 ++++++++++ .../issue-108653-associated-items-3.rs | 16 +++++ .../issue-108653-associated-items-3.stderr | 37 ++++++++++ .../issue-108653-associated-items-4.rs | 21 ++++++ .../issue-108653-associated-items-4.stderr | 22 ++++++ .../issue-108653-associated-items-5.rs | 8 +++ .../issue-108653-associated-items-5.stderr | 22 ++++++ .../issue-108653-associated-items-6.rs | 8 +++ .../issue-108653-associated-items-6.stderr | 22 ++++++ .../issue-108653-associated-items-7.rs | 12 ++++ .../issue-108653-associated-items-7.stderr | 22 ++++++ .../issue-108653-associated-items-8.rs | 12 ++++ .../issue-108653-associated-items-8.stderr | 22 ++++++ .../issue-108653-associated-items-9.rs | 11 +++ .../issue-108653-associated-items.rs | 35 ++++++++++ .../issue-108653-associated-items.stderr | 67 +++++++++++++++++++ 18 files changed, 416 insertions(+), 25 deletions(-) create mode 100644 tests/rustdoc-ui/intra-doc/issue-108653-associated-items-2.rs create mode 100644 tests/rustdoc-ui/intra-doc/issue-108653-associated-items-2.stderr create mode 100644 tests/rustdoc-ui/intra-doc/issue-108653-associated-items-3.rs create mode 100644 tests/rustdoc-ui/intra-doc/issue-108653-associated-items-3.stderr create mode 100644 tests/rustdoc-ui/intra-doc/issue-108653-associated-items-4.rs create mode 100644 tests/rustdoc-ui/intra-doc/issue-108653-associated-items-4.stderr create mode 100644 tests/rustdoc-ui/intra-doc/issue-108653-associated-items-5.rs create mode 100644 tests/rustdoc-ui/intra-doc/issue-108653-associated-items-5.stderr create mode 100644 tests/rustdoc-ui/intra-doc/issue-108653-associated-items-6.rs create mode 100644 tests/rustdoc-ui/intra-doc/issue-108653-associated-items-6.stderr create mode 100644 tests/rustdoc-ui/intra-doc/issue-108653-associated-items-7.rs create mode 100644 tests/rustdoc-ui/intra-doc/issue-108653-associated-items-7.stderr create mode 100644 tests/rustdoc-ui/intra-doc/issue-108653-associated-items-8.rs create mode 100644 tests/rustdoc-ui/intra-doc/issue-108653-associated-items-8.stderr create mode 100644 tests/rustdoc-ui/intra-doc/issue-108653-associated-items-9.rs create mode 100644 tests/rustdoc-ui/intra-doc/issue-108653-associated-items.rs create mode 100644 tests/rustdoc-ui/intra-doc/issue-108653-associated-items.stderr diff --git a/tests/rustdoc-ui/intra-doc/ambiguity.stderr b/tests/rustdoc-ui/intra-doc/ambiguity.stderr index 7974796e47b..9e12bb5efc3 100644 --- a/tests/rustdoc-ui/intra-doc/ambiguity.stderr +++ b/tests/rustdoc-ui/intra-doc/ambiguity.stderr @@ -18,84 +18,84 @@ help: to link to the builtin 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/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..d5ba259d54b --- /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 builtin 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..af138a75682 --- /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 builtin 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 builtin 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 +