Constified array::from_fn and ptr::drop_in_place#109122
Constified array::from_fn and ptr::drop_in_place#109122fee1-dead wants to merge 3 commits intorust-lang:masterfrom
array::from_fn and ptr::drop_in_place#109122Conversation
|
r? @cuviper (rustbot has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
f65d736 to
b4cbcb3
Compare
This comment has been minimized.
This comment has been minimized.
b4cbcb3 to
f10bdbe
Compare
array::from_fnarray::from_fn and ptr::drop_in_place
|
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
The Miri subtree was changed cc @rust-lang/miri |
f10bdbe to
8300869
Compare
| //~| ERROR the parameter type `T` may not live long enough | ||
| drop_in_place: unsafe { | ||
| transmute::<unsafe fn(*mut T), unsafe fn(*mut ())>(drop_in_place::<T>) | ||
| //~^ ERROR can't drop `T` in const contexts |
There was a problem hiding this comment.
Isn't this a bad error? We're not actually calling the function that needs const drop, and this breaks stable code:
pub const fn get_drop<T>() -> unsafe fn(*mut T) {
core::ptr::drop_in_place::<T>
}There was a problem hiding this comment.
Similarly for array::from_fn:
pub const fn array_from_fn() -> fn(fn(usize) -> ()) -> [(); 42] {
core::array::from_fn
}... works on stable, but fails here for lack of ~const FnMut on the function pointer.
There was a problem hiding this comment.
Does this go back to the previous error after #109557?
There was a problem hiding this comment.
The const-eval working group has been discussing the status of const traits in the compiler as well as the standard library. We came to a consensus that all uses of ~const in the standard library should be temporary removed to allow for a clean impl of it to land in the compiler. See this zulip thread.
|
If the current plan is to remove |
Uh oh!
There was an error while loading. Please reload this page.