File tree Expand file tree Collapse file tree 3 files changed +22
-2
lines changed
Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ declare_clippy_lint! {
1616 ///
1717 /// ### Why is this bad?
1818 /// Taking and returning an `Option<T>` may require additional
19- /// `Some(_)` and `unwrap` if all you have is a `T`
19+ /// `Some(_)` and `unwrap` if all you have is a `T`.
2020 ///
2121 /// ### Example
2222 /// ```no_run
Original file line number Diff line number Diff line change @@ -15,6 +15,15 @@ fn j(arg: Option<u64>) -> Option<u64> {
1515 arg. map ( |x| x * 2 )
1616}
1717
18+ fn mul_args ( a : String , b : u64 ) -> String {
19+ a
20+ }
21+
22+ fn mul_args_opt ( a : Option < String > , b : u64 ) -> Option < String > {
23+ //~^ ERROR: `fn` that only maps over argument
24+ a. map ( |val| mul_args ( val, b + 1 ) )
25+ }
26+
1827// No lint: no `Option` argument argument
1928fn maps_static_option ( ) -> Option < usize > {
2029 MAYBE_ATOMIC . map ( |a| a. load ( Ordering :: Relaxed ) )
Original file line number Diff line number Diff line change @@ -22,5 +22,16 @@ LL | | }
2222 |
2323 = help: move the `.map` to the caller or to an `_opt` function
2424
25- error: aborting due to 2 previous errors
25+ error: `fn` that only maps over argument
26+ --> tests/ui/single_option_map.rs:23:1
27+ |
28+ LL | / fn mul_args_opt(a: Option<String>, b: u64) -> Option<String> {
29+ LL | |
30+ LL | | a.map(|val| mul_args(val, b + 1))
31+ LL | | }
32+ | |_^
33+ |
34+ = help: move the `.map` to the caller or to an `_opt` function
35+
36+ error: aborting due to 3 previous errors
2637
You can’t perform that action at this time.
0 commit comments