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

mention WithOptConstParam #1346

Merged
merged 1 commit into from
May 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/constants.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ Constants used in the type system are represented as [`ty::Const`].
The variants of their [`ty::ConstKind`] mostly mirror the variants of [`ty::TyKind`]
with the two *additional* variants being `ConstKind::Value` and `ConstKind::Unevaluated`.

## `WithOptConstParam` and dealing with the query system

To typecheck constants used in the type system, we have to know their expected type.
For const arguments in type dependent paths, e.g. `x.foo::<{ 3 + 4 }>()`, we don't know
the expected type for `{ 3 + 4 }` until we are typechecking the containing function.

As we may however have to evaluate that constant during this typecheck, we would get a cycle error.
For more details, you can look at [this document](https://hackmd.io/@rust-const-generics/Bk5GHW-Iq).

## Unevaluated constants

Expand Down