-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #109104 - GuillaumeGomez:fix-invalid-suggestion-ambig…
…uous-intra-doc2, r=oli-obk,notriddle rustdoc: Fix invalid suggestions on ambiguous intra doc links v2 Fixes #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`
- Loading branch information
Showing
26 changed files
with
702 additions
and
189 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
tests/rustdoc-ui/intra-doc/issue-108653-associated-items-10.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`] |
17 changes: 17 additions & 0 deletions
17
tests/rustdoc-ui/intra-doc/issue-108653-associated-items-2.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} | ||
} |
37 changes: 37 additions & 0 deletions
37
tests/rustdoc-ui/intra-doc/issue-108653-associated-items-2.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
16 changes: 16 additions & 0 deletions
16
tests/rustdoc-ui/intra-doc/issue-108653-associated-items-3.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
37 changes: 37 additions & 0 deletions
37
tests/rustdoc-ui/intra-doc/issue-108653-associated-items-3.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
21 changes: 21 additions & 0 deletions
21
tests/rustdoc-ui/intra-doc/issue-108653-associated-items-4.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
22 changes: 22 additions & 0 deletions
22
tests/rustdoc-ui/intra-doc/issue-108653-associated-items-4.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
8 changes: 8 additions & 0 deletions
8
tests/rustdoc-ui/intra-doc/issue-108653-associated-items-5.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 {} | ||
} |
22 changes: 22 additions & 0 deletions
22
tests/rustdoc-ui/intra-doc/issue-108653-associated-items-5.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
8 changes: 8 additions & 0 deletions
8
tests/rustdoc-ui/intra-doc/issue-108653-associated-items-6.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
Oops, something went wrong.