Skip to content

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

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
aDotInTheVoid opened this issue Mar 11, 2025 · 0 comments · Fixed by #138577
Labels
A-rustdoc-json Area: Rustdoc JSON backend T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@aDotInTheVoid
Copy link
Member

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() {}
@aDotInTheVoid aDotInTheVoid added A-rustdoc-json Area: Rustdoc JSON backend T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Mar 11, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 11, 2025
@aDotInTheVoid aDotInTheVoid removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 12, 2025
@jhpratt jhpratt 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 Mar 12, 2025
@bors bors closed this as completed in b15e663 Mar 17, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Mar 17, 2025
Rollup merge of rust-lang#138577 - aDotInTheVoid:deprecate-deprecations, r=GuillaumeGomez

rustdoc-json: Don't also include `#[deprecated]` in `Item::attrs`

Closes rust-lang#138378

Not sure if this should bump `FORMAT_VERSION` or not. CC `@Enselic` `@LukeMathWalker` `@obi1kenobi`

r? `@GuillaumeGomez,` best reviewed commit-by-commit
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-rustdoc-json Area: Rustdoc JSON backend T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants