feat: render Object Safety informations non-object safe traits
This commit is contained in:
parent
ec2b311914
commit
51e22be682
@ -1455,6 +1455,9 @@ pub(crate) fn is_notable_trait(&self, tcx: TyCtxt<'_>) -> bool {
|
||||
pub(crate) fn unsafety(&self, tcx: TyCtxt<'_>) -> hir::Unsafety {
|
||||
tcx.trait_def(self.def_id).unsafety
|
||||
}
|
||||
pub(crate) fn is_object_safe(&self, tcx: TyCtxt<'_>) -> bool {
|
||||
tcx.check_is_object_safe(self.def_id)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -959,6 +959,20 @@ fn trait_item(w: &mut Buffer, cx: &mut Context<'_>, m: &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.
|
||||
|
@ -218,6 +218,14 @@ fn filter_items<'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(
|
||||
|
Loading…
Reference in New Issue
Block a user