rust-lang / rust-lang/rust

We allow infinitely expanding types behind pointer indirection

Open
#158,908 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

I-types-nominated needs-triage
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

This compiles

struct Foo<T> {
    y: T,
    x: Option<*const Foo<(T,)>>,
}

fn main() {
    let x = Foo {
        y: 1u32,
        x: None,
    };
}

It feels quite brittle however, e.g. the following does not:

struct Foo<T> {
    y: T,
    // We recur due to drop checking
    x: Option<Box<Foo<(T,)>>>,
}

fn main() {
    let x = Foo {
        y: 1u32,
        x: None,
    };
}

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 compiling the two Rust examples in the issue and compare the behavior of the raw-pointer and Box forms. Investigate the compiler's handling of recursive type expansion and drop checking; done means the accepted and rejected cases have a documented, consistent rationale or a targeted fix with regression coverage.

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
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.