Skip to content

rustdoc-json: Precise capturing JSON is untyped #137616

Closed
@Enselic

Description

@Enselic

Given this function:

pub fn capture<'a, T>(x: &'a (), y: T) -> impl Sized + use<'a, T> {
    (x, y)
}

we can see this rustdoc JSON for the function output type:

rustdoc +nightly -Zunstable-options --output-format json src/lib.rs
  "output": {
      "impl_trait": [
          {
              "trait_bound": {
                  "trait": {
                      "path": "Sized",
                      "id": 1,
                      "args": {
                          "angle_bracketed": {
                              "args": [],
                              "constraints": []
                          }
                      }
                  },
                  "generic_params": [],
                  "modifier": "none"
              }
          },
          {
              "use": [
                  "'a",
                  "T"
              ]
          }
      ]
  },

Note that the use data is completely untyped and just raw strings:

          {
              "use": [
                  "'a",
                  "T"
              ]
          }

We probably want to use different JSON types at least for generic args and lifetimes before we stabilize the format.

Right now cargo-public-api resorts to a "if string begins with ' " hack.

Metadata

Metadata

Assignees

Labels

A-rustdoc-jsonArea: Rustdoc JSON backendC-enhancementCategory: An issue proposing an enhancement or a PR with one.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.F-precise_capturing`#![feature(precise_capturing)]`T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions