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

Additional bounds are required for const generics using associated constants #80976

Open
clarfonthey opened this issue Jan 13, 2021 · 2 comments
Labels
A-const-generics Area: const generics (parameters and arguments) A-diagnostics Area: Messages for errors, warnings, and lints F-generic_const_exprs `#![feature(generic_const_exprs)]` requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@clarfonthey
Copy link
Contributor

clarfonthey commented Jan 13, 2021

Example below. Based on the description in #76560, I'd expect to not be required to add [(); From::DIM]: and [(); To::DIM] bounds to Transform because the associated consts are inherent to the trait's definition and thus are public APIs.

#![feature(generic_const_exprs)]

trait Vector {
    type Scalar;
    const DIM: usize;
}

struct Transform<From, To>
where
    From: Vector,
    To: Vector<Scalar = From::Scalar>,
{
    columns: [[From::Scalar; From::DIM]; To::DIM],
}

(Playground)

@camelid camelid added A-const-generics Area: const generics (parameters and arguments) F-generic_const_exprs `#![feature(generic_const_exprs)]` F-const_generics `#![feature(const_generics)]` requires-nightly This issue requires a nightly compiler in some way. and removed F-generic_const_exprs `#![feature(generic_const_exprs)]` labels Jan 17, 2021
@camelid
Copy link
Member

camelid commented Jan 17, 2021

It seems const_evaluatable_checked is not required to repro? EDIT: actually it is required :)

@camelid camelid added the F-generic_const_exprs `#![feature(generic_const_exprs)]` label Jan 17, 2021
@lcnr lcnr added A-diagnostics Area: Messages for errors, warnings, and lints and removed F-const_generics `#![feature(const_generics)]` labels Jun 24, 2022
@lcnr
Copy link
Contributor

lcnr commented Jun 24, 2022

triaged in https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/.60F-generic_const_exprs.60.20triage/near/287323105, if we want const evaluatable bounds this error is expected (though with a better error message). Whether these bounds are needed is tracked in rust-lang/project-const-generics#41

@Noratrieb Noratrieb added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-generics Area: const generics (parameters and arguments) A-diagnostics Area: Messages for errors, warnings, and lints F-generic_const_exprs `#![feature(generic_const_exprs)]` requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants