# Removal of all unstable placement features

**URL:** <https://internals.rust-lang.org/t/removal-of-all-unstable-placement-features/7223>\
**Category:** announcements\
**Created:** [April 3, 2018, 10:15pm UTC](https://internals.rust-lang.org/t/removal-of-all-unstable-placement-features/7223 "2018-04-03T22:15:39Z")\
**Posts on this page:** 2\
**Page:** 2

<div class="post-metadata">

**Author:** ![arielb1](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/arielb1/32/3044_2.png) [@arielb1](https://internals.rust-lang.org/u/arielb1)\
**Post date:** [April 10, 2018, 9:32pm UTC](https://internals.rust-lang.org/t/removal-of-all-unstable-placement-features/7223/21 "2018-04-10T21:32:44Z")

</div>

So from my POV, the problem is that we promised RVO/NRVO, but never quite followed on that promise.

> [@kennytm](#):
>
> ```rust
> place &lt;- [$expr; $n]
> 
> ```
> 
> would expand to
> 
> ```rust
> for i in 0..$n {
> place[i] &lt;- $expr;
> }
> 
> ```

Isn't this a misoptimization for the current semantics of `ExprRepeat`, as it evaluates `$expr` multiple times? The correct version would be this:

```rust
if $n > 0 {
    place[0] = $expr;
    place[1..] = [place[0]; $n-1];
}

```

Maybe we should also have a variant of `ExprRepeat` that works with non-`Copy` but constexpr `$expr`.

> [@kennytm](#):
>
> I was thinking if it is possible to do a syntax-based transformation of the RHS at HIR→HAIR level to perform the proper lowering, e.g.

For years there was supposed to be a guaranteed MIR optimization that does exactly this, except also in a few more cases (e.g., NRVO). It just never happened to be implemented because nobody found the time for it.

---

<div class="post-metadata">

**Author:** ![aidanhs](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/aidanhs/32/499_2.png) [@aidanhs](https://internals.rust-lang.org/u/aidanhs)\
**Post date:** [March 25, 2019, 8:30am UTC](https://internals.rust-lang.org/t/removal-of-all-unstable-placement-features/7223/22 "2019-03-25T08:30:01Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

[Previous page](https://internals.rust-lang.org/t/removal-of-all-unstable-placement-features/7223.md?page=1)
