Sisu
E0045

is used to test for None

Error

Built from the repository at commit a8614dc.

is tests identity: whether two references refer to the same object. None is no object, so is does not apply to it.

Why

Testing for None is a comparison of values, written with ==.

Broken

class Node {
    next: Node?
}

fn main() {
    let n = Node(next: None)
    print(n.next is None)
}

What sisu says

error[E0045]: `is` tests identity, and `None` is not an object
 --> E0045.sisu:7:11
  |
7 |     print(n.next is None)
  |           ^^^^^^^^^^^^^^
  |
  = help: use `n.next == None`

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

Fixed

class Node {
    next: Node?
}

fn main() {
    let n = Node(next: None)
    print(n.next == None)
}

Related

  • E0044: a value that is never None compared with None.
  • E0046: is on something that is not an object.