docs(unstable-book): Document const generics features#155543
docs(unstable-book): Document const generics features#155543popzxc wants to merge 4 commits intorust-lang:mainfrom
Conversation
|
|
| let mut i = 0; | ||
| while i < B::Y { | ||
| let mut j = 0; | ||
| while j < B::X { | ||
| out[i * B::X + j] = y[i].saturating_mul(x[j]); | ||
| j += 1; | ||
| } | ||
| i += 1; | ||
| } |
There was a problem hiding this comment.
This body sort of shifts the attention from the things I wanted to highlight, but I thought that adding todo!() here would not feel genuine for readers.
| @@ -0,0 +1,59 @@ | |||
| # generic_const_items | |||
There was a problem hiding this comment.
Not directly related to other 3, but it 1. seems to be cross-referenced a lot (e.g. in UI tests), and 2. similar in spirit and might often be a thing that people actually want to have.
| @@ -0,0 +1,110 @@ | |||
| # min_generic_const_args | |||
|
|
|||
| Enables the generic const args MVP. | |||
There was a problem hiding this comment.
The feature description also states (only bare paths, not arbitrary computation), which feels out of date now -- right now more functionality seems to be supported, but I did not change any rust source code, as this feature is only about the documentation. Happy to change to whatever phrasing works better, both here and in unstable.rs if required.
There was a problem hiding this comment.
right now the things mGCA supports are:
- paths to type const items (e.g. ::ASSOC)
- tuple constructor calls (e.g. Some(N)
- struct/enum variant expressions (e.g. Some { 0: N })
- paths to const constructors (e.g. None::)
- tuple expressions (e.g. (N,))
- array expressions (e.g. [N, N])
There was a problem hiding this comment.
maybe concise wording here is "Paths to type const items and constructors for ADTs and primitives"
| @@ -0,0 +1,72 @@ | |||
| # generic_const_exprs | |||
|
|
|||
| Allows non-trivial generic constants which have to have wfness manually propagated to callers | |||
There was a problem hiding this comment.
"wfness" might be an unfamiliar term for people outside of Rust compiler developers community, so it might not be suitable for public documentation; left it here because it's technically correct and used in unstable.rs.
There was a problem hiding this comment.
wfness = well-formedness; I would at least use the written-out form since that's an established term in linguistics that's searchable.
There was a problem hiding this comment.
I would say something like "which have to be shown to successfully evaluate to a value by being part of an item signature". i think even the fully written "well-formedness" is a bit too jargon
This comment has been minimized.
This comment has been minimized.
59f05a0 to
b4886b2
Compare
|
|
||
| Related features: [generic_const_args], [generic_const_items]. | ||
|
|
||
| [feature_background]: https://hackmd.io/OsVAAEgOS2ajDwxg44kN-A?view |
There was a problem hiding this comment.
I think linking to a hackmd file is somewhat unfortunate 🤔 would you be willing to make a PR to the rust-lang/project-const-generics repo adding a documents/ directory and moving this document into there?
then we can link to a markdown file on github instead of a hackmd link
There was a problem hiding this comment.
Yup, will do slightly later!
b4886b2 to
73e44e8
Compare
|
|
||
| Related features: [generic_const_args], [generic_const_items]. | ||
|
|
||
| [feature_background]: https://github.com/rust-lang/project-const-generics/blob/main/documents/min_const_generics_plan.md |
There was a problem hiding this comment.
Link updated, pending corresponding PR merge
This comment has been minimized.
This comment has been minimized.
Co-authored-by: León Orell Valerian Liehr <me@fmease.dev>
656bb20 to
c4eb1bf
Compare
|
@BoxyUwU is there anything else that needs to be done either in rust-lang/project-const-generics#110 or this PR? |
|
left a comment on the other PR, this should be good to go once that's merged :) |
|
@rustbot author |
|
Reminder, once the PR becomes ready for a review, use |
|
@rustbot ready This PR links the markdown file and the PR is merged, so should be good to go. |
|
@bors r+ rollup |
…ures, r=BoxyUwU docs(unstable-book): Document const generics features Relevant tracking issues: rust-lang#113521 rust-lang#132980 rust-lang#76560 rust-lang#151972 ## What Adds a high-level overview of 4 unstable features related to const generic exprs. ## Why While trying to learn about the current state of const generic exprs, I found it a bit too hard due to lack of documentation -- had to read through a bunch of tracking issues & look for PRs/examples in the repo just to understand what the feature is about. Moreover, given that there is a bunch of features with similarly-looking names, it was even more confusing. For that purpose, I also added cross-referencing across (directly or logically) related features. As a result, I decided to add some more context to the unstable book, so that new readers have an easier time than I had. ## Caveats I understand that the features are incomplete/experimental, so the docs are at risk of becoming stale, but the book entrypoint already has [a corresponding warning](https://doc.rust-lang.org/unstable-book/), so I guess it should be fine. Also, given that I did research myself, the examples provided might be not the best to showcase the feature -- happy to provide better examples, if you have suggestions. The examples provided are what "made the feature make sense" to me as an outsider, so there is a chance that they will be good for other external readers too, though. LLM use disclosue: an LLM was used for self-review only; research, coming up with examples, and writing is mine. Issues reported by LLM were fixed manually too. r? @BoxyUwU
|
⌛ Testing commit c4eb1bf with merge 1fac9f8... Workflow: https://github.com/rust-lang/rust/actions/runs/25319609277 |
…yUwU docs(unstable-book): Document const generics features Relevant tracking issues: #113521 #132980 #76560 #151972 ## What Adds a high-level overview of 4 unstable features related to const generic exprs. ## Why While trying to learn about the current state of const generic exprs, I found it a bit too hard due to lack of documentation -- had to read through a bunch of tracking issues & look for PRs/examples in the repo just to understand what the feature is about. Moreover, given that there is a bunch of features with similarly-looking names, it was even more confusing. For that purpose, I also added cross-referencing across (directly or logically) related features. As a result, I decided to add some more context to the unstable book, so that new readers have an easier time than I had. ## Caveats I understand that the features are incomplete/experimental, so the docs are at risk of becoming stale, but the book entrypoint already has [a corresponding warning](https://doc.rust-lang.org/unstable-book/), so I guess it should be fine. Also, given that I did research myself, the examples provided might be not the best to showcase the feature -- happy to provide better examples, if you have suggestions. The examples provided are what "made the feature make sense" to me as an outsider, so there is a chance that they will be good for other external readers too, though. LLM use disclosue: an LLM was used for self-review only; research, coming up with examples, and writing is mine. Issues reported by LLM were fixed manually too. r? @BoxyUwU
|
@bors yield For encompassing rollup |
|
Auto build was cancelled. Cancelled workflows: The next pull request likely to be tested is #156140. |
Rollup of 6 pull requests Successful merges: - #155543 (docs(unstable-book): Document const generics features) - #156043 (c-variadic: gate `va_arg` on `c_variadic_experimental_arch`) - #156082 (Move tests associated types) - #156092 (Clean up `TyCtxt::needs_crate_hash` usage and rename it to `needs_hir_hash`.) - #156104 (Relax `T: Sized` bound on `try_as_dyn` / `try_as_dyn_mut`) - #156128 (.mailmap: prefer matching just based on commit emails)
…ures, r=BoxyUwU docs(unstable-book): Document const generics features Relevant tracking issues: rust-lang#113521 rust-lang#132980 rust-lang#76560 rust-lang#151972 ## What Adds a high-level overview of 4 unstable features related to const generic exprs. ## Why While trying to learn about the current state of const generic exprs, I found it a bit too hard due to lack of documentation -- had to read through a bunch of tracking issues & look for PRs/examples in the repo just to understand what the feature is about. Moreover, given that there is a bunch of features with similarly-looking names, it was even more confusing. For that purpose, I also added cross-referencing across (directly or logically) related features. As a result, I decided to add some more context to the unstable book, so that new readers have an easier time than I had. ## Caveats I understand that the features are incomplete/experimental, so the docs are at risk of becoming stale, but the book entrypoint already has [a corresponding warning](https://doc.rust-lang.org/unstable-book/), so I guess it should be fine. Also, given that I did research myself, the examples provided might be not the best to showcase the feature -- happy to provide better examples, if you have suggestions. The examples provided are what "made the feature make sense" to me as an outsider, so there is a chance that they will be good for other external readers too, though. LLM use disclosue: an LLM was used for self-review only; research, coming up with examples, and writing is mine. Issues reported by LLM were fixed manually too. r? @BoxyUwU
…ures, r=BoxyUwU docs(unstable-book): Document const generics features Relevant tracking issues: rust-lang#113521 rust-lang#132980 rust-lang#76560 rust-lang#151972 ## What Adds a high-level overview of 4 unstable features related to const generic exprs. ## Why While trying to learn about the current state of const generic exprs, I found it a bit too hard due to lack of documentation -- had to read through a bunch of tracking issues & look for PRs/examples in the repo just to understand what the feature is about. Moreover, given that there is a bunch of features with similarly-looking names, it was even more confusing. For that purpose, I also added cross-referencing across (directly or logically) related features. As a result, I decided to add some more context to the unstable book, so that new readers have an easier time than I had. ## Caveats I understand that the features are incomplete/experimental, so the docs are at risk of becoming stale, but the book entrypoint already has [a corresponding warning](https://doc.rust-lang.org/unstable-book/), so I guess it should be fine. Also, given that I did research myself, the examples provided might be not the best to showcase the feature -- happy to provide better examples, if you have suggestions. The examples provided are what "made the feature make sense" to me as an outsider, so there is a chance that they will be good for other external readers too, though. LLM use disclosue: an LLM was used for self-review only; research, coming up with examples, and writing is mine. Issues reported by LLM were fixed manually too. r? @BoxyUwU
…uwer Rollup of 10 pull requests Successful merges: - #155848 ([doc]: Revert `core::io::ErrorKind` doc changes) - #155855 (Remove unnecessary `get_unchecked`) - #156062 (Added command-line argument support for `wasm32-wali-linux-musl`) - #155543 (docs(unstable-book): Document const generics features) - #156043 (c-variadic: gate `va_arg` on `c_variadic_experimental_arch`) - #156082 (Move tests associated types) - #156092 (Clean up `TyCtxt::needs_crate_hash` usage and rename it to `needs_hir_hash`.) - #156104 (Relax `T: Sized` bound on `try_as_dyn` / `try_as_dyn_mut`) - #156128 (.mailmap: prefer matching just based on commit emails) - #156135 (Remove most uses of def_id_to_node_id)
…ures, r=BoxyUwU docs(unstable-book): Document const generics features Relevant tracking issues: rust-lang#113521 rust-lang#132980 rust-lang#76560 rust-lang#151972 ## What Adds a high-level overview of 4 unstable features related to const generic exprs. ## Why While trying to learn about the current state of const generic exprs, I found it a bit too hard due to lack of documentation -- had to read through a bunch of tracking issues & look for PRs/examples in the repo just to understand what the feature is about. Moreover, given that there is a bunch of features with similarly-looking names, it was even more confusing. For that purpose, I also added cross-referencing across (directly or logically) related features. As a result, I decided to add some more context to the unstable book, so that new readers have an easier time than I had. ## Caveats I understand that the features are incomplete/experimental, so the docs are at risk of becoming stale, but the book entrypoint already has [a corresponding warning](https://doc.rust-lang.org/unstable-book/), so I guess it should be fine. Also, given that I did research myself, the examples provided might be not the best to showcase the feature -- happy to provide better examples, if you have suggestions. The examples provided are what "made the feature make sense" to me as an outsider, so there is a chance that they will be good for other external readers too, though. LLM use disclosue: an LLM was used for self-review only; research, coming up with examples, and writing is mine. Issues reported by LLM were fixed manually too. r? @BoxyUwU
…uwer Rollup of 10 pull requests Successful merges: - #155848 ([doc]: Revert `core::io::ErrorKind` doc changes) - #155855 (Remove unnecessary `get_unchecked`) - #155543 (docs(unstable-book): Document const generics features) - #155962 (`rustc`: `target_features`: allow for `cfg`-only stable `target_features`) - #156043 (c-variadic: gate `va_arg` on `c_variadic_experimental_arch`) - #156082 (Move tests associated types) - #156092 (Clean up `TyCtxt::needs_crate_hash` usage and rename it to `needs_hir_hash`.) - #156104 (Relax `T: Sized` bound on `try_as_dyn` / `try_as_dyn_mut`) - #156128 (.mailmap: prefer matching just based on commit emails) - #156135 (Remove most uses of def_id_to_node_id)
…ures, r=BoxyUwU docs(unstable-book): Document const generics features Relevant tracking issues: rust-lang#113521 rust-lang#132980 rust-lang#76560 rust-lang#151972 ## What Adds a high-level overview of 4 unstable features related to const generic exprs. ## Why While trying to learn about the current state of const generic exprs, I found it a bit too hard due to lack of documentation -- had to read through a bunch of tracking issues & look for PRs/examples in the repo just to understand what the feature is about. Moreover, given that there is a bunch of features with similarly-looking names, it was even more confusing. For that purpose, I also added cross-referencing across (directly or logically) related features. As a result, I decided to add some more context to the unstable book, so that new readers have an easier time than I had. ## Caveats I understand that the features are incomplete/experimental, so the docs are at risk of becoming stale, but the book entrypoint already has [a corresponding warning](https://doc.rust-lang.org/unstable-book/), so I guess it should be fine. Also, given that I did research myself, the examples provided might be not the best to showcase the feature -- happy to provide better examples, if you have suggestions. The examples provided are what "made the feature make sense" to me as an outsider, so there is a chance that they will be good for other external readers too, though. LLM use disclosue: an LLM was used for self-review only; research, coming up with examples, and writing is mine. Issues reported by LLM were fixed manually too. r? @BoxyUwU
…uwer Rollup of 12 pull requests Successful merges: - #155848 ([doc]: Revert `core::io::ErrorKind` doc changes) - #155855 (Remove unnecessary `get_unchecked`) - #155543 (docs(unstable-book): Document const generics features) - #155962 (`rustc`: `target_features`: allow for `cfg`-only stable `target_features`) - #156043 (c-variadic: gate `va_arg` on `c_variadic_experimental_arch`) - #156082 (Move tests associated types) - #156092 (Clean up `TyCtxt::needs_crate_hash` usage and rename it to `needs_hir_hash`.) - #156103 (Fix E0040 suggestion for explicit `Drop::drop` UFCS calls) - #156104 (Relax `T: Sized` bound on `try_as_dyn` / `try_as_dyn_mut`) - #156128 (.mailmap: prefer matching just based on commit emails) - #156135 (Remove most uses of def_id_to_node_id) - #156152 (Update books)
…ures, r=BoxyUwU docs(unstable-book): Document const generics features Relevant tracking issues: rust-lang#113521 rust-lang#132980 rust-lang#76560 rust-lang#151972 ## What Adds a high-level overview of 4 unstable features related to const generic exprs. ## Why While trying to learn about the current state of const generic exprs, I found it a bit too hard due to lack of documentation -- had to read through a bunch of tracking issues & look for PRs/examples in the repo just to understand what the feature is about. Moreover, given that there is a bunch of features with similarly-looking names, it was even more confusing. For that purpose, I also added cross-referencing across (directly or logically) related features. As a result, I decided to add some more context to the unstable book, so that new readers have an easier time than I had. ## Caveats I understand that the features are incomplete/experimental, so the docs are at risk of becoming stale, but the book entrypoint already has [a corresponding warning](https://doc.rust-lang.org/unstable-book/), so I guess it should be fine. Also, given that I did research myself, the examples provided might be not the best to showcase the feature -- happy to provide better examples, if you have suggestions. The examples provided are what "made the feature make sense" to me as an outsider, so there is a chance that they will be good for other external readers too, though. LLM use disclosue: an LLM was used for self-review only; research, coming up with examples, and writing is mine. Issues reported by LLM were fixed manually too. r? @BoxyUwU
Rollup of 16 pull requests Successful merges: - #155848 ([doc]: Revert `core::io::ErrorKind` doc changes) - #155855 (Remove unnecessary `get_unchecked`) - #155543 (docs(unstable-book): Document const generics features) - #155962 (`rustc`: `target_features`: allow for `cfg`-only stable `target_features`) - #156043 (c-variadic: gate `va_arg` on `c_variadic_experimental_arch`) - #156082 (Move tests associated types) - #156087 (Improve `&pin` reference-pattern suggestions) - #156092 (Clean up `TyCtxt::needs_crate_hash` usage and rename it to `needs_hir_hash`.) - #156103 (Fix E0040 suggestion for explicit `Drop::drop` UFCS calls) - #156104 (Relax `T: Sized` bound on `try_as_dyn` / `try_as_dyn_mut`) - #156122 (Add a `doc_cfg` regression test to ensure foreign types impls are working as expected) - #156128 (.mailmap: prefer matching just based on commit emails) - #156135 (Remove most uses of def_id_to_node_id) - #156152 (Update books) - #156154 (tests: mark import UI tests as check-pass) - #156162 (Update `browser-ui-test` version to `0.23.5`)
View all comments
Relevant tracking issues: #113521 #132980 #76560 #151972
What
Adds a high-level overview of 4 unstable features related to const generic exprs.
Why
While trying to learn about the current state of const generic exprs, I found it a bit too hard due to lack of documentation -- had to read through a bunch of tracking issues & look for PRs/examples in the repo just to understand what the feature is about.
Moreover, given that there is a bunch of features with similarly-looking names, it was even more confusing. For that purpose, I also added cross-referencing across (directly or logically) related features.
As a result, I decided to add some more context to the unstable book, so that new readers have an easier time than I had.
Caveats
I understand that the features are incomplete/experimental, so the docs are at risk of becoming stale, but the book entrypoint already has a corresponding warning, so I guess it should be fine.
Also, given that I did research myself, the examples provided might be not the best to showcase the feature -- happy to provide better examples, if you have suggestions. The examples provided are what "made the feature make sense" to me as an outsider, so there is a chance that they will be good for other external readers too, though.
LLM use disclosue: an LLM was used for self-review only; research, coming up with examples, and writing is mine. Issues reported by LLM were fixed manually too.
r? @BoxyUwU