err.span_suggestion_verbose(
span.shrink_to_lo(),
"consider converting the `Option<T>` into a `Result<T, _>` using `Option::ok_or` or `Option::ok_or_else`",
- ".ok_or_else(|_| /* error value */)".to_string(),
+ ".ok_or_else(|| /* error value */)".to_string(),
Applicability::HasPlaceholders,
);
} else if is_try && is_from && should_convert_result_to_option {
span.shrink_to_lo(),
"consider converting the `Result<T, _>` into an `Option<T>` using `Result::ok`",
".ok()".to_string(),
- Applicability::HasPlaceholders,
+ Applicability::MachineApplicable,
);
}
= note: required by `std::convert::From::from`
help: consider converting the `Option<T>` into a `Result<T, _>` using `Option::ok_or` or `Option::ok_or_else`
|
-LL | a.ok_or_else(|_| /* error value */)?;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | a.ok_or_else(|| /* error value */)?;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: `?` couldn't convert the error to `std::option::NoneError`
--> $DIR/option-to-result.rs:11:6
= note: required by `std::convert::From::from`
help: consider converting the `Option<T>` into a `Result<T, _>` using `Option::ok_or` or `Option::ok_or_else`
|
-LL | x.ok_or_else(|_| /* error value */)?;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | x.ok_or_else(|| /* error value */)?;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `std::ops::Try`)
--> $DIR/try-on-option.rs:13:5