diff options
| author | Alexis (Poliorcetics) Bourget <ab_github@poliorcetiq.eu> | 2023-07-01 19:13:00 +0200 |
|---|---|---|
| committer | Alexis (Poliorcetics) Bourget <ab_github@poliorcetiq.eu> | 2023-10-29 22:57:45 +0100 |
| commit | 51e22be682e4ed5864e36400cbbc10836ee52c7e (patch) | |
| tree | a0a640435e4c141a8cc6e34eb051cba8262c4e5f /src/librustdoc/html/render | |
| parent | ec2b311914a4880235862f3cd65fe24e92e6d3a5 (diff) | |
| download | rust-51e22be682e4ed5864e36400cbbc10836ee52c7e.tar.gz rust-51e22be682e4ed5864e36400cbbc10836ee52c7e.zip | |
feat: render Object Safety informations non-object safe traits
Diffstat (limited to 'src/librustdoc/html/render')
| -rw-r--r-- | src/librustdoc/html/render/print_item.rs | 14 | ||||
| -rw-r--r-- | src/librustdoc/html/render/sidebar.rs | 8 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index fdf45569061..4d518a3e20b 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -959,6 +959,20 @@ fn item_trait(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean: let cloned_shared = Rc::clone(&cx.shared); let cache = &cloned_shared.cache; let mut extern_crates = FxHashSet::default(); + + if !t.is_object_safe(cx.tcx()) { + write_small_section_header( + w, + "object-safety", + "Object Safety", + &format!("<div class=\"object-safety-info\">This trait is <b>not</b> \ + <a href=\"{base}/reference/items/traits.html#object-safety\">\ + object safe</a>.</div>", + base = crate::clean::utils::DOC_RUST_LANG_ORG_CHANNEL + ), + ); + } + if let Some(implementors) = cache.implementors.get(&it.item_id.expect_def_id()) { // The DefId is for the first Type found with that name. The bool is // if any Types with the same name but different DefId have been found. diff --git a/src/librustdoc/html/render/sidebar.rs b/src/librustdoc/html/render/sidebar.rs index 4e8d88c55b6..ba4aaaff5a7 100644 --- a/src/librustdoc/html/render/sidebar.rs +++ b/src/librustdoc/html/render/sidebar.rs @@ -218,6 +218,14 @@ fn sidebar_trait<'a>( .map(|(id, title, items)| LinkBlock::new(Link::new(id, title), "", items)) .collect(); sidebar_assoc_items(cx, it, &mut blocks); + + if !t.is_object_safe(cx.tcx()) { + blocks.push(LinkBlock::forced( + Link::new("object-safety", "Object Safety"), + "object-safety-note", + )); + } + blocks.push(LinkBlock::forced(Link::new("implementors", "Implementors"), "impl")); if t.is_auto(cx.tcx()) { blocks.push(LinkBlock::forced( |
