rustdoc-json: Expose Item stability#154603
rustdoc-json: Expose Item stability#154603aDotInTheVoid wants to merge 1 commit intorust-lang:mainfrom
Conversation
|
These commits modify Please ensure that if you've changed the output:
cc @obi1kenobi rustdoc-json-types is a public (although nightly-only) API. If possible, consider changing |
|
r? @fmease rustbot has assigned @fmease. Use Why was this reviewer chosen?The reviewer was selected based on:
|
759a6df to
af8204e
Compare
| /// Information about the item’s deprecation, if present. | ||
| pub deprecation: Option<Deprecation>, | ||
|
|
||
| pub stability: Option<Stability>, |
There was a problem hiding this comment.
I'm not sure if this should go here, or as a new variant in Attribute. Thoughts appreciated.
| #[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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
This comment has been minimized.
This comment has been minimized.
af8204e to
5f09a58
Compare
There was a problem hiding this comment.
My 2 cents: in favor of this approach, and also in favor of not making perfect be the enemy of good.
Stability is a property of the item as a whole, while a stability attribute tells us what's happening syntactically. This is similar to #[deprecated] in my mind: applying #[deprecated] to an enum also implicitly marks its variants as deprecated, so the variants' item-level deprecation status is deprecated but only the enum shows up with a #[deprecated] attribute.
The item-level stability is more valuable than the attribute, because it's authoritative. Syntactic information at the attribute level is nice to have too, but not a blocker. Same with item-level / attribute-level info like since.
| pub level: StabilityLevel, | ||
| } | ||
|
|
||
| #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] |
There was a problem hiding this comment.
consider Copy too? it's a breaking change to add it later :)
| //@ 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")] |
There was a problem hiding this comment.
having the since data available would be a neat nice-to-have, but we don't need to block this PR on a nice-to-have
This comment has been minimized.
This comment has been minimized.
This is motivated by cargo-semver-checks wanting to work on the standard library, but that requires being able to filter out breaking changes to unstable items, so it can only flag breaking changes to stable items. This in turn is motivated by https://www.github.com/rust-lang/rust/issues/153486.
5f09a58 to
5245648
Compare
This is motivated by cargo-semver-checks wanting to work on the standard library, but that requires being able to filter out breaking changes to unstable items, so it can only flag breaking changes to stable items. This in turn is motivated by
#153486.
TODO
Item, or a variant onAttributesStabilityLevelCC @obi1kenobi