From 88ff75c6ccd44e6eef20157cbedfa15dc0f6a1b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20BRANSTETT?= Date: Sun, 26 Sep 2021 18:22:07 +0200 Subject: [PATCH] Fix populate of union.impls --- src/librustdoc/json/mod.rs | 2 ++ src/test/rustdoc-json/unions/impl.rs | 15 +++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 src/test/rustdoc-json/unions/impl.rs diff --git a/src/librustdoc/json/mod.rs b/src/librustdoc/json/mod.rs index 5089cc30a1e39..915a9fd2b894a 100644 --- a/src/librustdoc/json/mod.rs +++ b/src/librustdoc/json/mod.rs @@ -169,6 +169,8 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { s.impls = self.get_impls(id.expect_def_id()) } else if let types::ItemEnum::Enum(ref mut e) = new_item.inner { e.impls = self.get_impls(id.expect_def_id()) + } else if let types::ItemEnum::Union(ref mut u) = new_item.inner { + u.impls = self.get_impls(id.expect_def_id()) } let removed = self.index.borrow_mut().insert(from_item_id(id), new_item.clone()); diff --git a/src/test/rustdoc-json/unions/impl.rs b/src/test/rustdoc-json/unions/impl.rs new file mode 100644 index 0000000000000..0388b4a8c3c3b --- /dev/null +++ b/src/test/rustdoc-json/unions/impl.rs @@ -0,0 +1,15 @@ +#![no_std] + +// @has impl.json "$.index[*][?(@.name=='Ux')].visibility" \"public\" +// @has - "$.index[*][?(@.name=='Ux')].kind" \"union\" +pub union Ux { + a: u32, + b: u64 +} + +// @has - "$.index[*][?(@.name=='Num')].visibility" \"public\" +// @has - "$.index[*][?(@.name=='Num')].kind" \"trait\" +pub trait Num {} + +// @count - "$.index[*][?(@.name=='Ux')].inner.impls" 1 +impl Num for Ux {}