Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add suggestion to if_let_some_result lint #4991

Closed
JohnTitor opened this issue Jan 4, 2020 · 0 comments · Fixed by #5032
Closed

Add suggestion to if_let_some_result lint #4991

JohnTitor opened this issue Jan 4, 2020 · 0 comments · Fixed by #5032
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages L-suggestion Lint: Improving, adding or fixing lint suggestions

Comments

@JohnTitor
Copy link
Member

It'd be nice for if_let_some_result to have suggestions. I think implementation should be easy.

https://rust-lang.github.io/rust-clippy/master/index.html#if_let_some_result

Example:

fn str_to_int(x: &str) -> i32 {
    if let Some(y) = x.parse().ok() {
        y
    } else {
        0
    }
}

suggests like this:

    if let Some(y) = x.parse().ok() {
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `if let Ok(y) = x.parse()`
@JohnTitor JohnTitor added L-suggestion Lint: Improving, adding or fixing lint suggestions C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages labels Jan 4, 2020
@bors bors closed this as completed in fd0428f Jan 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages L-suggestion Lint: Improving, adding or fixing lint suggestions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant