Conversation
|
r? @Manishearth rustbot has assigned @Manishearth. Use |
|
r? @llogiq |
|
It is also necessary to check that the receiver of fn f(x: &str) -> Option<u32> {
x.parse::<u32>().ok().map(|x| x+1)
} |
da10dc2 to
609541b
Compare
dc114ee to
a2283e0
Compare
samueltardieu
left a comment
There was a problem hiding this comment.
This test case should be added, to reflect one problem the lint had in its earlier form:
// No lint: maps other than the receiver
fn map_not_arg(arg: Option<u32>) -> Option<u32> {
maps_static_option().map(|_| arg.unwrap())
}Also, wrapping a function can be done more explicitly than with just the function name:
// No lint: wrapper function with η-expanded form
fn manipulate_opt_explicit(opt_i: Option<i32>) -> Option<i32> {
opt_i.map(|x| manipulate(x))
}It would be great not to lint here too. But it can always be done later if this proves cumbersome.
Thanks, I've added it. |
993f5b3 to
40edb89
Compare
There was a problem hiding this comment.
I think we may want to look into the the closure and not lint when it's anything but a function call.
This also applies to function arguments, which should be paths to lint. We shouldn't lint arg1.map(|a1| f(a1, arg2 + 1)). Edit: I'm confused, we should certainly lint that.
214b37b to
4d4ef00
Compare
Checks for functions with method calls to
.map(_)on an arg of typeOptionas the outermost expression.Fixes #774