11error: called `map(<f>).unwrap_or(<a>)` on an `Option` value. This can be done more directly by calling `map_or(<a>, <f>)` instead
22 --> $DIR/map_unwrap_or.rs:16:13
33 |
4+ LL | let _ = opt.map(|x| x + 1)
5+ | _____________^
6+ LL | | // Should lint even though this call is on a separate line.
7+ LL | | .unwrap_or(0);
8+ | |_____________________^
9+ |
10+ = note: `-D clippy::map-unwrap-or` implied by `-D warnings`
11+ help: use `map_or(<a>, <f>)` instead
12+ |
13+ LL | let _ = opt.map_or(0, |x| x + 1);
14+ | ^^^^^^ ^^ --
15+
16+ error: called `map(<f>).unwrap_or(<a>)` on an `Option` value. This can be done more directly by calling `map_or(<a>, <f>)` instead
17+ --> $DIR/map_unwrap_or.rs:20:13
18+ |
419LL | let _ = opt.map(|x| {
520 | _____________^
621LL | | x + 1
722LL | | }
823LL | | ).unwrap_or(0);
924 | |__________________^
1025 |
11- = note: `-D clippy::map-unwrap-or` implied by `-D warnings`
1226help: use `map_or(<a>, <f>)` instead
1327 |
1428LL | let _ = opt.map_or(0, |x| {
@@ -18,7 +32,7 @@ LL | );
1832 |
1933
2034error: called `map(<f>).unwrap_or(<a>)` on an `Option` value. This can be done more directly by calling `map_or(<a>, <f>)` instead
21- --> $DIR/map_unwrap_or.rs:20 :13
35+ --> $DIR/map_unwrap_or.rs:24 :13
2236 |
2337LL | let _ = opt.map(|x| x + 1)
2438 | _____________^
@@ -35,7 +49,7 @@ LL | }, |x| x + 1);
3549 |
3650
3751error: called `map(<f>).unwrap_or(None)` on an `Option` value. This can be done more directly by calling `and_then(<f>)` instead
38- --> $DIR/map_unwrap_or.rs:25 :13
52+ --> $DIR/map_unwrap_or.rs:29 :13
3953 |
4054LL | let _ = opt.map(|x| Some(x + 1)).unwrap_or(None);
4155 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -46,7 +60,7 @@ LL | let _ = opt.and_then(|x| Some(x + 1));
4660 | ^^^^^^^^ --
4761
4862error: called `map(<f>).unwrap_or(None)` on an `Option` value. This can be done more directly by calling `and_then(<f>)` instead
49- --> $DIR/map_unwrap_or.rs:27 :13
63+ --> $DIR/map_unwrap_or.rs:31 :13
5064 |
5165LL | let _ = opt.map(|x| {
5266 | _____________^
@@ -64,7 +78,7 @@ LL | );
6478 |
6579
6680error: called `map(<f>).unwrap_or(None)` on an `Option` value. This can be done more directly by calling `and_then(<f>)` instead
67- --> $DIR/map_unwrap_or.rs:31 :13
81+ --> $DIR/map_unwrap_or.rs:35 :13
6882 |
6983LL | let _ = opt
7084 | _____________^
@@ -78,7 +92,7 @@ LL | .and_then(|x| Some(x + 1));
7892 | ^^^^^^^^ --
7993
8094error: called `map(<f>).unwrap_or(<a>)` on an `Option` value. This can be done more directly by calling `map_or(<a>, <f>)` instead
81- --> $DIR/map_unwrap_or.rs:42 :13
95+ --> $DIR/map_unwrap_or.rs:46 :13
8296 |
8397LL | let _ = Some("prefix").map(|p| format!("{}.", p)).unwrap_or(id);
8498 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -89,7 +103,7 @@ LL | let _ = Some("prefix").map_or(id, |p| format!("{}.", p));
89103 | ^^^^^^ ^^^ --
90104
91105error: called `map(<f>).unwrap_or_else(<g>)` on an `Option` value. This can be done more directly by calling `map_or_else(<g>, <f>)` instead
92- --> $DIR/map_unwrap_or.rs:46 :13
106+ --> $DIR/map_unwrap_or.rs:50 :13
93107 |
94108LL | let _ = opt.map(|x| {
95109 | _____________^
@@ -99,7 +113,7 @@ LL | | ).unwrap_or_else(|| 0);
99113 | |__________________________^
100114
101115error: called `map(<f>).unwrap_or_else(<g>)` on an `Option` value. This can be done more directly by calling `map_or_else(<g>, <f>)` instead
102- --> $DIR/map_unwrap_or.rs:50 :13
116+ --> $DIR/map_unwrap_or.rs:54 :13
103117 |
104118LL | let _ = opt.map(|x| x + 1)
105119 | _____________^
@@ -108,5 +122,25 @@ LL | | 0
108122LL | | );
109123 | |_________^
110124
111- error: aborting due to 8 previous errors
125+ error: called `map(<f>).unwrap_or_else(<g>)` on a `Result` value. This can be done more directly by calling `.map_or_else(<g>, <f>)` instead
126+ --> $DIR/map_unwrap_or.rs:66:13
127+ |
128+ LL | let _ = res.map(|x| {
129+ | _____________^
130+ LL | | x + 1
131+ LL | | }
132+ LL | | ).unwrap_or_else(|_e| 0);
133+ | |____________________________^
134+
135+ error: called `map(<f>).unwrap_or_else(<g>)` on a `Result` value. This can be done more directly by calling `.map_or_else(<g>, <f>)` instead
136+ --> $DIR/map_unwrap_or.rs:70:13
137+ |
138+ LL | let _ = res.map(|x| x + 1)
139+ | _____________^
140+ LL | | .unwrap_or_else(|_e| {
141+ LL | | 0
142+ LL | | });
143+ | |__________^
144+
145+ error: aborting due to 11 previous errors
112146
0 commit comments