diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs
index 45e38d67c4020..336513804e1ff 100644
--- a/src/librustdoc/html/render/print_item.rs
+++ b/src/librustdoc/html/render/print_item.rs
@@ -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!(
- "
This trait is not \
- dyn compatible.
\
-
In older versions of Rust, dyn compatibility was called \"object safety\", \
- so this trait is not object safe.
",
- base = crate::clean::utils::DOC_RUST_LANG_ORG_VERSION
- ),
+ write!(
+ w,
+ "{}",
+ write_section_heading(
+ "Dyn Compatibility",
+ "dyn-compatibility",
+ None,
+ format!(
+ "This trait {} \
+ dyn compatible.
\
+
In older versions of Rust, dyn compatibility was called \"object safety\".
",
+ if t.is_dyn_compatible(cx.tcx()) { "is" } else { "is not" },
+ 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
diff --git a/tests/rustdoc-html/dyn-compatibility.rs b/tests/rustdoc-html/dyn-compatibility.rs
index 9115f93bc3bac..2d13c8a88bfdb 100644
--- a/tests/rustdoc-html/dyn-compatibility.rs
+++ b/tests/rustdoc-html/dyn-compatibility.rs
@@ -15,8 +15,8 @@ pub trait DynIncompatible2 {
}
//@ 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);
}