constify from_fn, try_from_fn, try_map, map#147071
Conversation
4134ec0 to
b09b6de
Compare
This comment has been minimized.
This comment has been minimized.
b09b6de to
a702598
Compare
This comment has been minimized.
This comment has been minimized.
a702598 to
4029d42
Compare
This comment has been minimized.
This comment has been minimized.
4029d42 to
79879c4
Compare
|
r? @ibraheemdev rustbot has assigned @ibraheemdev. Use |
library/core/src/array/mod.rs
Outdated
| else { | ||
| // SAFETY: this slice will contain only initialized objects. | ||
| unsafe { | ||
| x.array_mut.get_unchecked_mut(..x.initialized).assume_init_drop(); |
There was a problem hiding this comment.
What part of this isn't const evaluable? The get_unchecked_mut?
There was a problem hiding this comment.
assume_init_drop, and changing it to be const had some rammifications for some reason, causing some tests to fail. #147071 (comment)
There was a problem hiding this comment.
Looks like just trivial stderr file changes. Feel free to just bless them.
But is that code path testable in const? Since it's only happening in a panic path, I think it's unreachable anyway in const contexts. They never unwind and never will unwind. So maybe just document that and move the entire drop method body into the non-const code path... Or can we keep it non-const and avoid any drop happening for it by "disarming it" in the success path?
There was a problem hiding this comment.
its used in try_from_fn, so it can get dropped in const context?
There was a problem hiding this comment.
Ah right. Hmm. Wondering how to write an observable test for this. I think if you use a type with a reference to a Cell and in its const drop impl increment that cell, you should see in a const context that the cell isn't incremented if try_map errors/returns None.
There was a problem hiding this comment.
Ah oops, wanted to write this test but forgot about it when I was on a computer.
Need to reinvestigate this to get it all back into cache.
There was a problem hiding this comment.
It oughtnt really be needed now, as the behaviour is identical to the non const version?
|
The Miri subtree was changed cc @rust-lang/miri |
e95a529 to
0021344
Compare
43edafa to
7bec7a4
Compare
This comment has been minimized.
This comment has been minimized.
library/core/src/array/drain.rs
Outdated
| where | ||
| F: [const] FnMut(T) -> U, | ||
| { | ||
| extern "rust-call" fn call_mut(&mut self, (i,): (usize,)) -> Self::Output { |
There was a problem hiding this comment.
it would be possible to ignore this i and just use moved, but, uh, i think that would be somewhat confusing.
7bec7a4 to
1f0bdad
Compare
This comment has been minimized.
This comment has been minimized.
83d9e8c to
fe20650
Compare
This comment has been minimized.
This comment has been minimized.
fe20650 to
4e6aac0
Compare
|
Some changes occurred in src/tools/cargo cc @ehuss |
This comment has been minimized.
This comment has been minimized.
fc3eecd to
ebc402b
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
ebc402b to
4c15a50
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. |
4c15a50 to
e3a2c23
Compare
|
@bors r+ |
Rollup of 8 pull requests Successful merges: - #147071 (constify from_fn, try_from_fn, try_map, map) - #148930 (tweak editor configs) - #149320 (-Znext-solver: normalize expected function input types when fudging) - #149363 (Port the `#![windows_subsystem]` attribute to the new attribute system) - #149378 (make run-make tests use 2024 edition by default) - #149381 (Add `impl TrustedLen` on `BTree{Map,Set}` iterators) - #149388 (remove session+blob decoder construction) - #149390 (`rust-analyzer` subtree update) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of #147071 - bend-n:const_array-ops, r=oli-obk constify from_fn, try_from_fn, try_map, map adds the `const_array` feature reimplements `try_map` in more or less the same way
Rollup of 8 pull requests Successful merges: - rust-lang/rust#147071 (constify from_fn, try_from_fn, try_map, map) - rust-lang/rust#148930 (tweak editor configs) - rust-lang/rust#149320 (-Znext-solver: normalize expected function input types when fudging) - rust-lang/rust#149363 (Port the `#![windows_subsystem]` attribute to the new attribute system) - rust-lang/rust#149378 (make run-make tests use 2024 edition by default) - rust-lang/rust#149381 (Add `impl TrustedLen` on `BTree{Map,Set}` iterators) - rust-lang/rust#149388 (remove session+blob decoder construction) - rust-lang/rust#149390 (`rust-analyzer` subtree update) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#147071 (constify from_fn, try_from_fn, try_map, map) - rust-lang#148930 (tweak editor configs) - rust-lang#149320 (-Znext-solver: normalize expected function input types when fudging) - rust-lang#149363 (Port the `#![windows_subsystem]` attribute to the new attribute system) - rust-lang#149378 (make run-make tests use 2024 edition by default) - rust-lang#149381 (Add `impl TrustedLen` on `BTree{Map,Set}` iterators) - rust-lang#149388 (remove session+blob decoder construction) - rust-lang#149390 (`rust-analyzer` subtree update) r? `@ghost` `@rustbot` modify labels: rollup
adds the
const_arrayfeaturereimplements
try_mapin more or less the same way