Suggest f() for functions and add a test case
This commit is contained in:
parent
fc273a035d
commit
2dad90d8b5
3 changed files with 16 additions and 2 deletions
|
@ -893,6 +893,8 @@ impl Disambiguator {
|
||||||
fn display_for(kind: DefKind, path_str: &str) -> String {
|
fn display_for(kind: DefKind, path_str: &str) -> String {
|
||||||
if kind == DefKind::Macro(MacroKind::Bang) {
|
if kind == DefKind::Macro(MacroKind::Bang) {
|
||||||
return format!("{}!", path_str);
|
return format!("{}!", path_str);
|
||||||
|
} else if kind == DefKind::Fn || kind == DefKind::AssocFn {
|
||||||
|
return format!("{}()", path_str);
|
||||||
}
|
}
|
||||||
let prefix = match kind {
|
let prefix = match kind {
|
||||||
DefKind::Struct => "struct",
|
DefKind::Struct => "struct",
|
||||||
|
@ -904,7 +906,6 @@ impl Disambiguator {
|
||||||
"const"
|
"const"
|
||||||
}
|
}
|
||||||
DefKind::Static => "static",
|
DefKind::Static => "static",
|
||||||
DefKind::Fn | DefKind::AssocFn => "fn",
|
|
||||||
DefKind::Macro(MacroKind::Derive) => "derive",
|
DefKind::Macro(MacroKind::Derive) => "derive",
|
||||||
// Now handle things that don't have a specific disambiguator
|
// Now handle things that don't have a specific disambiguator
|
||||||
_ => match kind
|
_ => match kind
|
||||||
|
|
|
@ -60,4 +60,9 @@ trait T {}
|
||||||
//~^ ERROR incompatible link kind for `c`
|
//~^ ERROR incompatible link kind for `c`
|
||||||
//~| NOTE this link resolved
|
//~| NOTE this link resolved
|
||||||
//~| HELP use its disambiguator
|
//~| 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() {}
|
pub fn f() {}
|
||||||
|
|
|
@ -83,5 +83,13 @@ LL | /// Link to [c()]
|
||||||
|
|
|
|
||||||
= note: this link resolved to a constant, which is not a function
|
= note: this link resolved to a constant, which is not a function
|
||||||
|
|
||||||
error: aborting due to 10 previous errors
|
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
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue