Skip to content

Commit 0c736e9

Browse files
author
Tor Hovland
committed
Add stability tags to ImportItem.
1 parent 6765010 commit 0c736e9

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

src/librustdoc/html/render/print_item.rs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,11 +282,29 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
282282
}
283283

284284
clean::ImportItem(ref import) => {
285+
let (stab, stab_tags) = if let Some(def_id) = import.source.did {
286+
// Just need an item with the correct def_id
287+
let import_item = clean::Item { def_id, ..myitem.clone() };
288+
let stab = import_item.stability_class(cx.tcx());
289+
let stab_tags = Some(extra_info_tags(&import_item, item, cx.tcx()));
290+
(stab, stab_tags)
291+
} else {
292+
(None, None)
293+
};
294+
295+
let add = if stab.is_some() { " " } else { "" };
296+
285297
write!(
286298
w,
287-
"<tr><td><code>{}{}</code></td></tr>",
288-
myitem.visibility.print_with_space(myitem.def_id, cx),
289-
import.print(cx),
299+
"<tr class=\"{stab}{add}module-item\">\
300+
<td><code>{vis}{imp}</code></td>\
301+
<td class=\"docblock-short\">{stab_tags}</td>\
302+
</tr>",
303+
stab = stab.unwrap_or_default(),
304+
add = add,
305+
vis = myitem.visibility.print_with_space(myitem.def_id, cx),
306+
imp = import.print(cx),
307+
stab_tags = stab_tags.unwrap_or_default(),
290308
);
291309
}
292310

@@ -320,7 +338,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
320338
docs = MarkdownSummaryLine(&doc_value, &myitem.links(cx)).into_string(),
321339
class = myitem.type_(),
322340
add = add,
323-
stab = stab.unwrap_or_else(String::new),
341+
stab = stab.unwrap_or_default(),
324342
unsafety_flag = unsafety_flag,
325343
href = item_path(myitem.type_(), &myitem.name.unwrap().as_str()),
326344
title = [full_path(cx, myitem), myitem.type_().to_string()]

0 commit comments

Comments
 (0)