@@ -4,6 +4,7 @@ use rustc_data_structures::fx::FxHashMap;
4
4
use rustc_hir as hir;
5
5
use rustc_hir:: def:: CtorKind ;
6
6
use rustc_hir:: def_id:: DefId ;
7
+ use rustc_middle:: dep_graph:: DepContext ;
7
8
use rustc_middle:: middle:: stability;
8
9
use rustc_middle:: ty:: TyCtxt ;
9
10
use rustc_span:: hygiene:: MacroKind ;
@@ -282,11 +283,40 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
282
283
}
283
284
284
285
clean:: ImportItem ( ref import) => {
286
+ let ( stab, stab_tags) = if let Some ( import_def_id) = import. source . did {
287
+ let import_attrs = Box :: new ( clean:: Attributes :: from_ast (
288
+ cx. tcx ( ) . sess ( ) . diagnostic ( ) ,
289
+ cx. tcx ( ) . get_attrs ( import_def_id) ,
290
+ None ,
291
+ ) ) ;
292
+
293
+ // Just need an item with the correct def_id and attrs
294
+ let import_item = clean:: Item {
295
+ def_id : import_def_id,
296
+ attrs : import_attrs,
297
+ ..myitem. clone ( )
298
+ } ;
299
+
300
+ let stab = import_item. stability_class ( cx. tcx ( ) ) ;
301
+ let stab_tags = Some ( extra_info_tags ( & import_item, item, cx. tcx ( ) ) ) ;
302
+ ( stab, stab_tags)
303
+ } else {
304
+ ( None , None )
305
+ } ;
306
+
307
+ let add = if stab. is_some ( ) { " " } else { "" } ;
308
+
285
309
write ! (
286
310
w,
287
- "<tr><td><code>{}{}</code></td></tr>" ,
288
- myitem. visibility. print_with_space( myitem. def_id, cx) ,
289
- import. print( cx) ,
311
+ "<tr class=\" {stab}{add}import-item\" >\
312
+ <td><code>{vis}{imp}</code></td>\
313
+ <td class=\" docblock-short\" >{stab_tags}</td>\
314
+ </tr>",
315
+ stab = stab. unwrap_or_default( ) ,
316
+ add = add,
317
+ vis = myitem. visibility. print_with_space( myitem. def_id, cx) ,
318
+ imp = import. print( cx) ,
319
+ stab_tags = stab_tags. unwrap_or_default( ) ,
290
320
) ;
291
321
}
292
322
@@ -320,7 +350,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
320
350
docs = MarkdownSummaryLine ( & doc_value, & myitem. links( cx) ) . into_string( ) ,
321
351
class = myitem. type_( ) ,
322
352
add = add,
323
- stab = stab. unwrap_or_else ( String :: new ) ,
353
+ stab = stab. unwrap_or_default ( ) ,
324
354
unsafety_flag = unsafety_flag,
325
355
href = item_path( myitem. type_( ) , & myitem. name. unwrap( ) . as_str( ) ) ,
326
356
title = [ full_path( cx, myitem) , myitem. type_( ) . to_string( ) ]
0 commit comments