constify vec![1, 2, 3] macro#155795
Conversation
This comment has been minimized.
This comment has been minimized.
f5967a3 to
c0c3525
Compare
|
r? @TaKO8Ki rustbot has assigned @TaKO8Ki. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
c0c3525 to
334542e
Compare
This comment has been minimized.
This comment has been minimized.
334542e to
ad4fd06
Compare
This comment has been minimized.
This comment has been minimized.
ad4fd06 to
8549919
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
r? @rust-lang/wg-const-eval |
|
r? wg-const-eval |
| static STATIC11: Vec<MyOwned> = vec![MyOwned]; | ||
| static STATIC11: Vec<MyOwned> = non_const(MyOwned); | ||
| //~^ ERROR cannot call non-const function | ||
| //~| ERROR cannot call non-const |
There was a problem hiding this comment.
Keep using the vec macro and just fix up the diagnostics. Can even enable the feature
There was a problem hiding this comment.
Ok, many of these have no more errors now since a Vec of ZSTs doesn't allocate.
If we would rather keep these failure cases, I can make MyOwned non-ZST, or introduce cases with a separate non-ZST type.
|
Reminder, once the PR becomes ready for a review, use |
8549919 to
b1342c9
Compare
|
@rustbot ready |
Tracking issues:
const_heap: #79597makes all the parts needed for non-empty
vec![]macros const:alloc::boxed::box_assume_init_into_vec_unsafealloc::boxed::Box::assume_initalloc::boxed::Box::into_raw_with_allocatoralloc::boxed::Box::new_uninitalloc::slice::[T]::into_vecNote that this does not allow for the use of the
vec![(); 4]arm of this macro to be used in const-eval, since that uses specialization (spec and const traits don't really like each other so I didn't want to touch any of that in this).