Skip to content

Experiment proposal: In-place initialization #336

Open
@compiler-errors

Description

@compiler-errors

Experiment: In-place initialization

A few weeks ago, @Darksonn authored https://hackmd.io/@aliceryhl/BJutRcPblx that proposes the lang-ification of the pin-init crate, and how it can be used to enable and simplify some major use-cases in the language. The motivation in that doc is pretty thorough, so I won't copy it over here and I encourage you to read it to understand the background.

I think that the design, modulo syntax, is clear enough that it would be worthwhile to experiment with the implementation in the compiler. This is particularly important because I think we'll both learn a lot about the design from the implementation in the compiler, and because the implementation in the compiler will likely need to go through a few iterations1 that can happen in parallel with any evolution of the syntax.

I'm opening up a lightweight experiment proposal here in the T-lang repo just for bookkeeping. I wasn't totally sure whether to open this in the lang team repo as an experiment proposal, or on the r-l/r repo as a feature gate tracker. But since no PRs have been opened up yet, I wanted to open this here first. I assume a feature gate issue in the compiler will follow soon.

After syncing this morning, @dingxiangfei2009 is first planning on opening a PR to add the trait Init<T> to the standard library for experimentation, and then in parallel @dingxiangfei2009 will be working on the implementation of user-written init Struct { .. } expressions, and I'll be working on the feature's interaction with AFIDT (async fn in dyn trait, cc rust-lang/rust#133119).

As is true with all lang experiments, this feature is subject to change and removal with no guarantees, and I assume an RFC will follow in due time, hopefully better informed due to experimentation in the compiler impl.


Some relevant contacts:

Design: @Darksonn @y86-dev
Implementation: @dingxiangfei2009, @compiler-errors
Compiler team liaison/reviewer: @compiler-errors
Lang liaison: @joshtriplett

If I've missed cc'ing someone, let me know. If you don't want to be recorded here, let me know too.

Footnotes

  1. Adding a new closure-ish type to the compiler requires touching tons of places in the compiler, and IMO it's worth surfacing all of the interactions sooner than later!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions