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

Const generics: Bounds like T: Foo<{ value }> don't work #71986

Closed
jplatte opened this issue May 7, 2020 · 2 comments · Fixed by #71973
Closed

Const generics: Bounds like T: Foo<{ value }> don't work #71986

jplatte opened this issue May 7, 2020 · 2 comments · Fixed by #71973
Labels
A-const-generics Area: const generics (parameters and arguments) A-lazy-normalization Area: Lazy normalization (tracking issue: #60471) C-bug Category: This is a bug. F-const_generics `#![feature(const_generics)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jplatte
Copy link
Contributor

jplatte commented May 7, 2020

This is probably due to lazy normalization not being here yet, but I don't find any issues for this specifically so maybe this is a good additional test case for #71973 or a later PR?

#![feature(const_generics)]

trait Foo<const B: bool> {}
fn bar<T: Foo<{ true }>>() {}

I wouldn't even expect this to work necessarily, since the equivalent thing with an associated constant instead of a const generic argument produces cannot constrain an associated constant to a value (although without an error code 🙁).

@jplatte
Copy link
Contributor Author

jplatte commented May 7, 2020

Ah, nevermind, the linked PR already has a very similar test case. I guess this still tracks an issue until that PR has been merged, but I will close afterwards.

@lcnr lcnr added A-const-generics Area: const generics (parameters and arguments) A-lazy-normalization Area: Lazy normalization (tracking issue: #60471) C-bug Category: This is a bug. F-const_generics `#![feature(const_generics)]` labels May 7, 2020
@lcnr
Copy link
Contributor

lcnr commented May 7, 2020

Its novel enough to be added as an additional test 👍

We still need a lot of tests for const generics if we want to ever make them stable.

@jonas-schievink jonas-schievink added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label May 14, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue May 18, 2020
Lazy normalization of constants (Reprise)

Continuation of rust-lang#67890 by @Skinny121.

Initial implementation of rust-lang#60471 for constants.

Perform normalization/evaluation of constants lazily, which is known as lazy normalization. Lazy normalization is only enabled when using `#![feature(lazy_normalization_consts)]`, by default constants are still evaluated eagerly as there are currently.

Lazy normalization of constants is achieved with a new ConstEquate predicate which type inferences uses to delay checking whether constants are equal to each other until later, avoiding cycle errors.

Note this doesn't allow the use of generics within repeat count expressions as that is still evaluated during conversion to mir. There are also quite a few other known problems with lazy normalization which will be fixed in future PRs.

r? @nikomatsakis

fixes rust-lang#71922, fixes rust-lang#71986
@bors bors closed this as completed in c6030c9 May 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-generics Area: const generics (parameters and arguments) A-lazy-normalization Area: Lazy normalization (tracking issue: #60471) C-bug Category: This is a bug. F-const_generics `#![feature(const_generics)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants