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

Stabilizing a subset of const generics #37

Closed
withoutboats opened this issue Jul 16, 2020 · 4 comments
Closed

Stabilizing a subset of const generics #37

withoutboats opened this issue Jul 16, 2020 · 4 comments
Labels
meeting-proposal Proposal for a lang team design meeting meeting-scheduled Lang team design meeting that has a scheduled date T-lang

Comments

@withoutboats
Copy link

Summary

I want to propose that we get a subset const generics on track to stabilization in the near future. We should have a meeting to discuss the specifics and attempt to achieve consensus on this plan.

Background reading

About this issue

This issue corresponds to a lang-team design meeting proposal. It corresponds
to a possible topic of discussion that may be scheduled for deeper discussion
during one of our design meetings.

@nikomatsakis
Copy link
Contributor

As discussed on Zulip, we are thinking of doing this meeting this week, July 22 -- @withoutboats can you confirm availability for that slot?

@withoutboats
Copy link
Author

Yes I plan to attend.

@nikomatsakis
Copy link
Contributor

Scheduled for July 22 design meeting.

@nikomatsakis nikomatsakis added the meeting-scheduled Lang team design meeting that has a scheduled date label Jul 20, 2020
@nikomatsakis
Copy link
Contributor

Minutes and recording are available: https://github.com/rust-lang/lang-team/blob/master/design-meeting-minutes/2020-07-22-Const-generics-MVP.md

bors added a commit to rust-lang-ci/rust that referenced this issue Aug 8, 2020
Implement the `min_const_generics` feature gate

Implements both rust-lang/lang-team#37 and rust-lang/compiler-team#332.

Adds the new feature gate `#![feature(min_const_generics)]`.
This feature gate adds the following limitations to using const generics:
- generic parameters must only be used in types if they are trivial. (either `N` or `{ N }`)
- generic parameters must be either integers, `bool` or `char`.

We do allow arbitrary expressions in associated consts though, meaning that the following is allowed,
even if `<[u8; 0] as Foo>::ASSOC` is not const evaluatable.
```rust
trait Foo {
    const ASSOC: usize;
}

impl<const N: usize> Foo for [u8; N] {
    const ASSOC: usize = 64 / N;
}
```

r? @varkor cc @eddyb @withoutboats
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
meeting-proposal Proposal for a lang team design meeting meeting-scheduled Lang team design meeting that has a scheduled date T-lang
Projects
Status: No status
Development

No branches or pull requests

2 participants