Skip to content

Defaulted const generic parameters no longer have the const arg's type checked #139643

Description

@BoxyUwU

Code

I tried this code:

struct Foo<const N: u32, const M: u64 = N>;

I expected to see this happen: It fail to compile like it uised to

Instead, this happened: it compile :>

Probably regressed in #125915 where we started lowering const arguments to ConstArgKind::Path instead of ConstArgKind::Anon so there is no longer implicitly an anon const with an expected type of u64 with an expr typed as u32.

We could probably special case handling of types of defaulted const generics in wfcheck to be done even when generics are involved. Or just accept this as working code which is consistent with things like struct Foo<T, U = <T as Iterator>::Item>(T, U); 🤷‍♀ would need a types fcp for that tho

I don't believe this to be a soundness bug

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-const-genericsArea: const generics (parameters and arguments)C-bugCategory: This is a bug.F-const_generics_defaults`#![feature(const_generics_defaults)]`P-lowLow priorityT-typesRelevant to the types team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions