Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vec! macro should use box [...] instead of Box::new([...]). #28950

Closed
eddyb opened this issue Oct 10, 2015 · 3 comments
Closed

vec! macro should use box [...] instead of Box::new([...]). #28950

eddyb opened this issue Oct 10, 2015 · 3 comments

Comments

@eddyb
Copy link
Member

eddyb commented Oct 10, 2015

There's no reason to have the potentially unoptimizable inefficiency in vec!.
It's impossible to reoder side-effects (which is why we want placement syntax), so vec![expressions, containing, side, effects] will end up in a copy from the stack to the heap.

I guess it's not as bad as I thought given that vec![x; N] goes through a more optimal route so you can't cause a stack overflow with it.

@apasel422
Copy link
Contributor

Wouldn't this require #![feature(box_syntax)] in all crates that use the macro?

@eddyb
Copy link
Member Author

eddyb commented Oct 11, 2015

Not at all, formatting and TLS macros already use unstable features in their implementation.
There was some work put into making this possible, we might as well make use of it.

@apasel422
Copy link
Contributor

Ah, I see. I'm looking into implementing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants