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> {
2929 opt_i. map ( manipulate)
3030}
3131
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+
3243fn main ( ) {
3344 let answer = Some ( 42u32 ) ;
3445 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
22 --> tests/ui/single_option_map.rs:8:1
33 |
44LL | / fn h(arg: Option<u32>) -> Option<u32> {
5+ LL | |
56LL | | arg.map(|x| x * 2)
67LL | | }
78 | |_^
@@ -11,14 +12,25 @@ LL | | }
1112 = help: to override `-D warnings` add `#[allow(clippy::single_option_map)]`
1213
1314error: `fn` that only maps over argument
14- --> tests/ui/single_option_map.rs:12 :1
15+ --> tests/ui/single_option_map.rs:13 :1
1516 |
1617LL | / fn j(arg: Option<u64>) -> Option<u64> {
18+ LL | |
1719LL | | arg.map(|x| x * 2)
1820LL | | }
1921 | |_^
2022 |
2123 = help: move the `.map` to the caller or to an `_opt` function
2224
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
2436
You can’t perform that action at this time.
0 commit comments