From aa763fcf421e627455aa1de16df1292c8e1bcb9d Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Sat, 19 Feb 2022 09:50:35 +0100 Subject: rustdoc-json: Include GenericParamDefKind::Type::synthetic in JSON The rustdoc JSON for ``` pub fn f(_: impl Clone) {} ``` will effectively be ``` pub fn f(_: impl Clone) ``` where a synthetic generic parameter called `impl Clone` with generic trait bound `Clone` is added to the function declaration. The generated HTML filters out these generic parameters by doing `self.params.iter().filter(|p| !p.is_synthetic_type_param())`, because the synthetic generic parameter is not of interest to regular users. For the same reason, we should expose whether or not a generic parameter is synthetic or not also in the rustdoc JSON, so that rustdoc JSON clients can also have the option to hide synthetic generic parameters. --- src/test/rustdoc-json/fns/generics.rs | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/test/rustdoc-json/fns/generics.rs (limited to 'src/test/rustdoc-json') diff --git a/src/test/rustdoc-json/fns/generics.rs b/src/test/rustdoc-json/fns/generics.rs new file mode 100644 index 00000000000..f80c380337b --- /dev/null +++ b/src/test/rustdoc-json/fns/generics.rs @@ -0,0 +1,5 @@ +// @has generics.json "$.index[*][?(@.name=='one_generic_param_fn')].inner.generics.params[0].kind.type.synthetic" false +pub fn one_generic_param_fn(_: T) {} + +// @has - "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.generics.params[0].kind.type.synthetic" true +pub fn one_synthetic_generic_param_fn(_: impl Clone) {} -- cgit 1.4.1-3-g733a5