rust-lang / rust-lang/rust

Error for `for let mut v = vec![]; v.push(v);` ‒ "error[E0275]: overflow assigning `Vec<_>` to `_`" ‒ seems poor

Open
#149,464 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-diagnostics T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Code
fn main() {
    let mut v = vec![];
    v.push(v);
}
Current output
error[E0275]: overflow assigning `Vec<_>` to `_`
 --> src/main.rs:3:12
  |
3 |     v.push(v);
  |            ^

For more information about this error, try `rustc --explain E0275`.
Desired output

"Vec<_> would appear in its own signature"? "Self-referential type"? idk

Rationale and extra context

It feels really circumferential to render "type of v depends on itself" as "can't reify infinite-depth type deduction tree with finite stack". I think.

Other cases

Rust Version
$ rustc +nightly --version --verbose
rustc 1.93.0-nightly (cc3eee7fb 2025-11-28)
binary: rustc
commit-hash: cc3eee7fbe17ea4b7238531cb97e1b7b8bd6afce
commit-date: 2025-11-28
host: x86_64-unknown-linux-gnu
release: 1.93.0-nightly
LLVM version: 21.1.5
Anything else?

No response

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

Start by reproducing the example in src/main.rs with the reported rustc nightly version and inspect how the E0275 diagnostic is produced. Compare the current overflow message with the requested self-referential-type explanation; done means the diagnostic clearly explains why v cannot contain itself and the existing reproduction is covered by an appropriate compiler test.

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.