File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,17 @@ fn manipulate_opt(opt_i: Option<i32>) -> Option<i32> {
29
29
opt_i. map ( manipulate)
30
30
}
31
31
32
+ // No lint: maps other than the receiver
33
+ fn map_not_arg ( arg : Option < u32 > ) -> Option < u32 > {
34
+ maps_static_option ( ) . map ( |_| arg. unwrap ( ) )
35
+ }
36
+
37
+ // No lint: wrapper function with η-expanded form
38
+ #[ allow( clippy:: redundant_closure) ]
39
+ fn manipulate_opt_explicit ( opt_i : Option < i32 > ) -> Option < i32 > {
40
+ opt_i. map ( |x| manipulate ( x) )
41
+ }
42
+
32
43
fn main ( ) {
33
44
let answer = Some ( 42u32 ) ;
34
45
let h_result = h ( answer) ;
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ error: `fn` that only maps over argument
2
2
--> tests/ui/single_option_map.rs:8:1
3
3
|
4
4
LL | / fn h(arg: Option<u32>) -> Option<u32> {
5
+ LL | |
5
6
LL | | arg.map(|x| x * 2)
6
7
LL | | }
7
8
| |_^
@@ -11,14 +12,25 @@ LL | | }
11
12
= help: to override `-D warnings` add `#[allow(clippy::single_option_map)]`
12
13
13
14
error: `fn` that only maps over argument
14
- --> tests/ui/single_option_map.rs:12 :1
15
+ --> tests/ui/single_option_map.rs:13 :1
15
16
|
16
17
LL | / fn j(arg: Option<u64>) -> Option<u64> {
18
+ LL | |
17
19
LL | | arg.map(|x| x * 2)
18
20
LL | | }
19
21
| |_^
20
22
|
21
23
= help: move the `.map` to the caller or to an `_opt` function
22
24
23
- error: aborting due to 2 previous errors
25
+ error: `fn` that only maps over argument
26
+ --> tests/ui/single_option_map.rs:39:1
27
+ |
28
+ LL | / fn manipulate_opt_explicit(opt_i: Option<i32>) -> Option<i32> {
29
+ LL | | opt_i.map(|x| manipulate(x))
30
+ LL | | }
31
+ | |_^
32
+ |
33
+ = help: move the `.map` to the caller or to an `_opt` function
34
+
35
+ error: aborting due to 3 previous errors
24
36
You can’t perform that action at this time.
0 commit comments