@@ -4,6 +4,7 @@ use rustc_data_structures::fx::FxHashMap;
44use rustc_hir as hir;
55use rustc_hir:: def:: CtorKind ;
66use rustc_hir:: def_id:: DefId ;
7+ use rustc_middle:: dep_graph:: DepContext ;
78use rustc_middle:: middle:: stability;
89use rustc_middle:: ty:: TyCtxt ;
910use rustc_span:: hygiene:: MacroKind ;
@@ -282,11 +283,40 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
282283 }
283284
284285 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+
285309 write ! (
286310 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( ) ,
290320 ) ;
291321 }
292322
@@ -320,7 +350,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
320350 docs = MarkdownSummaryLine ( & doc_value, & myitem. links( cx) ) . into_string( ) ,
321351 class = myitem. type_( ) ,
322352 add = add,
323- stab = stab. unwrap_or_else ( String :: new ) ,
353+ stab = stab. unwrap_or_default ( ) ,
324354 unsafety_flag = unsafety_flag,
325355 href = item_path( myitem. type_( ) , & myitem. name. unwrap( ) . as_str( ) ) ,
326356 title = [ full_path( cx, myitem) , myitem. type_( ) . to_string( ) ]
0 commit comments