Skip to content

Commit 2e4a0e3

Browse files
camelidBoxyUwU
andcommitted
Clarify docs explaining purpose of ConstArg
Co-authored-by: Boxy <[email protected]>
1 parent 37ed7a4 commit 2e4a0e3

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

compiler/rustc_hir/src/hir.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -228,17 +228,16 @@ impl<'hir> PathSegment<'hir> {
228228
}
229229
}
230230

231-
/// A constant that enters the type system, e.g. through const generics or even
232-
/// array lengths.
231+
/// A constant that enters the type system, used for arguments to const generics (e.g. array lengths).
233232
///
234-
/// These are distinct from [`AnonConst`] in part because with the plan for
235-
/// `min_generic_const_args`, arbitrary anonymous constants (like `Foo<{N + 1}>`)
236-
/// will *not* be allowed to use generic parameters. Instead, it will be necessary
237-
/// to add indirection using a free constant that itself has const parameters.
233+
/// These are distinct from [`AnonConst`] as anon consts in the type system are not allowed
234+
/// to use any generic parameters, therefore we must represent `N` differently. Additionally
235+
/// future designs for supporting generic parameters in const arguments will likely not use
236+
/// an anon const based design.
238237
///
239238
/// So, `ConstArg` (specifically, [`ConstArgKind`]) distinguishes between const args
240239
/// that are [just paths](ConstArgKind::Path) (currently just bare const params)
241-
/// versus const args that are literals or have arbitrary computations (e.g., `{ 1 + 3}`).
240+
/// versus const args that are literals or have arbitrary computations (e.g., `{ 1 + 3 }`).
242241
#[derive(Clone, Copy, Debug, HashStable_Generic)]
243242
pub struct ConstArg<'hir> {
244243
#[stable_hasher(ignore)]

0 commit comments

Comments
 (0)