Skip to content

generic_const_exprs does not work properly with const/type param defaults #106994

Open
@BoxyUwU

Description

@BoxyUwU

In order to make feature(generic_const_exprs) not completely broken when used with feature(const_generics_defaults), #86580 was landed. From the description of the PR:

This PR doesn't handle the predicates of the const so

trait Foo<const N: usize> { const Assoc: usize; }
pub struct Bar<const N: usize = { <()>::Assoc }> where (): Foo<N>;

Resolves to <() as Foo<N>>::Assoc which can allow for using fwd declared params indirectly.

trait Foo<const N: usize> {}
struct Bar<const N: usize = { 2 + 3 }> where (): Foo<N>;

This code also ICEs under this PR because instantiating the default's predicates causes an ICE as predicates_of contains predicates with fwd declared params

because of this these two features are still pretty incompatible with eachother. This issue tracks this as there have been a large volume of issues that are all about which makes looking through F-generic_const-exprs issues harder than it needs to be.

It was previously attempted to fix this in #106847 but that was closed:

I don't feel super comfortable merging more hacks to make generic_const_exprs + const_generics_defaults work in the presence of each other. #86580 alone was already rather hacky and I think this PR just makes it way too much to be reasonable. It's also unclear to me whether this is going to interfere with fixing some of the other issues we have with const generics and I don't want to make that any harder than necessary.

feature(generic_const_exprs) is an incomplete feature (both literally and according to the incomplete_features lint), having it in a broken state because we are not currently in a good position to properly fix this seems fine to me. Thanks for making the PR anyway but I expect this issue will stay open until we make a lot more progress on generic_const_exprs 😅

duplicate issues

When this is fixed the following should be revisited and checked to make sure everything works as intended:

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-genericsArea: const generics (parameters and arguments)C-bugCategory: This is a bug.F-generic_const_exprs`#![feature(generic_const_exprs)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-blockedStatus: Blocked on something else such as an RFC or other implementation work.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-incomplete-featuresThis issue requires the use of incomplete features.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions