@@ -954,12 +954,20 @@ fn type_ns_kind(def: Def, path_str: &str) -> (&'static str, &'static str, String
954
954
( kind, article, format ! ( "{}@{}" , kind, path_str) )
955
955
}
956
956
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
+
957
966
fn ambiguity_error ( cx : & DocContext , attrs : & Attributes ,
958
967
path_str : & str ,
959
968
article1 : & str , kind1 : & str , disambig1 : & str ,
960
969
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) ;
963
971
cx. sess ( )
964
972
. struct_span_warn ( sp,
965
973
& format ! ( "`{}` is both {} {} and {} {}" ,
@@ -1174,8 +1182,9 @@ enum PathKind {
1174
1182
Type ,
1175
1183
}
1176
1184
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) ) ;
1179
1188
}
1180
1189
1181
1190
impl Clean < Attributes > for [ ast:: Attribute ] {
@@ -1228,7 +1237,7 @@ impl Clean<Attributes> for [ast::Attribute] {
1228
1237
if let Ok ( def) = resolve ( cx, path_str, true ) {
1229
1238
def
1230
1239
} else {
1231
- resolution_failure ( cx, path_str) ;
1240
+ resolution_failure ( cx, & attrs , path_str) ;
1232
1241
// this could just be a normal link or a broken link
1233
1242
// we could potentially check if something is
1234
1243
// "intra-doc-link-like" and warn in that case
@@ -1239,7 +1248,7 @@ impl Clean<Attributes> for [ast::Attribute] {
1239
1248
if let Ok ( def) = resolve ( cx, path_str, false ) {
1240
1249
def
1241
1250
} else {
1242
- resolution_failure ( cx, path_str) ;
1251
+ resolution_failure ( cx, & attrs , path_str) ;
1243
1252
// this could just be a normal link
1244
1253
continue ;
1245
1254
}
@@ -1284,7 +1293,7 @@ impl Clean<Attributes> for [ast::Attribute] {
1284
1293
} else if let Ok ( value_def) = resolve ( cx, path_str, true ) {
1285
1294
value_def
1286
1295
} else {
1287
- resolution_failure ( cx, path_str) ;
1296
+ resolution_failure ( cx, & attrs , path_str) ;
1288
1297
// this could just be a normal link
1289
1298
continue ;
1290
1299
}
@@ -1293,7 +1302,7 @@ impl Clean<Attributes> for [ast::Attribute] {
1293
1302
if let Some ( def) = macro_resolve ( cx, path_str) {
1294
1303
( def, None )
1295
1304
} else {
1296
- resolution_failure ( cx, path_str) ;
1305
+ resolution_failure ( cx, & attrs , path_str) ;
1297
1306
continue
1298
1307
}
1299
1308
}
0 commit comments