Skip to content

rustdoc-json: Don't include #[deprecated] in Item::attrs, as it's already in Item::deprecation #138378

Open
@aDotInTheVoid

Description

@aDotInTheVoid

This function:

#[deprecated(since = "yoinks ago")]
pub fn since() {}

After runing rustdoc -wjson gives

    "2": {
      "attrs": ["#[attr = Deprecation {deprecation: Deprecation {since:\nNonStandard(\"yoinks ago\")}}]\n"],
      "crate_id": 0,
      "deprecation": {"note": null, "since": "yoinks ago"},
      "docs": null,
      "id": 2,
      "inner": {
        "function": {
          "generics": {"params": [], "where_predicates": []},
          "has_body": true,
          "header": {"abi": "Rust", "is_async": false, "is_const": false, "is_unsafe": false},
          "sig": {"inputs": [], "is_c_variadic": false, "output": null}
        }
      },
      "links": {},
      "name": "since",
      "span": {
        "begin": [10, 0],
        "end": [10, 17],
        "filename": "/home/gh-aDotInTheVoid/rust2/tests/rustdoc-json/attrs/deprecated.rs"
      },
      "visibility": "public"
    },

We include "attrs": ["#[attr = Deprecation {deprecation: Deprecation {since:\nNonStandard(\"yoinks ago\")}}]\n"],, but this is redundant because it's also availible (in a better, more structed format) as "deprecation": {"note": null, "since": "yoinks ago"},

We should remove this info from attrs, and only provide it in deprecation.

CC @obi1kenobi

Here's the bones of a testcase because I started on this this evening but it's too late to finish
#[deprecated]
pub fn raw() {}

#[deprecated = "here's a reason"]
pub fn equals_string() {}

#[deprecated(since = "yoinks ago")]
pub fn since() {}

#[deprecated(note = "7")]
pub fn note() {}

#[deprecated(since = "tomorrow", note = "sorry")]
pub fn since_and_note() {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-rustdoc-jsonArea: Rustdoc JSON backendT-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