Skip to content

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

Open
@lcnr

Description

@lcnr
#![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.

Metadata

Metadata

Assignees

Labels

A-const-genericsArea: const generics (parameters and arguments)C-bugCategory: This is a bug.D-verboseDiagnostics: Too much output caused by a single piece of incorrect code.F-generic_const_exprs`#![feature(generic_const_exprs)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions