Skip to content

don't eagerly emit errors when evaluating constants during selection #87001

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

Open
lcnr opened this issue Jul 9, 2021 · 2 comments
Open

don't eagerly emit errors when evaluating constants during selection #87001

lcnr opened this issue Jul 9, 2021 · 2 comments
Assignees
Labels
A-const-generics Area: const generics (parameters and arguments) C-bug Category: This is a bug. D-verbose Diagnostics: Too much output caused by a single piece of incorrect code. F-generic_const_exprs `#![feature(generic_const_exprs)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@lcnr
Copy link
Contributor

lcnr commented Jul 9, 2021

#![feature(const_generics, const_evaluatable_checked)]

struct Bar<const N: usize>;
trait Foo {}

impl<const N: usize> Foo for Bar<N> where [u8; N - 1]:  {}

impl Foo for Bar<0> {}

currently errors with

error[E0080]: evaluation of `<Bar<0_usize> as Foo>::{constant#0}` failed
 --> src/lib.rs:6:48
  |
6 | impl<const N: usize> Foo for Bar<N> where [u8; N - 1]:  {}
  |                                                ^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow

while checking whether the two impls overlap during coherence. Failing to evaluate a generic constant in the where clauses should not eagerly cause an error if it happens during selection. See #81339 for how to fix this issue, I did not have the capacity to finish that PR.

@lcnr lcnr added C-bug Category: This is a bug. F-generic_const_exprs `#![feature(generic_const_exprs)]` labels Jul 9, 2021
@jonas-schievink jonas-schievink added the A-const-generics Area: const generics (parameters and arguments) label Jul 9, 2021
@estebank estebank added D-verbose Diagnostics: Too much output caused by a single piece of incorrect code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 10, 2021
@b-naber
Copy link
Contributor

b-naber commented Jan 4, 2022

@rustbot claim

@lcnr
Copy link
Contributor Author

lcnr commented Jun 24, 2022

(tracked in rust-lang/project-const-generics#25)

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) C-bug Category: This is a bug. D-verbose Diagnostics: Too much output caused by a single piece of incorrect code. F-generic_const_exprs `#![feature(generic_const_exprs)]` 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