Skip to content

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

Open

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.

Activity

  1. added
    D-verboseDiagnostics: Too much output caused by a single piece of incorrect code.
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Jul 10, 2021
  2. b-naber commented on Jan 4, 2022

    @b-naber
    Contributor

    @rustbot claim

  3. lcnr commented on Jun 24, 2022

    @lcnr
    ContributorAuthor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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