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

Post lazy normalization for consts cleanup (#71973) #72129

Closed
lcnr opened this issue May 12, 2020 · 4 comments
Closed

Post lazy normalization for consts cleanup (#71973) #72129

lcnr opened this issue May 12, 2020 · 4 comments
Labels
A-const-generics Area: const generics (parameters and arguments) A-lazy-normalization Area: Lazy normalization (tracking issue: #60471) F-generic_const_exprs `#![feature(generic_const_exprs)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@lcnr
Copy link
Contributor

lcnr commented May 12, 2020

While #71973 implements lazy normalization for constants,
there are still some bugs we need to deal with afterwards.

This issue is a collection of things not explicitly mentioned with FIXME(lazy_normalization_consts) so we don't forget anything.

@lcnr
Copy link
Contributor Author

lcnr commented May 12, 2020

done

Add src/test/ui/const-generics/issues/issue-69654.rs back in, which causes an unrelated stack overflow once lazy normalization is enabled.

#![feature(const_generics)]
#![allow(incomplete_features)]

trait Bar<T> {}
impl<T> Bar<T> for [u8; T] {}
//~^ ERROR expected value, found type parameter `T`

struct Foo<const N: usize> {}
impl<const N: usize> Foo<N>
where
    [u8; N]: Bar<[(); N]>,
{
    fn foo() {}
}

fn main() {
    Foo::foo();
}

Also add the following similar test, which should compile but also causes a stack overflow.

// run-pass
#![feature(const_generics)]
#![allow(incomplete_features, unused_braces)]

trait Bar<T> {}
impl<T> Bar<T> for [u8; {7}] {}

struct Foo<const N: usize> {}
impl<const N: usize> Foo<N>
where
    [u8; N]: Bar<[(); N]>,
{
    fn foo() {}
}

fn main() {
    Foo::foo();
}

@lcnr lcnr added A-const-generics Area: const generics (parameters and arguments) A-lazy-normalization Area: Lazy normalization (tracking issue: #60471) F-const_generics `#![feature(const_generics)]` labels May 12, 2020
@lcnr
Copy link
Contributor Author

lcnr commented May 12, 2020

Taken from a comment by @nikomatsakis

// run-pass
#![feature(const_generics)]
#![feature(lazy_normalization_consts)]
#![allow(incomplete_features)]

// try to devise a test for higher-ranked case
//
// e.g., for<'a> EqZero<<() as Zero<'a>::C>>
//
//

trait EqZero<const C: usize> { }

impl EqZero<0> for () { }

trait Zero<'a> {
    const C: usize;
}

impl<'a> Zero<'a> for () {
    const C: usize = 0;
}

fn test_me<T>()
where for<'a> T: EqZero<{<() as Zero<'a>>::C}>
{
}

fn main() {
    test_me::<()>();
}

However, that test continues to ICE even with these changes, due to some assertion in type checking. So maybe it's fine, and we should just move that test to a follow-up issue. Anyway, this code as it is written here is the code we want eventually -- we just have to reconcile some details of the leak-check first.

@jonas-schievink jonas-schievink added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label May 12, 2020
@varkor
Copy link
Member

varkor commented Oct 2, 2020

Linking the relevant Zulip conversation here, which is helpful.

@BoxyUwU BoxyUwU added F-generic_const_exprs `#![feature(generic_const_exprs)]` and removed F-lazy_normalization_consts F-const_generics `#![feature(const_generics)]` labels Sep 5, 2021
@lcnr lcnr closed this as completed Jun 24, 2022
@lcnr
Copy link
Contributor Author

lcnr commented Jun 24, 2022

the remaining work is tracked in different issues, most notably rust-lang/project-const-generics#35

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) F-generic_const_exprs `#![feature(generic_const_exprs)]` 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.

4 participants