Skip to content

mGCA: We don't properly check associated const bindings for well-formedness #151642

@fmease

Description

@fmease

Uplifted from #150843 (comment), #150843 (comment). Follow links for further details. Credits to @BoxyUwU.


Example reproducers:

RHS is a const param.

//@ known-bug: unknown
//@ check-pass

#![feature(min_generic_const_args)]
#![expect(incomplete_features)]

trait Trait { #[type_const] const CT: bool; }

fn f<const N: i32>(_: impl Trait<CT = { N }>) {} // FIXME: this should yield a type mismatch (`bool` v `i32`)

RHS is a const param.

//@ known-bug: unknown
//@ check-pass

#![feature(min_generic_const_args)]
#![expect(incomplete_features)]

trait Trait { #[type_const] const CT: bool; }

fn f<const N: i32>() {
    let _: dyn Trait<CT = { N }>; // FIXME: this should yield a type mismatch (`bool` v `i32`)
}

RHS is a (normalizable) const projection (that doesn't contain any generic params).

//@ known-bug: unknown
//@ check-pass

#![feature(min_generic_const_args)]
#![expect(incomplete_features)]

trait Trait { #[type_const] const CT: bool; }

trait Bound { #[type_const] const N: u32; }
impl Bound for () { #[type_const] const N: u32 = 0; }

fn f() { let _: dyn Trait<CT = { <() as Bound>::N }>; } // FIXME
fn g(_: impl Trait<CT = { <() as Bound>::N }>) {} // FIXME

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.F-min_generic_const_args`#![feature(min_generic_const_args)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.

Type

No type

Projects

Status

To Do

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions