rustdoc: cleaner errors on disambiguator/namespace mismatches
This commit is contained in:
parent
267cf8d3b2
commit
3686e59913
@ -1996,12 +1996,23 @@ fn resolution_failure(
|
|||||||
&diag_info,
|
&diag_info,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if let Some(disambiguator) = disambiguator
|
||||||
|
&& !matches!(disambiguator, Disambiguator::Namespace(..))
|
||||||
|
{
|
||||||
|
format!(
|
||||||
|
"this link resolves to {}, which is not {} {}",
|
||||||
|
item(res),
|
||||||
|
disambiguator.article(),
|
||||||
|
disambiguator.descr()
|
||||||
|
)
|
||||||
|
} else {
|
||||||
format!(
|
format!(
|
||||||
"this link resolves to {}, which is not in the {} namespace",
|
"this link resolves to {}, which is not in the {} namespace",
|
||||||
item(res),
|
item(res),
|
||||||
expected_ns.descr()
|
expected_ns.descr()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
if let Some(span) = sp {
|
if let Some(span) = sp {
|
||||||
diag.span_label(span, note);
|
diag.span_label(span, note);
|
||||||
|
@ -74,7 +74,7 @@ error: unresolved link to `m`
|
|||||||
--> $DIR/disambiguator-mismatch.rs:52:14
|
--> $DIR/disambiguator-mismatch.rs:52:14
|
||||||
|
|
|
|
||||||
LL | /// Link to [m()]
|
LL | /// Link to [m()]
|
||||||
| ^^^ this link resolves to the macro `m`, which is not in the value namespace
|
| ^^^ this link resolves to the macro `m`, which is not a function
|
||||||
|
|
|
|
||||||
help: to link to the macro, add an exclamation mark
|
help: to link to the macro, add an exclamation mark
|
||||||
|
|
|
|
||||||
@ -142,7 +142,7 @@ error: unresolved link to `std`
|
|||||||
--> $DIR/disambiguator-mismatch.rs:83:14
|
--> $DIR/disambiguator-mismatch.rs:83:14
|
||||||
|
|
|
|
||||||
LL | /// Link to [fn@std]
|
LL | /// Link to [fn@std]
|
||||||
| ^^^^^^ this link resolves to the crate `std`, which is not in the value namespace
|
| ^^^^^^ this link resolves to the crate `std`, which is not a function
|
||||||
|
|
|
|
||||||
help: to link to the crate, prefix with `mod@`
|
help: to link to the crate, prefix with `mod@`
|
||||||
|
|
|
|
||||||
@ -164,7 +164,7 @@ error: unresolved link to `S::A`
|
|||||||
--> $DIR/disambiguator-mismatch.rs:93:14
|
--> $DIR/disambiguator-mismatch.rs:93:14
|
||||||
|
|
|
|
||||||
LL | /// Link to [field@S::A]
|
LL | /// Link to [field@S::A]
|
||||||
| ^^^^^^^^^^ this link resolves to the variant `A`, which is not in the value namespace
|
| ^^^^^^^^^^ this link resolves to the variant `A`, which is not a field
|
||||||
|
|
|
|
||||||
help: to link to the variant, prefix with `variant@`
|
help: to link to the variant, prefix with `variant@`
|
||||||
|
|
|
|
||||||
|
@ -98,7 +98,7 @@ fn g() {}
|
|||||||
/// [m()]
|
/// [m()]
|
||||||
//~^ ERROR unresolved link
|
//~^ ERROR unresolved link
|
||||||
//~| HELP to link to the macro
|
//~| HELP to link to the macro
|
||||||
//~| NOTE not in the value namespace
|
//~| NOTE not a function
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! m {
|
macro_rules! m {
|
||||||
() => {};
|
() => {};
|
||||||
|
@ -104,7 +104,7 @@ error: unresolved link to `S`
|
|||||||
--> $DIR/errors.rs:68:6
|
--> $DIR/errors.rs:68:6
|
||||||
|
|
|
|
||||||
LL | /// [S!]
|
LL | /// [S!]
|
||||||
| ^^ this link resolves to the struct `S`, which is not in the macro namespace
|
| ^^ this link resolves to the struct `S`, which is not a macro
|
||||||
|
|
|
|
||||||
help: to link to the struct, prefix with `struct@`
|
help: to link to the struct, prefix with `struct@`
|
||||||
|
|
|
|
||||||
@ -158,7 +158,7 @@ error: unresolved link to `m`
|
|||||||
--> $DIR/errors.rs:98:6
|
--> $DIR/errors.rs:98:6
|
||||||
|
|
|
|
||||||
LL | /// [m()]
|
LL | /// [m()]
|
||||||
| ^^^ this link resolves to the macro `m`, which is not in the value namespace
|
| ^^^ this link resolves to the macro `m`, which is not a function
|
||||||
|
|
|
|
||||||
help: to link to the macro, add an exclamation mark
|
help: to link to the macro, add an exclamation mark
|
||||||
|
|
|
|
||||||
|
@ -2,7 +2,7 @@ error: unresolved link to `Clone`
|
|||||||
--> $DIR/issue-110495-suffix-with-space.rs:3:6
|
--> $DIR/issue-110495-suffix-with-space.rs:3:6
|
||||||
|
|
|
|
||||||
LL | //! [Clone ()].
|
LL | //! [Clone ()].
|
||||||
| ^^^^^^^^ this link resolves to the trait `Clone`, which is not in the value namespace
|
| ^^^^^^^^ this link resolves to the trait `Clone`, which is not a function
|
||||||
|
|
|
|
||||||
note: the lint level is defined here
|
note: the lint level is defined here
|
||||||
--> $DIR/issue-110495-suffix-with-space.rs:2:9
|
--> $DIR/issue-110495-suffix-with-space.rs:2:9
|
||||||
@ -31,7 +31,7 @@ error: unresolved link to `Clone`
|
|||||||
--> $DIR/issue-110495-suffix-with-space.rs:5:7
|
--> $DIR/issue-110495-suffix-with-space.rs:5:7
|
||||||
|
|
|
|
||||||
LL | //! [`Clone ()`].
|
LL | //! [`Clone ()`].
|
||||||
| ^^^^^^^^ this link resolves to the trait `Clone`, which is not in the value namespace
|
| ^^^^^^^^ this link resolves to the trait `Clone`, which is not a function
|
||||||
|
|
|
|
||||||
help: to link to the trait, prefix with `trait@`
|
help: to link to the trait, prefix with `trait@`
|
||||||
|
|
|
|
||||||
|
@ -40,7 +40,7 @@ error: unresolved link to `Clone`
|
|||||||
--> $DIR/weird-syntax.rs:27:9
|
--> $DIR/weird-syntax.rs:27:9
|
||||||
|
|
|
|
||||||
LL | /// [ `Clone ()` ]
|
LL | /// [ `Clone ()` ]
|
||||||
| ^^^^^^^^ this link resolves to the trait `Clone`, which is not in the value namespace
|
| ^^^^^^^^ this link resolves to the trait `Clone`, which is not a function
|
||||||
|
|
|
|
||||||
help: to link to the trait, prefix with `trait@`
|
help: to link to the trait, prefix with `trait@`
|
||||||
|
|
|
|
||||||
@ -52,7 +52,7 @@ error: unresolved link to `Clone`
|
|||||||
--> $DIR/weird-syntax.rs:30:7
|
--> $DIR/weird-syntax.rs:30:7
|
||||||
|
|
|
|
||||||
LL | /// [`Clone ()` ]
|
LL | /// [`Clone ()` ]
|
||||||
| ^^^^^^^^ this link resolves to the trait `Clone`, which is not in the value namespace
|
| ^^^^^^^^ this link resolves to the trait `Clone`, which is not a function
|
||||||
|
|
|
|
||||||
help: to link to the trait, prefix with `trait@`
|
help: to link to the trait, prefix with `trait@`
|
||||||
|
|
|
|
||||||
@ -64,7 +64,7 @@ error: unresolved link to `Clone`
|
|||||||
--> $DIR/weird-syntax.rs:33:9
|
--> $DIR/weird-syntax.rs:33:9
|
||||||
|
|
|
|
||||||
LL | /// [ `Clone ()`]
|
LL | /// [ `Clone ()`]
|
||||||
| ^^^^^^^^ this link resolves to the trait `Clone`, which is not in the value namespace
|
| ^^^^^^^^ this link resolves to the trait `Clone`, which is not a function
|
||||||
|
|
|
|
||||||
help: to link to the trait, prefix with `trait@`
|
help: to link to the trait, prefix with `trait@`
|
||||||
|
|
|
|
||||||
@ -76,7 +76,7 @@ error: unresolved link to `Clone`
|
|||||||
--> $DIR/weird-syntax.rs:36:9
|
--> $DIR/weird-syntax.rs:36:9
|
||||||
|
|
|
|
||||||
LL | /// [```Clone ()```]
|
LL | /// [```Clone ()```]
|
||||||
| ^^^^^^^^ this link resolves to the trait `Clone`, which is not in the value namespace
|
| ^^^^^^^^ this link resolves to the trait `Clone`, which is not a function
|
||||||
|
|
|
|
||||||
help: to link to the trait, prefix with `trait@`
|
help: to link to the trait, prefix with `trait@`
|
||||||
|
|
|
|
||||||
@ -88,7 +88,7 @@ error: unresolved link to `Clone`
|
|||||||
--> $DIR/weird-syntax.rs:42:13
|
--> $DIR/weird-syntax.rs:42:13
|
||||||
|
|
|
|
||||||
LL | /// [ ``` Clone () ``` ]
|
LL | /// [ ``` Clone () ``` ]
|
||||||
| ^^^^^^^^ this link resolves to the trait `Clone`, which is not in the value namespace
|
| ^^^^^^^^ this link resolves to the trait `Clone`, which is not a function
|
||||||
|
|
|
|
||||||
help: to link to the trait, prefix with `trait@`
|
help: to link to the trait, prefix with `trait@`
|
||||||
|
|
|
|
||||||
@ -122,7 +122,7 @@ error: unresolved link to `Clone`
|
|||||||
--> $DIR/weird-syntax.rs:74:9
|
--> $DIR/weird-syntax.rs:74:9
|
||||||
|
|
|
|
||||||
LL | /// [x][Clone()]
|
LL | /// [x][Clone()]
|
||||||
| ^^^^^^^ this link resolves to the trait `Clone`, which is not in the value namespace
|
| ^^^^^^^ this link resolves to the trait `Clone`, which is not a function
|
||||||
|
|
|
|
||||||
help: to link to the trait, prefix with `trait@`
|
help: to link to the trait, prefix with `trait@`
|
||||||
|
|
|
|
||||||
@ -134,7 +134,7 @@ error: unresolved link to `Clone`
|
|||||||
--> $DIR/weird-syntax.rs:77:9
|
--> $DIR/weird-syntax.rs:77:9
|
||||||
|
|
|
|
||||||
LL | /// [x][Clone ()]
|
LL | /// [x][Clone ()]
|
||||||
| ^^^^^^^^^ this link resolves to the trait `Clone`, which is not in the value namespace
|
| ^^^^^^^^^ this link resolves to the trait `Clone`, which is not a function
|
||||||
|
|
|
|
||||||
help: to link to the trait, prefix with `trait@`
|
help: to link to the trait, prefix with `trait@`
|
||||||
|
|
|
|
||||||
@ -176,7 +176,7 @@ error: unresolved link to `Clone`
|
|||||||
--> $DIR/weird-syntax.rs:97:9
|
--> $DIR/weird-syntax.rs:97:9
|
||||||
|
|
|
|
||||||
LL | /// [w](Clone\(\))
|
LL | /// [w](Clone\(\))
|
||||||
| ^^^^^^^^^ this link resolves to the trait `Clone`, which is not in the value namespace
|
| ^^^^^^^^^ this link resolves to the trait `Clone`, which is not a function
|
||||||
|
|
|
|
||||||
help: to link to the trait, prefix with `trait@`
|
help: to link to the trait, prefix with `trait@`
|
||||||
|
|
|
|
||||||
@ -188,7 +188,7 @@ error: unresolved link to `Clone`
|
|||||||
--> $DIR/weird-syntax.rs:103:9
|
--> $DIR/weird-syntax.rs:103:9
|
||||||
|
|
|
|
||||||
LL | /// [w](Clone())
|
LL | /// [w](Clone())
|
||||||
| ^^^^^^^ this link resolves to the trait `Clone`, which is not in the value namespace
|
| ^^^^^^^ this link resolves to the trait `Clone`, which is not a function
|
||||||
|
|
|
|
||||||
help: to link to the trait, prefix with `trait@`
|
help: to link to the trait, prefix with `trait@`
|
||||||
|
|
|
|
||||||
@ -256,7 +256,7 @@ error: unresolved link to `Clone`
|
|||||||
--> $DIR/weird-syntax.rs:132:9
|
--> $DIR/weird-syntax.rs:132:9
|
||||||
|
|
|
|
||||||
LL | /// The [cln][] link here will produce a plain text suggestion
|
LL | /// The [cln][] link here will produce a plain text suggestion
|
||||||
| ^^^^^ this link resolves to the trait `Clone`, which is not in the value namespace
|
| ^^^^^ this link resolves to the trait `Clone`, which is not a function
|
||||||
|
|
|
|
||||||
= help: to link to the trait, prefix with `trait@`: trait@Clone
|
= help: to link to the trait, prefix with `trait@`: trait@Clone
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user