@@ -884,9 +884,9 @@ fn ambiguity_error(cx: &DocContext, attrs: &Attributes,
884
884
& format ! ( "`{}` is both {} {} and {} {}" ,
885
885
path_str, article1, kind1,
886
886
article2, kind2) )
887
- . help ( & format ! ( "try `{0 }` if you want to select the {1 }, \
888
- or `{2}@{3 }` if you want to \
889
- select the {2 }",
887
+ . help ( & format ! ( "try `{}` if you want to select the {}, \
888
+ or `{}` if you want to \
889
+ select the {}",
890
890
disambig1, kind1, disambig2,
891
891
kind2) )
892
892
. emit ( ) ;
@@ -920,8 +920,8 @@ impl Clean<Attributes> for [ast::Attribute] {
920
920
link. trim_left_matches ( prefix)
921
921
} else if let Some ( prefix) =
922
922
[ "const@" , "static@" ,
923
- "value@" , "function@" ] . iter ( )
924
- . find ( |p| link. starts_with ( * * p) ) {
923
+ "value@" , "function@" , "mod@" , "fn@" , "module@" ]
924
+ . iter ( ) . find ( |p| link. starts_with ( * * p) ) {
925
925
kind = PathKind :: Value ;
926
926
link. trim_left_matches ( prefix)
927
927
} else if link. ends_with ( "()" ) {
@@ -1007,28 +1007,44 @@ impl Clean<Attributes> for [ast::Attribute] {
1007
1007
}
1008
1008
}
1009
1009
PathKind :: Unknown => {
1010
- // try both!
1011
- // It is imperative we search for not-a-value first
1012
- // Otherwise we will find struct ctors for when we are looking
1013
- // for structs, and the link won't work.
1014
- if let Ok ( path) = resolve ( false ) {
1010
+ // try everything!
1011
+ if let Some ( macro_def) = macro_resolve ( ) {
1012
+ if let Ok ( type_path) = resolve ( false ) {
1013
+ let ( type_kind, article, type_disambig)
1014
+ = type_ns_kind ( type_path. def , path_str) ;
1015
+ ambiguity_error ( cx, & attrs, path_str,
1016
+ article, type_kind, & type_disambig,
1017
+ "a" , "macro" , & format ! ( "macro@{}" , path_str) ) ;
1018
+ continue ;
1019
+ } else if let Ok ( value_path) = resolve ( true ) {
1020
+ let ( value_kind, value_disambig)
1021
+ = value_ns_kind ( value_path. def , path_str)
1022
+ . expect ( "struct and mod cases should have been \
1023
+ caught in previous branch") ;
1024
+ ambiguity_error ( cx, & attrs, path_str,
1025
+ "a" , value_kind, & value_disambig,
1026
+ "a" , "macro" , & format ! ( "macro@{}" , path_str) ) ;
1027
+ }
1028
+ macro_def
1029
+ } else if let Ok ( type_path) = resolve ( false ) {
1030
+ // It is imperative we search for not-a-value first
1031
+ // Otherwise we will find struct ctors for when we are looking
1032
+ // for structs, and the link won't work.
1015
1033
// if there is something in both namespaces
1016
1034
if let Ok ( value_path) = resolve ( true ) {
1017
1035
let kind = value_ns_kind ( value_path. def , path_str) ;
1018
1036
if let Some ( ( value_kind, value_disambig) ) = kind {
1019
1037
let ( type_kind, article, type_disambig)
1020
- = type_ns_kind ( path . def ) ;
1021
- ambiguity_error ( cx, & attrs,
1022
- article, type_kind, type_disambig,
1023
- "a" , value_kind, value_disambig) ;
1038
+ = type_ns_kind ( type_path . def , path_str ) ;
1039
+ ambiguity_error ( cx, & attrs, path_str ,
1040
+ article, type_kind, & type_disambig,
1041
+ "a" , value_kind, & value_disambig) ;
1024
1042
continue ;
1025
1043
}
1026
1044
}
1027
- path. def
1028
- } else if let Ok ( path) = resolve ( true ) {
1029
- path. def
1030
- } else if let Some ( def) = macro_resolve ( ) {
1031
- def
1045
+ type_path. def
1046
+ } else if let Ok ( value_path) = resolve ( true ) {
1047
+ value_path. def
1032
1048
} else {
1033
1049
// this could just be a normal link
1034
1050
continue ;
0 commit comments