-
-
Notifications
You must be signed in to change notification settings - Fork 15.4k
rustdoc-json: Expose Item stability #154603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -114,8 +114,8 @@ pub type FxHashMap<K, V> = HashMap<K, V>; // re-export for use in src/librustdoc | |
| // will instead cause conflicts. See #94591 for more. (This paragraph and the "Latest feature" line | ||
| // are deliberately not in a doc comment, because they need not be in public docs.) | ||
| // | ||
| // Latest feature: Add `ExternCrate::path`. | ||
| pub const FORMAT_VERSION: u32 = 57; | ||
| // Latest feature: Add `Item::stability`. | ||
| pub const FORMAT_VERSION: u32 = 58; | ||
|
|
||
| /// The root of the emitted JSON blob. | ||
| /// | ||
|
|
@@ -294,10 +294,30 @@ pub struct Item { | |
| pub attrs: Vec<Attribute>, | ||
| /// Information about the item’s deprecation, if present. | ||
| pub deprecation: Option<Deprecation>, | ||
|
|
||
| pub stability: Option<Stability>, | ||
|
|
||
| /// The type-specific fields describing this item. | ||
| pub inner: ItemEnum, | ||
| } | ||
|
|
||
| #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] | ||
| #[cfg_attr(feature = "rkyv_0_8", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))] | ||
| #[cfg_attr(feature = "rkyv_0_8", rkyv(derive(Debug)))] | ||
| pub struct Stability { | ||
| pub feature: String, | ||
| pub level: StabilityLevel, | ||
| } | ||
|
|
||
| #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. consider |
||
| #[cfg_attr(feature = "rkyv_0_8", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))] | ||
| #[cfg_attr(feature = "rkyv_0_8", rkyv(derive(Debug)))] | ||
| #[serde(rename_all = "snake_case")] | ||
| pub enum StabilityLevel { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We probably want to expose more stuff here. Rustc has all of https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/enum.StabilityLevel.html. I'm not sure how much of that anyone other than rustc cares about. Thoughts appreciated.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's probably interesting tooling that can be built on top of querying that info, but we can save that for rustdoc JSON v59+ if it's a hassle to add here. It's very nice to have but I wouldn't block this PR over it. |
||
| Stable, | ||
| Unstable, | ||
| } | ||
|
|
||
| #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] | ||
| #[cfg_attr(feature = "rkyv_0_8", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))] | ||
| #[cfg_attr(feature = "rkyv_0_8", rkyv(derive(Debug)))] | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| #![feature(staged_api)] | ||
|
|
||
| //@ is "$.index[?(@.name=='foo')].stability.level" '"stable"' | ||
| //@ is "$.index[?(@.name=='foo')].stability.feature" '"eeeee"' | ||
| //@ is "$.index[?(@.name=='foo')].attrs" [] | ||
| #[stable(since = "2.71.8", feature = "eeeee")] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. having the |
||
| pub fn foo() {} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| //@ is "$.index[?(@.name=='foo')].stability" null | ||
| //@ is "$.index[?(@.name=='foo')].attrs" [] | ||
| pub fn foo() {} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| #![feature(staged_api)] | ||
|
|
||
| //@ is "$.index[?(@.name=='foo')].stability.level" '"unstable"' | ||
| //@ is "$.index[?(@.name=='foo')].stability.feature" '"delights"' | ||
| //@ is "$.index[?(@.name=='foo')].attrs" [] | ||
| #[unstable(feature = "delights", issue = "26")] | ||
| pub fn foo() {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this should go here, or as a new variant in
Attribute. Thoughts appreciated.