Skip to content

Commit d578819

Browse files
committed
rustdoc JSON: Don't apply #[repr] privacy heuristics
1 parent c79bbfa commit d578819

File tree

4 files changed

+12
-53
lines changed

4 files changed

+12
-53
lines changed

src/librustdoc/clean/types.rs

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -772,20 +772,11 @@ impl Item {
772772
.filter_map(|attr| {
773773
if is_json {
774774
match attr {
775-
hir::Attribute::Parsed(AttributeKind::Deprecation { .. }) => {
776-
// rustdoc-json stores this in `Item::deprecation`, so we
777-
// don't want it it `Item::attrs`.
778-
None
779-
}
780-
rustc_hir::Attribute::Parsed(rustc_attr_parsing::AttributeKind::Repr(
781-
..,
782-
)) => {
783-
// We have separate pretty-printing logic for `#[repr(..)]` attributes.
784-
// For example, there are circumstances where `#[repr(transparent)]`
785-
// is applied but should not be publicly shown in rustdoc
786-
// because it isn't public API.
787-
None
788-
}
775+
// rustdoc-json stores this in `Item::deprecation`, so we
776+
// don't want it it `Item::attrs`.
777+
hir::Attribute::Parsed(AttributeKind::Deprecation { .. }) => None,
778+
// We have separate pretty-printing logic for `#[repr(..)]` attributes.
779+
hir::Attribute::Parsed(AttributeKind::Repr(..)) => None,
789780
_ => Some({
790781
let mut s = rustc_hir_pretty::attribute_to_string(&tcx, attr);
791782
assert_eq!(s.pop(), Some('\n'));
@@ -818,7 +809,8 @@ impl Item {
818809
if repr.transparent() {
819810
// Render `repr(transparent)` iff the non-1-ZST field is public or at least one
820811
// field is public in case all fields are 1-ZST fields.
821-
let render_transparent = cache.document_private
812+
let render_transparent = is_json
813+
|| cache.document_private
822814
|| adt
823815
.all_fields()
824816
.find(|field| {

src/rustdoc-json-types/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub type FxHashMap<K, V> = HashMap<K, V>; // re-export for use in src/librustdoc
3030
/// This integer is incremented with every breaking change to the API,
3131
/// and is returned along with the JSON blob as [`Crate::format_version`].
3232
/// Consuming code should assert that this value matches the format version(s) that it supports.
33-
pub const FORMAT_VERSION: u32 = 45;
33+
pub const FORMAT_VERSION: u32 = 46;
3434

3535
/// The root of the emitted JSON blob.
3636
///

tests/rustdoc-json/attrs/repr_combination.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,7 @@ pub enum AlignedExplicitRepr {
7777
pub enum ReorderedAlignedExplicitRepr {
7878
First,
7979
}
80+
81+
//@ is "$.index[?(@.name=='Transparent')].attrs" '["#[repr(transparent)]"]'
82+
#[repr(transparent)]
83+
pub struct Transparent(i64);

tests/rustdoc-json/attrs/repr_transparent.rs

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)