For box EXPR
/Box::new
, that may be possible, but it would have to be a rather ad-hoc, magical attribute. And it would presumably come with some weird rules for the implementation of new
to guarantee that the optimization actually applies (remember that this is intended to apply not just to Box
but also to Rc
, Arc
, and third-party types). So I doubt whether that feature would actually be easier to implement or less of an addition to the language. Then there’s the fact that box EXPR
is simple more ergonomic, and nicely matches box
patterns which are desirable too.
With “placement in” syntax, e.g. as replacement for (edit: Vec::new
Vec::push
, sorry for the confusion), it’s not really possible to avoid new syntax, see this old FAQ (particularly question #4).