Skip to content

Commit d0f74b6

Browse files
committed
Load struct-variant data correctly from metadata
1 parent 0e3a2c0 commit d0f74b6

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

src/librustdoc/clean/mod.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1892,18 +1892,11 @@ impl<'tcx> Clean<Item> for ty::VariantDefData<'tcx, 'static> {
18921892
Item {
18931893
source: Span::empty(),
18941894
name: Some(field.name.clean(cx)),
1895-
attrs: Vec::new(),
1895+
attrs: cx.tcx().get_attrs(field.did).clean(cx),
18961896
visibility: Some(field.vis),
1897-
// FIXME: this is not accurate, we need an id for
1898-
// the specific field but we're using the id
1899-
// for the whole variant. Thus we read the
1900-
// stability from the whole variant as well.
1901-
// Struct variants are experimental and need
1902-
// more infrastructure work before we can get
1903-
// at the needed information here.
1904-
def_id: self.did,
1905-
stability: get_stability(cx, self.did),
1906-
deprecation: get_deprecation(cx, self.did),
1897+
def_id: field.did,
1898+
stability: get_stability(cx, field.did),
1899+
deprecation: get_deprecation(cx, field.did),
19071900
inner: StructFieldItem(
19081901
TypedStructField(field.unsubst_ty().clean(cx))
19091902
)
@@ -1916,7 +1909,7 @@ impl<'tcx> Clean<Item> for ty::VariantDefData<'tcx, 'static> {
19161909
name: Some(self.name.clean(cx)),
19171910
attrs: inline::load_attrs(cx, cx.tcx(), self.did),
19181911
source: Span::empty(),
1919-
visibility: Some(hir::Public),
1912+
visibility: Some(hir::Inherited),
19201913
def_id: self.did,
19211914
inner: VariantItem(Variant { kind: kind }),
19221915
stability: get_stability(cx, self.did),

src/test/rustdoc/issue-32395.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414

1515
// @has variant_struct/enum.Foo.html
1616
// @!has - 'pub qux'
17+
// @!has - 'pub Bar'
1718
extern crate variant_struct;
1819

1920
// @has issue_32395/enum.Foo.html
2021
// @!has - 'pub qux'
22+
// @!has - 'pub Bar'
2123
pub use variant_struct::Foo;

0 commit comments

Comments
 (0)