Skip to content

feat: Provide an '.item_kind()' method on ItemEnum#153279

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
LukeMathWalker:add-kind-method
Mar 3, 2026
Merged

feat: Provide an '.item_kind()' method on ItemEnum#153279
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
LukeMathWalker:add-kind-method

Conversation

@LukeMathWalker
Copy link
Contributor

A little helper method which I found myself adding over and over again in all the projects I maintain which depend on rustdoc-json-types.

r? @aDotInTheVoid

@rustbot
Copy link
Collaborator

rustbot commented Mar 2, 2026

rustdoc-json-types is a public (although nightly-only) API. If possible, consider changing src/librustdoc/json/conversions.rs; otherwise, make sure you bump the FORMAT_VERSION constant.

cc @CraftSpider, @aDotInTheVoid, @Enselic, @obi1kenobi

@rustbot rustbot added A-rustdoc-json Area: Rustdoc JSON backend S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Mar 2, 2026
@rustbot
Copy link
Collaborator

rustbot commented Mar 2, 2026

aDotInTheVoid is currently at their maximum review capacity.
They may take a while to respond.

@rust-log-analyzer

This comment has been minimized.

Copy link
Member

@aDotInTheVoid aDotInTheVoid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

impl ItemEnum {
/// Returns the [`ItemKind`] of this item.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: This doc comment doesn't say anything that isn't in the function signature. Maybe add a sentance or an example about why you'd want to do this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's one of those methods where it's difficult to be insightful in doc comments 😅

ItemEnum::Static(_) => ItemKind::Static,
ItemEnum::ExternType => ItemKind::ExternType,
ItemEnum::Macro(_) => ItemKind::Macro,
ItemEnum::ProcMacro(pm) => match pm.kind {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, maybe we should merge these in ItemKind, or split them in ItemEnum. (But not in this PR)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it does violate the overall ItemEnum variant <> ItemKind variant symmetry a bit.

@aDotInTheVoid
Copy link
Member

@bors r+ rollup

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 2, 2026

📌 Commit 931e2c4 has been approved by aDotInTheVoid

It is now in the queue for this repository.

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 2, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Mar 3, 2026
…aDotInTheVoid

feat: Provide an '.item_kind()' method on ItemEnum

A little helper method which I found myself adding over and over again in all the projects I maintain which depend on `rustdoc-json-types`.

r? @aDotInTheVoid
rust-bors bot pushed a commit that referenced this pull request Mar 3, 2026
…uwer

Rollup of 12 pull requests

Successful merges:

 - #152941 (prefer actual ABI-controling fields over target.abi when making ABI decisions)
 - #153227 (Don’t report missing fields in struct exprs with syntax errors.)
 - #153265 (Clarified doc comments + added tests confirming current behavior for intersperse/intersperse_with)
 - #152966 (Migrate 11 tests from tests/ui/issues to specific directories)
 - #153003 (rustdoc: make `--emit` and `--out-dir` mimic rustc)
 - #153034 (Remove unhelpful hint from trivial bound errors)
 - #153152 (Migration of LintDiagnostic - part 5)
 - #153177 (disable the ptr_fragment_in_final test on s390x)
 - #153221 (Add release notes for 1.94.0)
 - #153279 (feat: Provide an '.item_kind()' method on ItemEnum)
 - #153297 (Update the name of the Hermit operating system)
 - #153309 (Cleanup of c-variadic link test)
@rust-bors rust-bors bot merged commit 3bb5245 into rust-lang:main Mar 3, 2026
11 checks passed
@rustbot rustbot added this to the 1.96.0 milestone Mar 3, 2026
rust-timer added a commit that referenced this pull request Mar 3, 2026
Rollup merge of #153279 - LukeMathWalker:add-kind-method, r=aDotInTheVoid

feat: Provide an '.item_kind()' method on ItemEnum

A little helper method which I found myself adding over and over again in all the projects I maintain which depend on `rustdoc-json-types`.

r? @aDotInTheVoid
@aDotInTheVoid
Copy link
Member

Published in v0.57.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-rustdoc-json Area: Rustdoc JSON backend S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants