fix: unnecessary_filter_map return of Some arg#12766
fix: unnecessary_filter_map return of Some arg#12766omer-shtivi wants to merge 2 commits intorust-lang:masterfrom
Conversation
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @llogiq (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
| && arg_id.ty_def_id() == args[0].hir_id().ty_def_id() | ||
| { | ||
| if let hir::ExprKind::Path(_) = args[0].kind { | ||
| span_lint(cx, UNNECESSARY_FILTER_MAP, arg.span, &format!("{name} is unnecessary")) |
There was a problem hiding this comment.
it just occurs to me that... could this be span_lint_with_sugg instead 🤔 , suggesting removing the filter_map?
same thing applies here, while suggest replacing the method call, with MaybeIncorrect applicability for both ofc...
|
|
||
| let _ = (0..4).filter_map(i32::checked_abs); | ||
|
|
||
| let _ = vec![Some(10), None].into_iter().filter_map(|x| Some(x)); |
There was a problem hiding this comment.
The linked issue also mentions passing a path to Some, so maybe we should add this as a test too
let _ = (0..4).filter_map(Some);There was a problem hiding this comment.
The more tests the merrier 😎
|
☔ The latest upstream changes (presumably #12897) made this pull request unmergeable. Please resolve the merge conflicts. |
| if is_res_lang_ctor(cx, path_res(cx, expr), OptionSome) | ||
| && arg_id.ty_def_id() == args[0].hir_id().ty_def_id() | ||
| { | ||
| if let hir::ExprKind::Path(_) = args[0].kind { |
There was a problem hiding this comment.
| if is_res_lang_ctor(cx, path_res(cx, expr), OptionSome) | |
| && arg_id.ty_def_id() == args[0].hir_id().ty_def_id() | |
| { | |
| if let hir::ExprKind::Path(_) = args[0].kind { | |
| if is_res_lang_ctor(cx, path_res(cx, expr), OptionSome) | |
| && arg_id.ty_def_id() == args[0].hir_id().ty_def_id() | |
| && let hir::ExprKind::Path(_) = args[0].kind { |
let chains for the win!
| @@ -1,3 +1,4 @@ | |||
| //@no-rustfix | |||
There was a problem hiding this comment.
Is the whole test rustfix-incompatible? If not, could we split our a -fix test file?
|
Hey @omer-shtivi , this is a ping from triage, since there hasn't been any activity in some time. Are you still planning to continue this implementation? If you have any questions, you're always welcome to ask them in this PR or on Zulip. @rustbot author |
|
Hey this is triage, I'm closing this due to inactivity. If you want to continue this implementation, you're welcome to create a new PR. Thank you for the time, you already put into this! Interested parties are welcome to pick this implementation up as well :) @rustbot label +S-inactive-closed -S-waiting-on-author -S-waiting-on-review |
fixes #12556
changelog: [
unnecessary_filter_map]: filter map return arg as Some