@@ -954,12 +954,20 @@ fn type_ns_kind(def: Def, path_str: &str) -> (&'static str, &'static str, String
954954 ( kind, article, format ! ( "{}@{}" , kind, path_str) )
955955}
956956
957+ fn span_of_attrs ( attrs : & Attributes ) -> syntax_pos:: Span {
958+ if attrs. doc_strings . is_empty ( ) {
959+ return DUMMY_SP ;
960+ }
961+ let start = attrs. doc_strings [ 0 ] . span ( ) ;
962+ let end = attrs. doc_strings . last ( ) . unwrap ( ) . span ( ) ;
963+ start. to ( end)
964+ }
965+
957966fn ambiguity_error ( cx : & DocContext , attrs : & Attributes ,
958967 path_str : & str ,
959968 article1 : & str , kind1 : & str , disambig1 : & str ,
960969 article2 : & str , kind2 : & str , disambig2 : & str ) {
961- let sp = attrs. doc_strings . first ( )
962- . map_or ( DUMMY_SP , |a| a. span ( ) ) ;
970+ let sp = span_of_attrs ( attrs) ;
963971 cx. sess ( )
964972 . struct_span_warn ( sp,
965973 & format ! ( "`{}` is both {} {} and {} {}" ,
@@ -1174,8 +1182,9 @@ enum PathKind {
11741182 Type ,
11751183}
11761184
1177- fn resolution_failure ( cx : & DocContext , path_str : & str ) {
1178- cx. sess ( ) . warn ( & format ! ( "[{}] cannot be resolved, ignoring it..." , path_str) ) ;
1185+ fn resolution_failure ( cx : & DocContext , attrs : & Attributes , path_str : & str ) {
1186+ let sp = span_of_attrs ( attrs) ;
1187+ cx. sess ( ) . span_warn ( sp, & format ! ( "[{}] cannot be resolved, ignoring it..." , path_str) ) ;
11791188}
11801189
11811190impl Clean < Attributes > for [ ast:: Attribute ] {
@@ -1228,7 +1237,7 @@ impl Clean<Attributes> for [ast::Attribute] {
12281237 if let Ok ( def) = resolve ( cx, path_str, true ) {
12291238 def
12301239 } else {
1231- resolution_failure ( cx, path_str) ;
1240+ resolution_failure ( cx, & attrs , path_str) ;
12321241 // this could just be a normal link or a broken link
12331242 // we could potentially check if something is
12341243 // "intra-doc-link-like" and warn in that case
@@ -1239,7 +1248,7 @@ impl Clean<Attributes> for [ast::Attribute] {
12391248 if let Ok ( def) = resolve ( cx, path_str, false ) {
12401249 def
12411250 } else {
1242- resolution_failure ( cx, path_str) ;
1251+ resolution_failure ( cx, & attrs , path_str) ;
12431252 // this could just be a normal link
12441253 continue ;
12451254 }
@@ -1284,7 +1293,7 @@ impl Clean<Attributes> for [ast::Attribute] {
12841293 } else if let Ok ( value_def) = resolve ( cx, path_str, true ) {
12851294 value_def
12861295 } else {
1287- resolution_failure ( cx, path_str) ;
1296+ resolution_failure ( cx, & attrs , path_str) ;
12881297 // this could just be a normal link
12891298 continue ;
12901299 }
@@ -1293,7 +1302,7 @@ impl Clean<Attributes> for [ast::Attribute] {
12931302 if let Some ( def) = macro_resolve ( cx, path_str) {
12941303 ( def, None )
12951304 } else {
1296- resolution_failure ( cx, path_str) ;
1305+ resolution_failure ( cx, & attrs , path_str) ;
12971306 continue
12981307 }
12991308 }
0 commit comments