diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-06-14 20:14:51 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-06-21 13:50:52 +1000 |
| commit | 40ba7913fc229ff2d17824fadc3b7c66a931f040 (patch) | |
| tree | 8fe518b2824aa9bf1767213567fbe43a80db500f /compiler/rustc_codegen_llvm/src | |
| parent | 18d742bda07d6f5d047c249cdd533c0e462b3298 (diff) | |
| download | rust-40ba7913fc229ff2d17824fadc3b7c66a931f040.tar.gz rust-40ba7913fc229ff2d17824fadc3b7c66a931f040.zip | |
rustdoc_json: Fix handling of paths with no generic args.
A path without generic args, like `Reader`, currently has JSON produced
like this:
```
{"path":"Reader","id":286,"args":{"angle_bracketed":{"args":[],"constraints":[]}}}
```
Even though `types::Path::args` is `Option` and allows for "no args",
instead it gets represented as "empty args". (More like `Reader<>` than
`Reader`.)
This is due to a problem in `clean::Path::from_clean`. It only produces
`None` if the path is an empty string. This commit changes it to also
produce `None` if there are no generic args. The example above becomes:
```
{"path":"Reader","id":286,"args":null}
```
I looked at a few examples and saw this reduce the size of the JSON
output by 3-9%.
The commit also adds an assertion that non-final segments don't have any
generics; something the old code was implicitly relying on.
Note: the original sin here is that `clean::PathSegment::args` is not an
`Option`, unlike `{ast,hir}::PathSegment::args`. I want to fix that, but
it can be done separately.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
0 files changed, 0 insertions, 0 deletions
