-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
A-lintArea: New lintsArea: New lintsL-complexityLint: Belongs in the complexity lint groupLint: Belongs in the complexity lint groupL-suggestionLint: Improving, adding or fixing lint suggestionsLint: Improving, adding or fixing lint suggestions
Description
The following code uses String::from
fn bar() -> Result<i32, String> {
let x = Some(52.3).ok_or_else(|| String::from("foo"))?;
Ok(42)
}but Some(52.3).ok_or("foo")?; would also compile
So if an ok_or_else is followed by a ? and the inner function is calling From::from (or a specific version of it), we should be able to convert it to an ok_or without that call.
Metadata
Metadata
Assignees
Labels
A-lintArea: New lintsArea: New lintsL-complexityLint: Belongs in the complexity lint groupLint: Belongs in the complexity lint groupL-suggestionLint: Improving, adding or fixing lint suggestionsLint: Improving, adding or fixing lint suggestions