Skip to content

Commit 98cba84

Browse files
committed
rustdoc: Use own logic to print #[repr(..)] attributes in JSON output.
1 parent f9e0239 commit 98cba84

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/librustdoc/clean/types.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,15 @@ impl Item {
772772
.other_attrs
773773
.iter()
774774
.filter_map(|attr| {
775-
if keep_as_is {
775+
// We have separate pretty-printing logic for `#[repr(..)]` attributes.
776+
// For example, there are circumstances where `#[repr(transparent)]` is applied
777+
// but should not be publicly shown in rustdoc because it isn't public API.
778+
if keep_as_is
779+
&& !matches!(
780+
attr,
781+
rustc_hir::Attribute::Parsed(rustc_attr_parsing::AttributeKind::Repr(..))
782+
)
783+
{
776784
Some(rustc_hir_pretty::attribute_to_string(&tcx, attr))
777785
} else if ALLOWED_ATTRIBUTES.contains(&attr.name_or_empty()) {
778786
Some(
@@ -786,8 +794,7 @@ impl Item {
786794
}
787795
})
788796
.collect();
789-
if !keep_as_is
790-
&& let Some(def_id) = self.def_id()
797+
if let Some(def_id) = self.def_id()
791798
&& let ItemType::Struct | ItemType::Enum | ItemType::Union = self.type_()
792799
{
793800
let adt = tcx.adt_def(def_id);

0 commit comments

Comments
 (0)