diff options
| author | Tor Hovland <tor.hovland@bekk.no> | 2021-04-05 20:57:49 +0200 |
|---|---|---|
| committer | Tor Hovland <tor.hovland@bekk.no> | 2021-04-18 10:45:22 +0200 |
| commit | 0c736e92a3575927d693b839f7ab537db7d6f84e (patch) | |
| tree | e9439e2d6954431adc633a2c4d3856fdeb2e9cbd | |
| parent | 67650104959003d1a5828f8d79ad72aa08752055 (diff) | |
| download | rust-0c736e92a3575927d693b839f7ab537db7d6f84e.tar.gz rust-0c736e92a3575927d693b839f7ab537db7d6f84e.zip | |
Add stability tags to ImportItem.
| -rw-r--r-- | src/librustdoc/html/render/print_item.rs | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index 42b79503017..e2c7a244064 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -282,11 +282,29 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl } clean::ImportItem(ref import) => { + let (stab, stab_tags) = if let Some(def_id) = import.source.did { + // Just need an item with the correct def_id + let import_item = clean::Item { def_id, ..myitem.clone() }; + let stab = import_item.stability_class(cx.tcx()); + let stab_tags = Some(extra_info_tags(&import_item, item, cx.tcx())); + (stab, stab_tags) + } else { + (None, None) + }; + + let add = if stab.is_some() { " " } else { "" }; + write!( w, - "<tr><td><code>{}{}</code></td></tr>", - myitem.visibility.print_with_space(myitem.def_id, cx), - import.print(cx), + "<tr class=\"{stab}{add}module-item\">\ + <td><code>{vis}{imp}</code></td>\ + <td class=\"docblock-short\">{stab_tags}</td>\ + </tr>", + stab = stab.unwrap_or_default(), + add = add, + vis = myitem.visibility.print_with_space(myitem.def_id, cx), + imp = import.print(cx), + stab_tags = stab_tags.unwrap_or_default(), ); } @@ -320,7 +338,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl docs = MarkdownSummaryLine(&doc_value, &myitem.links(cx)).into_string(), class = myitem.type_(), add = add, - stab = stab.unwrap_or_else(String::new), + stab = stab.unwrap_or_default(), unsafety_flag = unsafety_flag, href = item_path(myitem.type_(), &myitem.name.unwrap().as_str()), title = [full_path(cx, myitem), myitem.type_().to_string()] |
