]> git.lizzy.rs Git - rust.git/commit
rustdoc-json: Include GenericParamDefKind::Type::synthetic in JSON
authorMartin Nordholts <enselic@gmail.com>
Sat, 19 Feb 2022 08:50:35 +0000 (09:50 +0100)
committerMartin Nordholts <enselic@gmail.com>
Fri, 4 Mar 2022 04:54:12 +0000 (05:54 +0100)
commitaa763fcf421e627455aa1de16df1292c8e1bcb9d
treef0380c618dcca64aa91da9bc712991d4406132bb
parent6d7684101a51f1c375ec84aef5d2fbdeb214bbc2
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.
src/librustdoc/json/conversions.rs
src/rustdoc-json-types/lib.rs
src/test/rustdoc-json/fns/generics.rs [new file with mode: 0644]