Rollup merge of #75079 - jyn514:disambiguator, r=Manishearth
Disallow linking to items with a mismatched disambiguator Closes https://github.com/rust-lang/rust/issues/74851 r? @Manishearth
This commit is contained in:
commit
5b1ed09df0
6 changed files with 329 additions and 49 deletions
68
src/test/rustdoc-ui/intra-links-disambiguator-mismatch.rs
Normal file
68
src/test/rustdoc-ui/intra-links-disambiguator-mismatch.rs
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
#![deny(broken_intra_doc_links)]
|
||||
//~^ NOTE lint level is defined
|
||||
pub enum S {}
|
||||
|
||||
macro_rules! m {
|
||||
() => {};
|
||||
}
|
||||
|
||||
static s: usize = 0;
|
||||
const c: usize = 0;
|
||||
|
||||
trait T {}
|
||||
|
||||
/// Link to [struct@S]
|
||||
//~^ ERROR incompatible link kind for `S`
|
||||
//~| NOTE this link resolved
|
||||
//~| HELP use its disambiguator
|
||||
|
||||
/// Link to [mod@S]
|
||||
//~^ ERROR incompatible link kind for `S`
|
||||
//~| NOTE this link resolved
|
||||
//~| HELP use its disambiguator
|
||||
|
||||
/// Link to [union@S]
|
||||
//~^ ERROR incompatible link kind for `S`
|
||||
//~| NOTE this link resolved
|
||||
//~| HELP use its disambiguator
|
||||
|
||||
/// Link to [trait@S]
|
||||
//~^ ERROR incompatible link kind for `S`
|
||||
//~| NOTE this link resolved
|
||||
//~| HELP use its disambiguator
|
||||
|
||||
/// Link to [struct@T]
|
||||
//~^ ERROR incompatible link kind for `T`
|
||||
//~| NOTE this link resolved
|
||||
//~| HELP use its disambiguator
|
||||
|
||||
/// Link to [derive@m]
|
||||
//~^ ERROR incompatible link kind for `m`
|
||||
//~| NOTE this link resolved
|
||||
//~| HELP use its disambiguator
|
||||
|
||||
/// Link to [const@s]
|
||||
//~^ ERROR incompatible link kind for `s`
|
||||
//~| NOTE this link resolved
|
||||
//~| HELP use its disambiguator
|
||||
|
||||
/// Link to [static@c]
|
||||
//~^ ERROR incompatible link kind for `c`
|
||||
//~| NOTE this link resolved
|
||||
//~| HELP use its disambiguator
|
||||
|
||||
/// Link to [fn@c]
|
||||
//~^ ERROR incompatible link kind for `c`
|
||||
//~| NOTE this link resolved
|
||||
//~| HELP use its disambiguator
|
||||
|
||||
/// Link to [c()]
|
||||
//~^ ERROR incompatible link kind for `c`
|
||||
//~| NOTE this link resolved
|
||||
//~| HELP use its disambiguator
|
||||
|
||||
/// Link to [const@f]
|
||||
//~^ ERROR incompatible link kind for `f`
|
||||
//~| NOTE this link resolved
|
||||
//~| HELP use its disambiguator
|
||||
pub fn f() {}
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
error: incompatible link kind for `S`
|
||||
--> $DIR/intra-links-disambiguator-mismatch.rs:14:14
|
||||
|
|
||||
LL | /// Link to [struct@S]
|
||||
| ^^^^^^^^ help: to link to the enum, use its disambiguator: `enum@S`
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/intra-links-disambiguator-mismatch.rs:1:9
|
||||
|
|
||||
LL | #![deny(broken_intra_doc_links)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: this link resolved to an enum, which is not a struct
|
||||
|
||||
error: incompatible link kind for `S`
|
||||
--> $DIR/intra-links-disambiguator-mismatch.rs:19:14
|
||||
|
|
||||
LL | /// Link to [mod@S]
|
||||
| ^^^^^ help: to link to the enum, use its disambiguator: `enum@S`
|
||||
|
|
||||
= note: this link resolved to an enum, which is not a module
|
||||
|
||||
error: incompatible link kind for `S`
|
||||
--> $DIR/intra-links-disambiguator-mismatch.rs:24:14
|
||||
|
|
||||
LL | /// Link to [union@S]
|
||||
| ^^^^^^^ help: to link to the enum, use its disambiguator: `enum@S`
|
||||
|
|
||||
= note: this link resolved to an enum, which is not a union
|
||||
|
||||
error: incompatible link kind for `S`
|
||||
--> $DIR/intra-links-disambiguator-mismatch.rs:29:14
|
||||
|
|
||||
LL | /// Link to [trait@S]
|
||||
| ^^^^^^^ help: to link to the enum, use its disambiguator: `enum@S`
|
||||
|
|
||||
= note: this link resolved to an enum, which is not a trait
|
||||
|
||||
error: incompatible link kind for `T`
|
||||
--> $DIR/intra-links-disambiguator-mismatch.rs:34:14
|
||||
|
|
||||
LL | /// Link to [struct@T]
|
||||
| ^^^^^^^^ help: to link to the trait, use its disambiguator: `trait@T`
|
||||
|
|
||||
= note: this link resolved to a trait, which is not a struct
|
||||
|
||||
error: incompatible link kind for `m`
|
||||
--> $DIR/intra-links-disambiguator-mismatch.rs:39:14
|
||||
|
|
||||
LL | /// Link to [derive@m]
|
||||
| ^^^^^^^^ help: to link to the macro, use its disambiguator: `m!`
|
||||
|
|
||||
= note: this link resolved to a macro, which is not a derive macro
|
||||
|
||||
error: incompatible link kind for `s`
|
||||
--> $DIR/intra-links-disambiguator-mismatch.rs:44:14
|
||||
|
|
||||
LL | /// Link to [const@s]
|
||||
| ^^^^^^^ help: to link to the static, use its disambiguator: `static@s`
|
||||
|
|
||||
= note: this link resolved to a static, which is not a constant
|
||||
|
||||
error: incompatible link kind for `c`
|
||||
--> $DIR/intra-links-disambiguator-mismatch.rs:49:14
|
||||
|
|
||||
LL | /// Link to [static@c]
|
||||
| ^^^^^^^^ help: to link to the constant, use its disambiguator: `const@c`
|
||||
|
|
||||
= note: this link resolved to a constant, which is not a static
|
||||
|
||||
error: incompatible link kind for `c`
|
||||
--> $DIR/intra-links-disambiguator-mismatch.rs:54:14
|
||||
|
|
||||
LL | /// Link to [fn@c]
|
||||
| ^^^^ help: to link to the constant, use its disambiguator: `const@c`
|
||||
|
|
||||
= note: this link resolved to a constant, which is not a function
|
||||
|
||||
error: incompatible link kind for `c`
|
||||
--> $DIR/intra-links-disambiguator-mismatch.rs:59:14
|
||||
|
|
||||
LL | /// Link to [c()]
|
||||
| ^^^ help: to link to the constant, use its disambiguator: `const@c`
|
||||
|
|
||||
= note: this link resolved to a constant, which is not a function
|
||||
|
||||
error: incompatible link kind for `f`
|
||||
--> $DIR/intra-links-disambiguator-mismatch.rs:64:14
|
||||
|
|
||||
LL | /// Link to [const@f]
|
||||
| ^^^^^^^ help: to link to the function, use its disambiguator: `f()`
|
||||
|
|
||||
= note: this link resolved to a function, which is not a constant
|
||||
|
||||
error: aborting due to 11 previous errors
|
||||
|
||||
12
src/test/rustdoc/intra-link-trait-item.rs
Normal file
12
src/test/rustdoc/intra-link-trait-item.rs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// ignore-tidy-linelength
|
||||
#![deny(broken_intra_doc_links)]
|
||||
|
||||
/// Link to [S::assoc_fn()]
|
||||
/// Link to [Default::default()]
|
||||
// @has intra_link_trait_item/struct.S.html '//*[@href="../intra_link_trait_item/struct.S.html#method.assoc_fn"]' 'S::assoc_fn()'
|
||||
// @has - '//*[@href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html#tymethod.default"]' 'Default::default()'
|
||||
pub struct S;
|
||||
|
||||
impl S {
|
||||
pub fn assoc_fn() {}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue