-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
fix fallback impl for select_unpredictable intrinsic #151042
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
fix fallback impl for select_unpredictable intrinsic #151042
Conversation
This comment has been minimized.
This comment has been minimized.
|
Good catch! Could you add a Miri test? |
|
The Miri subtree was changed cc @rust-lang/miri |
|
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. |
This comment has been minimized.
This comment has been minimized.
a69e8e6 to
44ae04e
Compare
|
@RalfJung test added! |
44ae04e to
7d3bf37
Compare
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.
Libs bits LGTM, but since this is mostly miri:
r? @RalfJung
|
|
|
@bors r+ rollup |
…le-fallback, r=RalfJung
fix fallback impl for select_unpredictable intrinsic
`intrinsics::select_unpredictable` does not drop the value that is not selected, but the fallback impl did not consider this behavior. This creates an observable difference between Miri and actual execution, and possibly does not play well with the `core::hint` version which has extra logic to drop the value that was not selected.
```rust
#![feature(core_intrinsics)]
fn main() {
core::intrinsics::select_unpredictable(true, LoudDrop(0), LoudDrop(1));
// cargo run: "0"; cargo miri run: "1 0"
}
struct LoudDrop(u8);
impl Drop for LoudDrop {
fn drop(&mut self) {
print!("{} ", self.0);
}
}
```
This change let me remove the `T: [const] Destruct` bound as well, since the destructor is no longer relevant.
…le-fallback, r=RalfJung
fix fallback impl for select_unpredictable intrinsic
`intrinsics::select_unpredictable` does not drop the value that is not selected, but the fallback impl did not consider this behavior. This creates an observable difference between Miri and actual execution, and possibly does not play well with the `core::hint` version which has extra logic to drop the value that was not selected.
```rust
#![feature(core_intrinsics)]
fn main() {
core::intrinsics::select_unpredictable(true, LoudDrop(0), LoudDrop(1));
// cargo run: "0"; cargo miri run: "1 0"
}
struct LoudDrop(u8);
impl Drop for LoudDrop {
fn drop(&mut self) {
print!("{} ", self.0);
}
}
```
This change let me remove the `T: [const] Destruct` bound as well, since the destructor is no longer relevant.
…uwer Rollup of 8 pull requests Successful merges: - #148206 (Deduplicated float tests and unified in floats/mod.rs) - #151042 (fix fallback impl for select_unpredictable intrinsic) - #151220 (option: Use Option::map in Option::cloned) - #151260 (Handle unevaluated ConstKind in in_operand) - #151441 (Fix ICE: Don't try to evaluate type_consts when eagerly collecting items) - #151465 (codegen: clarify some variable names around function calls) - #151469 (llvm: Tolerate dead_on_return attribute changes) - #151476 (Avoid `-> ()` in derived functions.) r? @ghost
…uwer Rollup of 8 pull requests Successful merges: - #148206 (Deduplicated float tests and unified in floats/mod.rs) - #151042 (fix fallback impl for select_unpredictable intrinsic) - #151220 (option: Use Option::map in Option::cloned) - #151260 (Handle unevaluated ConstKind in in_operand) - #151441 (Fix ICE: Don't try to evaluate type_consts when eagerly collecting items) - #151465 (codegen: clarify some variable names around function calls) - #151469 (llvm: Tolerate dead_on_return attribute changes) - #151476 (Avoid `-> ()` in derived functions.) r? @ghost
…uwer Rollup of 8 pull requests Successful merges: - #148206 (Deduplicated float tests and unified in floats/mod.rs) - #151042 (fix fallback impl for select_unpredictable intrinsic) - #151220 (option: Use Option::map in Option::cloned) - #151260 (Handle unevaluated ConstKind in in_operand) - #151441 (Fix ICE: Don't try to evaluate type_consts when eagerly collecting items) - #151465 (codegen: clarify some variable names around function calls) - #151469 (llvm: Tolerate dead_on_return attribute changes) - #151476 (Avoid `-> ()` in derived functions.) r? @ghost
…uwer Rollup of 11 pull requests Successful merges: - #151001 (rustdoc: render doc(hidden) as a code attribute) - #151042 (fix fallback impl for select_unpredictable intrinsic) - #151220 (option: Use Option::map in Option::cloned) - #151260 (Handle unevaluated ConstKind in in_operand) - #151296 (MGCA: Fix incorrect pretty printing of valtree arrays) - #151423 (Move assert_matches to planned stable path) - #151441 (Fix ICE: Don't try to evaluate type_consts when eagerly collecting items) - #151465 (codegen: clarify some variable names around function calls) - #151468 (fix `f16` doctest FIXMEs) - #151469 (llvm: Tolerate dead_on_return attribute changes) - #151476 (Avoid `-> ()` in derived functions.) r? @ghost
…uwer Rollup of 11 pull requests Successful merges: - #151001 (rustdoc: render doc(hidden) as a code attribute) - #151042 (fix fallback impl for select_unpredictable intrinsic) - #151220 (option: Use Option::map in Option::cloned) - #151260 (Handle unevaluated ConstKind in in_operand) - #151296 (MGCA: Fix incorrect pretty printing of valtree arrays) - #151423 (Move assert_matches to planned stable path) - #151441 (Fix ICE: Don't try to evaluate type_consts when eagerly collecting items) - #151465 (codegen: clarify some variable names around function calls) - #151468 (fix `f16` doctest FIXMEs) - #151469 (llvm: Tolerate dead_on_return attribute changes) - #151476 (Avoid `-> ()` in derived functions.) r? @ghost
…uwer Rollup of 11 pull requests Successful merges: - #151001 (rustdoc: render doc(hidden) as a code attribute) - #151042 (fix fallback impl for select_unpredictable intrinsic) - #151220 (option: Use Option::map in Option::cloned) - #151260 (Handle unevaluated ConstKind in in_operand) - #151296 (MGCA: Fix incorrect pretty printing of valtree arrays) - #151423 (Move assert_matches to planned stable path) - #151441 (Fix ICE: Don't try to evaluate type_consts when eagerly collecting items) - #151465 (codegen: clarify some variable names around function calls) - #151468 (fix `f16` doctest FIXMEs) - #151469 (llvm: Tolerate dead_on_return attribute changes) - #151476 (Avoid `-> ()` in derived functions.) r? @ghost
Rollup merge of #151042 - RedDaedalus:fix-select-unpredictable-fallback, r=RalfJung fix fallback impl for select_unpredictable intrinsic `intrinsics::select_unpredictable` does not drop the value that is not selected, but the fallback impl did not consider this behavior. This creates an observable difference between Miri and actual execution, and possibly does not play well with the `core::hint` version which has extra logic to drop the value that was not selected. ```rust #![feature(core_intrinsics)] fn main() { core::intrinsics::select_unpredictable(true, LoudDrop(0), LoudDrop(1)); // cargo run: "0"; cargo miri run: "1 0" } struct LoudDrop(u8); impl Drop for LoudDrop { fn drop(&mut self) { print!("{} ", self.0); } } ``` This change let me remove the `T: [const] Destruct` bound as well, since the destructor is no longer relevant.
…uwer Rollup of 11 pull requests Successful merges: - rust-lang/rust#151001 (rustdoc: render doc(hidden) as a code attribute) - rust-lang/rust#151042 (fix fallback impl for select_unpredictable intrinsic) - rust-lang/rust#151220 (option: Use Option::map in Option::cloned) - rust-lang/rust#151260 (Handle unevaluated ConstKind in in_operand) - rust-lang/rust#151296 (MGCA: Fix incorrect pretty printing of valtree arrays) - rust-lang/rust#151423 (Move assert_matches to planned stable path) - rust-lang/rust#151441 (Fix ICE: Don't try to evaluate type_consts when eagerly collecting items) - rust-lang/rust#151465 (codegen: clarify some variable names around function calls) - rust-lang/rust#151468 (fix `f16` doctest FIXMEs) - rust-lang/rust#151469 (llvm: Tolerate dead_on_return attribute changes) - rust-lang/rust#151476 (Avoid `-> ()` in derived functions.) r? @ghost
intrinsics::select_unpredictabledoes not drop the value that is not selected, but the fallback impl did not consider this behavior. This creates an observable difference between Miri and actual execution, and possibly does not play well with thecore::hintversion which has extra logic to drop the value that was not selected.This change let me remove the
T: [const] Destructbound as well, since the destructor is no longer relevant.