Skip to content

Commit

Permalink
const generics update
Browse files Browse the repository at this point in the history
  • Loading branch information
lcnr authored and jyn514 committed Sep 20, 2021
1 parent 1795756 commit 82d4c56
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
- [Generics and substitutions](./generics.md)
- [`TypeFolder` and `TypeFoldable`](./ty-fold.md)
- [Generic arguments](./generic_arguments.md)
- [Constants in the type system](./constants.md)
- [Type inference](./type-inference.md)
- [Trait solving](./traits/resolution.md)
- [Early and Late Bound Parameters](./early-late-bound.md)
Expand Down
8 changes: 4 additions & 4 deletions src/constants.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ with the two *additional* variants being `ConstKind::Value` and `ConstKind::Unev

## Unevaluated constants

*This section talks about what's happening with `feature(const_generics)` enabled.
*This section talks about what's happening with `feature(generic_const_exprs)` enabled.
On stable we do not yet supply any generic parameters to anonymous constants,
avoiding most of the issues mentioned here.*

Unless a constant is either a simple literal, e.g. `[u8; 3]` or `foo::<{ 'c' }>()`,
or a generic parameter, e.g. `[u8; N]`, converting a constant to its [`ty::Const`] representation
returns an unevaluated constant. Even fully concrete constants which do not depend on a
generic parameter are not evaluated right away.
returns an unevaluated constant. Even fully concrete constants which do not depend on
generic parameters are not evaluated right away.

We do not eagerly evaluate constant as they can be used in the `where`-clauses of their
parent item, for example:

```rust
#[feature(const_generics, const_evaluatable_checked)]
#[feature(generic_const_exprs)]
fn foo<T: Trait>()
where
[u8; <T as Trait>::ASSOC + 1]: SomeOtherTrait,
Expand Down

0 comments on commit 82d4c56

Please sign in to comment.