Skip to content

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

Closed

Description

@lcnr

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.

Activity

  1. lcnr commented on May 12, 2020

    @lcnr
    ContributorAuthor

    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();
    }
  2. added
    A-const-genericsArea: const generics (parameters and arguments)
    A-lazy-normalizationArea: Lazy normalization (tracking issue: #60471)
    on May 12, 2020
  3. lcnr commented on May 12, 2020

    @lcnr
    ContributorAuthor

    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.

  4. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on May 12, 2020
  5. varkor commented on Oct 2, 2020

    @varkor
    Contributor

    Linking the relevant Zulip conversation here, which is helpful.

  6. lcnr commented on Jun 24, 2022

    @lcnr
    ContributorAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-genericsArea: const generics (parameters and arguments)A-lazy-normalizationArea: Lazy normalization (tracking issue: #60471)F-generic_const_exprs`#![feature(generic_const_exprs)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions