-
Notifications
You must be signed in to change notification settings - Fork 13.9k
constify from_fn, try_from_fn, try_map, map #147071
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
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What part of this isn't const evaluable? The get_unchecked_mut?
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its used in try_from_fn, so it can get dropped in const context?
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.
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.
library/core/src/array/mod.rs
Outdated
| #[inline] | ||
| #[stable(feature = "array_from_fn", since = "1.63.0")] | ||
| pub fn from_fn<T, const N: usize, F>(f: F) -> [T; N] | ||
| #[rustc_const_unstable(feature = "const_array", issue = "none")] |
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.
Please create a tracking issue and use its id here
|
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.
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
1f0bdad to
1f17c24
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
cc6fe75 to
f795f04
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
8dc2572 to
b560205
Compare
This comment has been minimized.
This comment has been minimized.
b560205 to
014f077
Compare
This comment has been minimized.
This comment has been minimized.
|
☔ The latest upstream changes (presumably #147692) made this pull request unmergeable. Please resolve the merge conflicts. |
014f077 to
432647f
Compare
This comment has been minimized.
This comment has been minimized.
432647f to
7eecd6c
Compare
This comment has been minimized.
This comment has been minimized.
7eecd6c to
69f1c74
Compare
This comment has been minimized.
This comment has been minimized.
|
@rustbot ready |
|
☔ The latest upstream changes (presumably #147957) made this pull request unmergeable. Please resolve the merge conflicts. |
69f1c74 to
d1504e0
Compare
|
This PR was rebased onto a different master 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. |
This comment has been minimized.
This comment has been minimized.
d1504e0 to
5c8cedc
Compare
adds the
const_arrayfeaturereimplements
try_mapwith "iterator"