Sisu
E0119

Variant built the wrong way

ErrorSafe fix

Built from the repository at commit a8614dc.

A variant that holds nothing is written without parentheses: State.Idle, not State.Idle(). A variant with a payload is always called with it: State.Running(5), not State.Running.

Why

One spelling for each variant means a reader can tell from State.Idle alone that it holds nothing, and from State.Running(5) that it holds a value. The fix for empty parentheses is certain, so it is safe; with arguments inside, it deletes them too, so it is unsafe. A missing payload has no fix, since only you know its value.

Broken

enum State {
    Idle
    Running(i64)
}

fn main() {
    let _ = State.Idle()
    let _ = State.Running(5)
}

What sisu says

error[E0119]: `State.Idle` holds nothing; write `State.Idle`
 --> E0119.sisu:7:23
  |
7 |     let _ = State.Idle()
  |                       ^^
  |
help: remove the parentheses
  |
7 -     let _ = State.Idle()
7 +     let _ = State.Idle
  |

sisu: 1 error
sisu: for more on a code, run `sisu explain <code>`: E0119

Fixed

enum State {
    Idle
    Running(i64)
}

fn main() {
    let _ = State.Idle
    let _ = State.Running(5)
}