Skip to content

Assoc const equality bounds aren't taken into consideration when normalizing const projections #120905

Open
@fmease

Description

@fmease

For example, I expected the following code to succeed compilation:

#![feature(generic_const_exprs)]
#![feature(associated_const_equality)]

trait Trait {
    const C: usize;
}

fn f<T: Trait<C = 1>>()
where
    [(); T::C]:
{
    let _: [(); T::C] = [()];
}

Since (I'm pretty sure that) the ParamEnv contains the projection predicate <T as Trait>::C == 1, the const projection <T as Trait>::C inside the function body should be able to get normalized to 1. That however doesn't seem to happen:

error[E0308]: mismatched types
  --> src/lib.rs:12:25
   |
12 |     let _: [(); T::C] = [()];
   |                         ^^^^ expected `T::C`, found `1`
   |
   = note: expected constant `T::C`
              found constant `1`

Metadata

Metadata

Assignees

Labels

A-trait-systemArea: Trait systemC-bugCategory: This is a bug.F-associated_const_equality`#![feature(associated_const_equality)]`F-generic_const_exprs`#![feature(generic_const_exprs)]`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