E4139

E4139#

This expression has type that cannot be implicitly ignored. Use ignore(...) or let _ = ... to explicitly ignore it.

Unit type can be implicitly ignored.

错误示例#

For example,

fn main {
  1 + 1 // This expression has type Int, its value cannot be implicitly ignored.
}

The code here show a deeper problem of the logic of the code: discarding the result makes the computation useless.

建议#

If you do want to discard the result, use ignore(..) or let _ = to explicitly discard the value.

fn main {
  ignore(1 + 1)
}