-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
rustdoc: decouple stability and const-stability #91694
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 |
---|---|---|
|
@@ -67,3 +67,20 @@ impl Foo { | |
#[rustc_const_stable(feature = "rust1", since = "1.2.0")] | ||
pub const fn stable_impl() -> u32 { 42 } | ||
} | ||
|
||
#[stable(feature = "rust1", since = "1.0.0")] | ||
pub struct Bar; | ||
|
||
impl Bar { | ||
// Do not show non-const stabilities that are the same as the enclosing item. | ||
// @matches 'foo/struct.Bar.html' '//span[@class="since"]' '^const: 1.2.0$' | ||
#[stable(feature = "rust1", since = "1.0.0")] | ||
#[rustc_const_stable(feature = "rust1", since = "1.2.0")] | ||
pub const fn stable_impl() -> u32 { 42 } | ||
|
||
// Show const-stability even for unstable functions. | ||
// @matches 'foo/struct.Bar.html' '//span[@class="since"]' '^const: 1.3.0$' | ||
#[unstable(feature = "foo2", issue = "none")] | ||
#[rustc_const_stable(feature = "rust1", since = "1.3.0")] | ||
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. I think this is invalid, you cannot have a 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. I disagree that it's "obviously wrong", allowing unstable functions to be called in a const-stable context is called out as a use-case in the rustc-guide. 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. Fair enough, I didn't knew that. Thanks for that but I still think having both 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. I agree that 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. Regardless of whether const-stable unstable functions are disallowed in the future, the implementation of this PR won't be affected: the invalid test case will just be removed. For now, it's supported, so it makes sense to me to show it in the documentation. |
||
pub const fn const_stable_unstable() -> u32 { 42 } | ||
} |
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.
Is the
1.0.0
still displayed? If not, please put it back like it used to. In any case, please add a test to ensure both are displayed if both are present like it's currently the case.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.
@GuillaumeGomez This is one of the goals of this PR. Currently, stabilities are omitted if the stability of the item matches the stability of the enclosing struct or module, except if they also have a const stability.
This PR updates the logic to always omit the stability if it matches, regardless of whether the item is const-stable or not.
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.
Oh I see. Thanks for the explanations!