Skip to content
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

Standard library rustdoc: show since when a function is const #76998

Closed
RalfJung opened this issue Sep 21, 2020 · 4 comments · Fixed by #79548
Closed

Standard library rustdoc: show since when a function is const #76998

RalfJung opened this issue Sep 21, 2020 · 4 comments · Fixed by #79548
Assignees
Labels
A-const-fn Area: const fn foo(..) {..}. Pure functions which can be applied at compile time. A-stability Area: issues related to #[stable] and #[unstable] attributes themselves. C-feature-request Category: A feature request, i.e: not implemented / a PR. E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@RalfJung
Copy link
Member

RalfJung commented Sep 21, 2020

The standard library has #[rustc_const_stable] attributes for all stable const fn. These contain since information. It would be great if rustdoc could render that, indicating since when this function is const-stable.

@RalfJung RalfJung added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. C-feature-request Category: A feature request, i.e: not implemented / a PR. labels Sep 21, 2020
@jyn514
Copy link
Member

jyn514 commented Oct 11, 2020

What would you expect this to look like? For 'this has existed since version x' it shows up as a version number next to [src]:
image

But if there's both 'existed since' and 'const since', that's now ambiguous.

@jyn514 jyn514 added the A-stability Area: issues related to #[stable] and #[unstable] attributes themselves. label Oct 11, 2020
@RalfJung
Copy link
Member Author

Strawman proposal: something like 1.0.0 (const: 1.10.0) in the same spot (and same color)?

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Oct 13, 2020
Switch rustdoc from `clean::Stability` to `rustc_attr::Stability`

This gives greater type safety and is less work to maintain on the rustdoc end. It also makes rustdoc more consistent with rustc.
Noticed this while working on rust-lang#76998.

- Remove `clean::Stability` in favor of `rustc_attr::Stability`
- Remove `impl Clean for Stability`; it's no longer necessary

r? @GuillaumeGomez
cc @petrochenkov
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Oct 14, 2020
Switch rustdoc from `clean::Stability` to `rustc_attr::Stability`

This gives greater type safety and is less work to maintain on the rustdoc end. It also makes rustdoc more consistent with rustc.
Noticed this while working on rust-lang#76998.

- Remove `clean::Stability` in favor of `rustc_attr::Stability`
- Remove `impl Clean for Stability`; it's no longer necessary

r? @GuillaumeGomez
cc @petrochenkov
bors added a commit to rust-lang-ci/rust that referenced this issue Nov 18, 2020
Add `Item::from_def_id_and_kind` to reduce duplication in rustdoc

This makes it harder to make typos, and also makes it much more clear what's intentionally different rather than a typo (look for `what_rustc_thinks`).

Found this while working on rust-lang#76998, I really didn't want to add `const_visibility` in 20 different places.

r? `@GuillaumeGomez`
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Nov 24, 2020
…meGomez

Make `fold_item_recur` non-nullable

This gets rid of a bunch of `unwrap()`s and makes it a little more clear
what's going on.

Originally I wanted to make `fold_item` non-nullable too, which would
have been a lot nicer to work with, but unfortunately `stripper` does
actually return `None` in some places. I might make a follow-up moving
stripper to be special and not a pass so that passes can be
non-nullable.

Found while working on rust-lang#76998.
bors added a commit to rust-lang-ci/rust that referenced this issue Nov 27, 2020
Cleanup more of rustdoc

-  Use `Item::from_def_id` for StructField
- Use `from_def_id_and_parts` for primitives and keywords
- Take `String` instead of `Symbol` in `from_def_id` - this avoids having to intern then immediately stringify the existing string.
- Remove unused `get_stability` and `get_deprecation`
- Remove unused `attrs` field from `primitives`
- Remove unused `attrs` field from `keywords`

This will probably conflict with rust-lang#79335 and I would prefer for that PR to land first - I'm anxious for rust-lang#77467 to land :)

Makes rust-lang#76998 easier to add.

r? `@GuillaumeGomez`
@jyn514 jyn514 added the E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. label Nov 29, 2020
@jyn514
Copy link
Member

jyn514 commented Nov 29, 2020

Mentoring instructions: This should be a lot easier after all the cleanups.

@jyn514 jyn514 added A-const-fn Area: const fn foo(..) {..}. Pure functions which can be applied at compile time. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. labels Nov 29, 2020
@CraftSpider
Copy link
Contributor

@rustbot claim

m-ou-se added a commit to m-ou-se/rust that referenced this issue Dec 1, 2020
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`
@bors bors closed this as completed in 33d7b8c Dec 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-fn Area: const fn foo(..) {..}. Pure functions which can be applied at compile time. A-stability Area: issues related to #[stable] and #[unstable] attributes themselves. C-feature-request Category: A feature request, i.e: not implemented / a PR. E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants