-
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
Show since when a function is const in stdlib #79548
Conversation
That was quick! |
let ver = ver.and_then(|inner| if !inner.is_empty() { Some(inner) } else { None }); | ||
|
||
let const_ver = const_ver.and_then(|inner| if !inner.is_empty() { Some(inner) } else { None }); | ||
|
||
if let Some(v) = ver { |
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.
No else
because there shouldn't be such a thing as 'stably const but not stable'
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.
"<span class=\"since\" title=\"Stable since Rust version {0}\">{0}</span>", | ||
v | ||
); | ||
} | ||
} | ||
} |
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.
Can you assert here that const_ver.is_none()
, and add an error earlier (in from_def_id_and_parts
, since that's the only place const_stability
isn't None
) if const_stability
is set but not stability
? If you're feeling really ambitious, you could make it part of the type system in Item
and have stability: Option(Stability, Option<ConstStability>)
.
@bors r+ After thinking about this more, I realized that ' |
📌 Commit ccbb0f5 has been approved by |
Opened #79551 to address the rustc side |
Show since when a function is const in stdlib Fixes rust-lang#76998 This makes it so that functions with the `#[rustc_const_stable()]` attribute now show from what version they were stably declared const, alongside what version they were declared stable. Example from `Result`: ![image](https://user-images.githubusercontent.com/13342132/100561194-1be60d00-3286-11eb-99ff-1e81201218a9.png) r? `@jyn514`
Rollup of 11 pull requests Successful merges: - rust-lang#79038 (Change ui test that are run-pass and that do not test the compiler to library tests) - rust-lang#79184 (Stop adding '*' at the end of slice and str typenames for MSVC case) - rust-lang#79227 (Remove const_fn_feature_flags test) - rust-lang#79444 (Move const ip in ui test to unit test) - rust-lang#79522 (Validate lint docs separately.) - rust-lang#79525 (Add -Z normalize-docs and enable it for compiler docs) - rust-lang#79527 (Move intra-doc link tests into a subdirectory) - rust-lang#79548 (Show since when a function is const in stdlib) - rust-lang#79568 (update Miri) - rust-lang#79573 (Update with status for various NetBSD ports.) - rust-lang#79583 (Update books) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Fixes #76998
This makes it so that functions with the
#[rustc_const_stable()]
attribute now show from what version they were stably declared const, alongside what version they were declared stable. Example fromResult
:r? @jyn514