diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs
index 9d8ee52a3faf..944cf0885124 100644
--- a/src/librustdoc/html/highlight.rs
+++ b/src/librustdoc/html/highlight.rs
@@ -291,8 +291,8 @@ impl Class {
match (self, other) {
(Self::Self_(_), Self::Self_(_))
| (Self::Macro(_), Self::Macro(_))
- | (Self::Ident(_), Self::Ident(_))
- | (Self::Decoration(_), Self::Decoration(_)) => true,
+ | (Self::Ident(_), Self::Ident(_)) => true,
+ (Self::Decoration(c1), Self::Decoration(c2)) => c1 == c2,
(x, y) => x == y,
}
}