E0243

? in a function (or closure) that does not return the same kind: an Option in a function returning Result (convert with .ok_or(err)?), a Result in one returning Option, or either in one returning neither. Spans the ? expression.

Machine-applicable fix: none.

Example

This program fails with E0243.

fn double(x: Option<Int>) -> Result<Int, String> {
    let n = x?
    Ok(n * 2)
}

Fixed

The same program, fixed.

fn double(x: Option<Int>) -> Result<Int, String> {
    let n = x.ok_or("missing")?
    Ok(n * 2)
}

Listed in the checker notes. oskac explain E0243 prints this entry offline.

All error codes