-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Use box
syntax in vec!
macro
#31797
Use box
syntax in vec!
macro
#31797
Conversation
r? @alexcrichton There might be a reason this wasn't done yet. |
Hm, I think that there's no reason to not do this. I don't think there's anything visible that can be relied upon by using cc @rust-lang/libs |
I'm on board - this seems like exactly the kind of thing we added |
Mind adding a test that would overflow the default stack with the old implementation, and force it to be compiled with no optimizations? |
@eddyb Would something like this suffice? #![feature(box_syntax)]
const LEN: usize = 1 << 15;
use std::thread::Builder;
fn main() {
assert!(Builder::new().stack_size(LEN / 2).spawn(|| {
let vec = <[_]>::into_vec(box ([0; LEN]);
assert_eq!(vec.len(), LEN);
}).unwrap().join().is_ok());
} |
@apasel422 the point is to use EDIT: Oops, I forgot we don't use the array for for repeats, so it would be hard to trigger without passing a lot of things to |
@eddyb Right. Do you have an example of how I could use the |
This crashes on playpen: fn main() {
let _v = vec![[0; 1 << 23]];
} |
Is there a way to specify the optimization level in a run-pass test, or do I have to use a run-make test? Edit: Never mind; found Edit 2: Actually, because |
Updated with test. |
-include ../tools.mk | ||
|
||
all: | ||
$(RUSTC) -C opt-level=0 big_vec.rs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be added as a run-pass
test instead? We've got builders for unoptimized tests which should cover this I believe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. I guess I don't have to do anything special to configure the test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
To be extra super sure, I'm gonna run crater on this. |
Crater reports zero regressions (as expected) |
@alexcrichton Does this need anything else? |
Ah I was just hoping to discuss this with the libs team briefly, but I suspect we'll just merge |
☔ The latest upstream changes (presumably #31749) made this pull request unmergeable. Please resolve the merge conflicts. |
We talked about this in triage yesterday and everything seemed all good, thanks again @apasel422! |
Closes #28950.
r? @eddyb