Sisu
E0112

Variant after a method

Error

Built from the repository at commit a8614dc.

An enum lists its variants first, then its methods. A variant that follows the first method is an error. The second label points at that method.

Why

One place to look for the variants: they are the first lines of the body, and the methods are the rest. Moving the variant above the first method fixes it. The compiler does not move code for you, so there is no fix.

Broken

enum Light {
    Red
    fn same(self) -> Light { self }
    Green
}

fn main() {
    print(Light.Red.same() == Light.Green)
}

What sisu says

error[E0112]: variants come before methods
 --> E0112.sisu:4:5
  |
3 |     fn same(self) -> Light { self }
  |     -- the first method
4 |     Green
  |     ^^^^^

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

Fixed

enum Light {
    Red
    Green

    fn same(self) -> Light { self }
}

fn main() {
    print(Light.Red.same() == Light.Green)
}