Skip to content

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

Closed

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() {}

Activity

  1. added
    T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
    on Mar 11, 2025
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Mar 11, 2025
  3. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Mar 12, 2025
  4. changed the title [-]rustdoc-json: Don't include `#[depricated]` in `Item::attrs`, as it's already in `Item::deprecation`[/-] [+]rustdoc-json: Don't include `#[deprecated]` in `Item::attrs`, as it's already in `Item::deprecation`[/+] on Mar 12, 2025
  5. added a commit that references this issue on Mar 17, 2025
    b15e663
  6. added a commit that references this issue on Mar 17, 2025
    e16a3f1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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