Sisu
E0108

Malformed format spec

Error

Built from the repository at commit a8614dc.

A format spec, the part of an interpolation after its :, is [<^>][width][.precision]: an optional alignment, an optional width, and an optional . with the number of decimals. It must hold a width or a precision, and a . needs digits after it. {x:}, {x:>}, {x:.} and {x:8.} are errors. The error points at the spec, from its :.

Why

An alignment alone, as in {x:>}, aligns nothing, and a . without digits names no precision. Each of these is half of a spec, and Sisu cannot tell which half is missing, so there is no fix: write the width or the precision you meant, or remove the : and what follows it.

Broken

fn main() {
    let x = 2.5
    print("{x:8.}")
}

What sisu says

error[E0108]: a format spec is `[<^>][width][.precision]`
 --> E0108.sisu:3:14
  |
3 |     print("{x:8.}")
  |              ^^^

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

Fixed

fn main() {
    let x = 2.5
    print("{x:8.2}")
}

Related

  • E0109: a format spec that asks for more than alignment, width and precision.
  • E0110: a width or precision above its limit.