about summary refs log tree commit diff
path: root/src/librustdoc/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/librustdoc/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/librustdoc/json')
-rw-r--r--src/librustdoc/json/conversions.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs
index 4358dc8980f..7ffcfada5c0 100644
--- a/src/librustdoc/json/conversions.rs
+++ b/src/librustdoc/json/conversions.rs
@@ -340,9 +340,10 @@ impl FromWithTcx<clean::GenericParamDefKind> for GenericParamDefKind {
             Lifetime { outlives } => GenericParamDefKind::Lifetime {
                 outlives: outlives.into_iter().map(|lt| lt.0.to_string()).collect(),
             },
-            Type { did: _, bounds, default, synthetic: _ } => GenericParamDefKind::Type {
+            Type { did: _, bounds, default, synthetic } => GenericParamDefKind::Type {
                 bounds: bounds.into_iter().map(|x| x.into_tcx(tcx)).collect(),
                 default: default.map(|x| (*x).into_tcx(tcx)),
+                synthetic,
             },
             Const { did: _, ty, default } => {
                 GenericParamDefKind::Const { ty: (*ty).into_tcx(tcx), default: default.map(|x| *x) }