Skip to content

Commit 8e40d93

Browse files
Filter out keyword items in rustdoc JSON output
1 parent a5c039c commit 8e40d93

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/librustdoc/json/conversions.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl JsonRenderer<'_> {
4343
let span = item.span(self.tcx);
4444
let clean::Item { name, attrs: _, kind: _, visibility, item_id, cfg: _ } = item;
4545
let inner = match *item.kind {
46-
clean::StrippedItem(_) => return None,
46+
clean::StrippedItem(_) | clean::KeywordItem(_) => return None,
4747
_ => from_clean_item(item, self.tcx),
4848
};
4949
Some(Item {
@@ -254,11 +254,8 @@ fn from_clean_item(item: clean::Item, tcx: TyCtxt<'_>) -> ItemEnum {
254254
},
255255
// FIXME: do not map to Typedef but to a custom variant
256256
AssocTypeItem(t, _) => ItemEnum::Typedef(t.into_tcx(tcx)),
257-
// `convert_item` early returns `None` for striped items
258-
StrippedItem(_) => unreachable!(),
259-
KeywordItem(_) => {
260-
panic!("{:?} is not supported for JSON output", item)
261-
}
257+
// `convert_item` early returns `None` for striped items and keywords.
258+
StrippedItem(_) | KeywordItem(_) => unreachable!(),
262259
ExternCrateItem { ref src } => ItemEnum::ExternCrate {
263260
name: name.as_ref().unwrap().to_string(),
264261
rename: src.map(|x| x.to_string()),
@@ -764,7 +761,7 @@ impl FromWithTcx<ItemType> for ItemKind {
764761
fn ids(items: impl IntoIterator<Item = clean::Item>, tcx: TyCtxt<'_>) -> Vec<Id> {
765762
items
766763
.into_iter()
767-
.filter(|x| !x.is_stripped())
764+
.filter(|x| !x.is_stripped() && !x.is_keyword())
768765
.map(|i| from_item_id_with_name(i.item_id, tcx, i.name))
769766
.collect()
770767
}

0 commit comments

Comments
 (0)