about summary refs log tree commit diff
path: root/src/test/rustdoc-json
diff options
context:
space:
mode:
authorMartin Nordholts <enselic@gmail.com>2022-02-19 09:50:35 +0100
committerMartin Nordholts <enselic@gmail.com>2022-03-04 05:54:12 +0100
commitaa763fcf421e627455aa1de16df1292c8e1bcb9d (patch)
treef0380c618dcca64aa91da9bc712991d4406132bb /src/test/rustdoc-json
parent6d7684101a51f1c375ec84aef5d2fbdeb214bbc2 (diff)
downloadrust-aa763fcf421e627455aa1de16df1292c8e1bcb9d.tar.gz
rust-aa763fcf421e627455aa1de16df1292c8e1bcb9d.zip
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: Clone>(_: 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.
Diffstat (limited to 'src/test/rustdoc-json')
-rw-r--r--src/test/rustdoc-json/fns/generics.rs5
1 files changed, 5 insertions, 0 deletions
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>(_: 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) {}