Sisu
E0138

Type that cannot be a type argument

Error

Built from the repository at commit a8614dc.

A type argument is a type a value can have: not unit and not never. An optional, such as i64?, can be a type argument.

Why

A type parameter stands for the type of values: of a field, a payload, a parameter or an element. unit and never are the types of no value, so they stand for nothing there.

Broken

class Cell<T> {
    value: T
}

fn main() {
    let c: Cell<unit>? = None
    print(c == None)
}

What sisu says

error[E0138]: `unit` cannot be a type argument
 --> E0138.sisu:6:17
  |
6 |     let c: Cell<unit>? = None
  |                 ^^^^

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

Fixed

class Cell<T> {
    value: T
}

fn main() {
    let c: Cell<bool>? = Cell(value: true)
    print(c?.value ?? false)
}

Related

  • E0137: type arguments that do not fit.