diff options
| author | Noah Lev <camelidcamel@gmail.com> | 2024-07-17 20:07:50 -0700 |
|---|---|---|
| committer | Noah Lev <camelidcamel@gmail.com> | 2024-07-17 20:31:36 -0700 |
| commit | 2e4a0e37e68beded4bdc473ecd8e94899e2eccc2 (patch) | |
| tree | 7db28cc70da7471703221f9449cab0eb31e55fbb | |
| parent | 37ed7a4438a24bcbe13986c82f193fd8e8d88221 (diff) | |
| download | rust-2e4a0e37e68beded4bdc473ecd8e94899e2eccc2.tar.gz rust-2e4a0e37e68beded4bdc473ecd8e94899e2eccc2.zip | |
Clarify docs explaining purpose of `ConstArg`
Co-authored-by: Boxy <rust@boxyuwu.dev>
| -rw-r--r-- | compiler/rustc_hir/src/hir.rs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index cd6e1bce350..bf773f2d487 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -228,17 +228,16 @@ impl<'hir> PathSegment<'hir> { } } -/// A constant that enters the type system, e.g. through const generics or even -/// array lengths. +/// A constant that enters the type system, used for arguments to const generics (e.g. array lengths). /// -/// These are distinct from [`AnonConst`] in part because with the plan for -/// `min_generic_const_args`, arbitrary anonymous constants (like `Foo<{N + 1}>`) -/// will *not* be allowed to use generic parameters. Instead, it will be necessary -/// to add indirection using a free constant that itself has const parameters. +/// These are distinct from [`AnonConst`] as anon consts in the type system are not allowed +/// to use any generic parameters, therefore we must represent `N` differently. Additionally +/// future designs for supporting generic parameters in const arguments will likely not use +/// an anon const based design. /// /// So, `ConstArg` (specifically, [`ConstArgKind`]) distinguishes between const args /// that are [just paths](ConstArgKind::Path) (currently just bare const params) -/// versus const args that are literals or have arbitrary computations (e.g., `{ 1 + 3}`). +/// versus const args that are literals or have arbitrary computations (e.g., `{ 1 + 3 }`). #[derive(Clone, Copy, Debug, HashStable_Generic)] pub struct ConstArg<'hir> { #[stable_hasher(ignore)] |
