From ba87c934ea86476bbd75909eb18cbf7627c12c81 Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Wed, 29 Jun 2022 20:34:56 +0200 Subject: [PATCH] rustdoc-json: Make default value of blanket impl assoc types work --- src/librustdoc/json/conversions.rs | 2 +- src/test/rustdoc-json/blanket_impls.rs | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 src/test/rustdoc-json/blanket_impls.rs diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index afc84cc0a97aa..316554808c201 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -255,7 +255,7 @@ fn from_clean_item(item: clean::Item, tcx: TyCtxt<'_>) -> ItemEnum { AssocTypeItem(t, b) => ItemEnum::AssocType { generics: t.generics.into_tcx(tcx), bounds: b.into_iter().map(|x| x.into_tcx(tcx)).collect(), - default: t.item_type.map(|ty| ty.into_tcx(tcx)), + default: Some(t.item_type.unwrap_or(t.type_).into_tcx(tcx)), }, // `convert_item` early returns `None` for striped items and keywords. StrippedItem(_) | KeywordItem(_) => unreachable!(), diff --git a/src/test/rustdoc-json/blanket_impls.rs b/src/test/rustdoc-json/blanket_impls.rs new file mode 100644 index 0000000000000..edf1a9fe2fcf9 --- /dev/null +++ b/src/test/rustdoc-json/blanket_impls.rs @@ -0,0 +1,9 @@ +// Regression test for + +#![no_std] + +// @has blanket_impls.json +// @has - "$.index[*][?(@.name=='Error')].kind" \"assoc_type\" +// @has - "$.index[*][?(@.name=='Error')].inner.default.kind" \"resolved_path\" +// @has - "$.index[*][?(@.name=='Error')].inner.default.inner.name" \"Infallible\" +pub struct ForBlanketTryFromImpl;