Skip to content

Commit 4ca8504

Browse files
authored
mention WithOptConstParam (rust-lang#1346)
1 parent e0bb752 commit 4ca8504

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Diff for: src/doc/rustc-dev-guide/src/constants.md

+8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ Constants used in the type system are represented as [`ty::Const`].
44
The variants of their [`ty::ConstKind`] mostly mirror the variants of [`ty::TyKind`]
55
with the two *additional* variants being `ConstKind::Value` and `ConstKind::Unevaluated`.
66

7+
## `WithOptConstParam` and dealing with the query system
8+
9+
To typecheck constants used in the type system, we have to know their expected type.
10+
For const arguments in type dependent paths, e.g. `x.foo::<{ 3 + 4 }>()`, we don't know
11+
the expected type for `{ 3 + 4 }` until we are typechecking the containing function.
12+
13+
As we may however have to evaluate that constant during this typecheck, we would get a cycle error.
14+
For more details, you can look at [this document](https://hackmd.io/@rust-const-generics/Bk5GHW-Iq).
715

816
## Unevaluated constants
917

0 commit comments

Comments
 (0)