rust-lang / rust-lang/rust

When a trait is missing items, there are many follow-up errors distracting from the root cause

Open
#125,603 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-diagnostics D-verbose E-needs-mcve T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

To reproduce, check out commit cdc509f7c09361466d543fc8311ce7066b10cc4f of rustc and remove this line:

https://github.com/rust-lang/rust/blob/7a5d814a047376223da9331061d9642dd33b3f9a/compiler/rustc_const_eval/src/const_eval/machine.rs#L375

I would expect some complaints about missing trait items. Those do show up, but they are drowned in tons of other errors like:

error[E0599]: the method `allocate` exists for struct `InterpCx<'_, '_, CompileTimeInterpreter<'_, '_>>`, but its trait bounds were not satisfied
   --> compiler/rustc_const_eval/src/util/check_validity_requirement.rs:53:10
    |
52  |       let allocated = cx
    |  _____________________-
53  | |         .allocate(ty, MemoryKind::Machine(crate::const_eval::MemoryKind::Heap))
    | |_________-^^^^^^^^
    |
   ::: compiler/rustc_const_eval/src/interpret/eval_context.rs:37:1
    |
37  |   pub struct InterpCx<'mir, 'tcx, M: Machine<'mir, 'tcx>> {
    |   ------------------------------------------------------- method `allocate` not found for this struct
    |
note: trait bound `{type error}: std::marker::Sized` was not satisfied
   --> compiler/rustc_const_eval/src/interpret/place.rs:386:24
    |
386 | impl<'mir, 'tcx: 'mir, Prov, M> InterpCx<'mir, 'tcx, M>
    |                        ^^^^     -----------------------
    |                        |
    |                        unsatisfied trait bound introduced here
help: consider relaxing the type parameter's implicit `Sized` bound
   --> compiler/rustc_const_eval/src/interpret/place.rs:386:28
    |
386 | impl<'mir, 'tcx: 'mir, Prov: ?Sized, M> InterpCx<'mir, 'tcx, M>
    |                            ++++++++

Seems like somewhere we are going on compiling too far, and then showing errors that have nothing to do with the root cause of the problem.

So far I have not managed to reproduce this with a smaller example.

Cc @oli-obk is this a consequence of your recent work to keep compiling in more cases?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Check out rustc commit cdc509f7c09361466d543fc8311ce7066b10cc4f and remove the referenced line in compiler/rustc_const_eval/src/const_eval/machine.rs. Reproduce the missing-trait-items case and inspect the diagnostics involving compiler/rustc_const_eval/src/util/check_validity_requirement.rs, interpret/eval_context.rs, and interpret/place.rs. Done should mean the root missing-item complaints are not obscured by unrelated follow-up errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.