Skip to content

Commit

Permalink
fix(maitake): prevent task cell niche optimization (#483)
Browse files Browse the repository at this point in the history
See [this comment][1]. Adding `#[repr(C)]` to this type suppresses niche
optimization, resolving potential unsoundness that could occur when the
compiler decides to niche-optimize a self-referential future type. In
practice this probably doesn't actually happen, but we should make sure
it never does.

[1]: rust-lang/miri#3780 (comment)
  • Loading branch information
hawkw committed Aug 3, 2024
1 parent 19b30c3 commit 45cf523
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions maitake/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ struct Schedulable<S> {
/// completed.
///
/// [`Output`]: Future::Output
#[repr(C)]
enum Cell<F: Future> {
/// The future is still pending.
Pending(F),
Expand Down

0 comments on commit 45cf523

Please sign in to comment.