Skip to main content

Module hoist

Module hoist 

Source
Expand description

Exposing awaits that sit inside larger statements.

An await in a match scrutinee, an if condition, or a call argument is evaluated before the rest of its statement anyway. Hoisting it into its own binding (let __psync_s1 = x.await;) keeps the evaluation order but turns it into a node that can overlap with other work, while the remainder of the statement stays where it was.

Functionsยง

awaits ๐Ÿ”’
condition ๐Ÿ”’
For loop fission: split if c {..} / if let p = c {..} / match c {..} whose branches await but whose condition c does not into let __psync_cN = c; and the statement reading it.
is_compound_assign ๐Ÿ”’
operands ๐Ÿ”’
Hoist the awaited operands of a call, method call, assignment, array, tuple or vec! into bindings, together with any earlier operands that are not pure, so they still evaluate in order. Also hoists an awaited method receiver (x.await?.items()), which evaluates first. fresh numbers the new bindings.
scrutinee ๐Ÿ”’
Split match e.await {..}, if let p = e.await {..}, if e.await {..}, the same forms as a let initializer, and let p = e.await else {..} into let __psync_sN = e.await; and the statement reading __psync_sN.