Skip to content

evaluation error hides "impl item missing" error #98629

Closed

Description

@lcnr
trait Trait {
    const N: usize;
}

impl Trait for i32 {}

fn f()
where
    [(); <i32 as Trait>::N]:,
{}

fn main() {}

results in

error[[E0080]](https://doc.rust-lang.org/nightly/error-index.html#E0080): evaluation of constant value failed
 --> src/main.rs:9:10
  |
9 |     [(); <i32 as Trait>::N]:,
  |          ^^^^^^^^^^^^^^^^^ referenced constant has errors

without showing that N is missing in the trait impl.

Taken from the comment by @carado in #74713 (comment)

Activity

  1. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    on Jun 28, 2022
  2. Rageking8 commented on Jun 28, 2022

    @Rageking8
    Contributor

    @rustbot label T-compiler

  3. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Jun 28, 2022
  4. Rageking8 commented on Jun 28, 2022

    @Rageking8
    Contributor

    Possible regression from stable to nightly. (Tested in Rust Playground)

    Both Stable 1.61.0 and 1.62.0-beta.7 (2022-06-26 747075d) result in this error :

    error[E0046]: not all trait items implemented, missing: `N`
     --> src/main.rs:5:1
      |
    2 |     const N: usize;
      |     --------------- `N` from trait
    ...
    5 | impl Trait for i32 {}
      | ^^^^^^^^^^^^^^^^^^ missing `N` in implementation
    
    For more information about this error, try `rustc --explain E0046`.
    

    However on Nightly version: 1.64.0-nightly (2022-06-27 2f3ddd9)

    This is the error :

    error[E0080]: evaluation of constant value failed
     --> src/main.rs:9:10
      |
    9 |     [(); <i32 as Trait>::N]:,
      |          ^^^^^^^^^^^^^^^^^ referenced constant has errors
    
    For more information about this error, try `rustc --explain E0080`.
    
  5. Rageking8 commented on Jun 28, 2022

    @Rageking8
    Contributor

    @rustbot label regression-from-stable-to-nightly

  6. added
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Jun 28, 2022
  7. apiraino commented on Jun 28, 2022

    @apiraino
    Contributor

    if my bisection is correct, commit 1f34da9 seems to trigger this. In #96591 cc @b-naber

    searched nightlies: from nightly-2022-04-01 to nightly-2022-06-28
    regressed nightly: nightly-2022-06-15
    searched commits: from ca122c7 to 1f34da9
    regressed commit: 1f34da9

    bisected with cargo-bisect-rustc v0.6.0

    Host triple: x86_64-unknown-linux-gnu
    Reproduce with:

    cargo bisect-rustc --start=2022-04-01 --script=./test.sh 
    
    $ cat test.sh 
    #!/bin/bash
    cargo check 2>&1 | grep "from trait"
  8. self-assigned this
    on Jun 30, 2022
  9. apiraino commented on Jun 30, 2022

    @apiraino
    Contributor

    WG-prioritization assigning priority (Zulip discussion).

    The missing diagnostic message in this case can possibly make fixing the code quite confusing. Thanks @TaKO8Ki for offering some help here :)

    @rustbot label -I-prioritize +P-high

  10. added
    P-highHigh priority
    and removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Jun 30, 2022
  11. compiler-errors commented on Jul 15, 2022

    @compiler-errors
    Contributor

    Hi @TaKO8Ki, are you working on this issue? I've been keeping tabs on this one for a bit and I decided to look into it since it's been a few weeks.

    I think I may have found a bug in the way that we resolve const items and I would like to put up a PR, unless you've already found a solution. 😸

    Also, marking this as a regression from stable to beta, since beta cutoff has happened since this issue was filed, I think.

  12. added a commit that references this issue on Jul 20, 2022
    19c1d52
  13. added 4 commits that reference this issue on Jul 21, 2022
    fa92ce8
    f4506a2
    ca16fea
    5d54e8d
  14. added 2 commits that reference this issue on Jul 23, 2022
    d976e3a
    3648dd5
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)A-diagnosticsArea: Messages for errors, warnings, and lintsP-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions