Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
fmease opened this issue Feb 11, 2024 · 0 comments
Labels
A-traits Area: Trait system C-bug Category: This is a bug. F-associated_const_equality `#![feature(associated_const_equality)]` F-generic_const_exprs `#![feature(generic_const_exprs)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue.

Comments

@fmease
Copy link
Member

fmease commented Feb 11, 2024

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`
@fmease fmease added A-traits Area: Trait system T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. T-types Relevant to the types team, which will review and decide on the PR/issue. F-associated_const_equality `#![feature(associated_const_equality)]` labels Feb 11, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 11, 2024
@fmease fmease removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 11, 2024
@fmease fmease changed the title Assoc const equality bounds inside the ParamEnv aren't taken into consideration during the normalization of const projections Assoc const equality bounds aren't taken into consideration for the normalization of const projections Feb 11, 2024
@fmease fmease changed the title Assoc const equality bounds aren't taken into consideration for the normalization of const projections Assoc const equality bounds aren't taken into consideration when normalizing const projections Feb 11, 2024
@fmease fmease added the F-generic_const_exprs `#![feature(generic_const_exprs)]` label Feb 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-traits Area: Trait system C-bug Category: This is a bug. F-associated_const_equality `#![feature(associated_const_equality)]` F-generic_const_exprs `#![feature(generic_const_exprs)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants