Skip to content

Commit

Permalink
Rollup merge of rust-lang#89276 - Urgau:fix-union-impls, r=GuillaumeG…
Browse files Browse the repository at this point in the history
…omez

Fix the population of the `union.impls` field

This pull-request fix the population of the `union.impls` field that was forgot when the `Union` type was introduce as a split from the `Struct` type rust-lang#81500.

`@rustbot` label +T-rustdoc +A-rustdoc-json
  • Loading branch information
GuillaumeGomez committed Sep 28, 2021
2 parents a5b0204 + 88ff75c commit 15b2946
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/librustdoc/json/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
15 changes: 15 additions & 0 deletions src/test/rustdoc-json/unions/impl.rs
Original file line number Diff line number Diff line change
@@ -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 {}

0 comments on commit 15b2946

Please sign in to comment.