Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 15 additions & 17 deletions src/librustdoc/html/render/print_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -946,24 +946,22 @@ fn item_trait(cx: &Context<'_>, it: &clean::Item, t: &clean::Trait) -> impl fmt:

let mut extern_crates = FxIndexSet::default();

if !t.is_dyn_compatible(cx.tcx()) {
write!(
w,
"{}",
write_section_heading(
"Dyn Compatibility",
"dyn-compatibility",
None,
format!(
"<div class=\"dyn-compatibility-info\"><p>This trait is <b>not</b> \
<a href=\"{base}/reference/items/traits.html#dyn-compatibility\">dyn compatible</a>.</p>\
<p><i>In older versions of Rust, dyn compatibility was called \"object safety\", \
so this trait is not object safe.</i></p></div>",
base = crate::clean::utils::DOC_RUST_LANG_ORG_VERSION
),
write!(
w,
"{}",
write_section_heading(
"Dyn Compatibility",
"dyn-compatibility",
None,
format!(
"<div class=\"dyn-compatibility-info\"><p>This trait {} \
<a href=\"{base}/reference/items/traits.html#dyn-compatibility\">dyn compatible</a>.</p>\
<p><i>In older versions of Rust, dyn compatibility was called \"object safety\".</i></p></div>",
if t.is_dyn_compatible(cx.tcx()) { "<b>is</b>" } else { "is <b>not</b>" },
base = crate::clean::utils::DOC_RUST_LANG_ORG_VERSION
),
)?;
}
),
)?;

if let Some(implementors) = cx.shared.cache.implementors.get(&it.item_id.expect_def_id()) {
// The DefId is for the first Type found with that name. The bool is
Expand Down
4 changes: 2 additions & 2 deletions tests/rustdoc-html/dyn-compatibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ pub trait DynIncompatible2<T> {
}

//@ has 'foo/trait.DynCompatible.html'
//@ !has - '//*[@class="dyn-compatibility-info"]' ''
//@ !has - '//*[@id="dyn-compatibility"]' ''
//@ has - '//*[@class="dyn-compatibility-info"]' 'This trait is dyn compatible.'
//@ has - '//*[@id="dyn-compatibility"]' 'Dyn Compatibility'
pub trait DynCompatible {
fn foo(&self);
}
Expand Down
Loading