Suggest f() for functions and add a test case

This commit is contained in:
Joshua Nelson 2020-08-05 20:46:02 -04:00
parent fc273a035d
commit 2dad90d8b5
3 changed files with 16 additions and 2 deletions

View file

@ -893,6 +893,8 @@ impl Disambiguator {
fn display_for(kind: DefKind, path_str: &str) -> String {
if kind == DefKind::Macro(MacroKind::Bang) {
return format!("{}!", path_str);
} else if kind == DefKind::Fn || kind == DefKind::AssocFn {
return format!("{}()", path_str);
}
let prefix = match kind {
DefKind::Struct => "struct",
@ -904,7 +906,6 @@ impl Disambiguator {
"const"
}
DefKind::Static => "static",
DefKind::Fn | DefKind::AssocFn => "fn",
DefKind::Macro(MacroKind::Derive) => "derive",
// Now handle things that don't have a specific disambiguator
_ => match kind

View file

@ -60,4 +60,9 @@ trait T {}
//~^ 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() {}

View file

@ -83,5 +83,13 @@ LL | /// Link to [c()]
|
= 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