2023-12-01 17:21:58 +00:00
|
|
|
error: called `map(<f>).unwrap_or(<a>)` on an `Option` value
|
2024-02-27 14:25:18 +00:00
|
|
|
--> tests/ui/map_unwrap_or.rs:17:13
|
2019-10-05 12:23:52 +00:00
|
|
|
|
|
|
|
|
LL | let _ = opt.map(|x| x + 1)
|
|
|
|
| _____________^
|
|
|
|
LL | | // Should lint even though this call is on a separate line.
|
|
|
|
LL | | .unwrap_or(0);
|
|
|
|
| |_____________________^
|
|
|
|
|
|
2020-05-17 15:36:26 +00:00
|
|
|
= note: `-D clippy::map-unwrap-or` implied by `-D warnings`
|
2023-08-01 12:02:21 +00:00
|
|
|
= help: to override `-D warnings` add `#[allow(clippy::map_unwrap_or)]`
|
2020-11-05 13:29:48 +00:00
|
|
|
help: use `map_or(<a>, <f>)` instead
|
2019-10-05 12:23:52 +00:00
|
|
|
|
|
2021-08-11 14:21:33 +00:00
|
|
|
LL - let _ = opt.map(|x| x + 1)
|
|
|
|
LL + let _ = opt.map_or(0, |x| x + 1);
|
2022-06-15 11:15:54 +00:00
|
|
|
|
|
2019-10-05 12:23:52 +00:00
|
|
|
|
2023-12-01 17:21:58 +00:00
|
|
|
error: called `map(<f>).unwrap_or(<a>)` on an `Option` value
|
2024-02-27 14:25:18 +00:00
|
|
|
--> tests/ui/map_unwrap_or.rs:21:13
|
2019-10-05 12:23:52 +00:00
|
|
|
|
|
|
|
|
LL | let _ = opt.map(|x| {
|
|
|
|
| _____________^
|
|
|
|
LL | | x + 1
|
|
|
|
LL | | }
|
|
|
|
LL | | ).unwrap_or(0);
|
|
|
|
| |__________________^
|
|
|
|
|
|
2020-11-05 13:29:48 +00:00
|
|
|
help: use `map_or(<a>, <f>)` instead
|
2019-10-05 12:23:52 +00:00
|
|
|
|
|
2021-08-11 14:21:33 +00:00
|
|
|
LL ~ let _ = opt.map_or(0, |x| {
|
2019-10-05 12:23:52 +00:00
|
|
|
LL | x + 1
|
|
|
|
LL | }
|
2021-08-11 14:21:33 +00:00
|
|
|
LL ~ );
|
2019-10-05 12:23:52 +00:00
|
|
|
|
|
|
|
|
|
2023-12-01 17:21:58 +00:00
|
|
|
error: called `map(<f>).unwrap_or(<a>)` on an `Option` value
|
2024-02-27 14:25:18 +00:00
|
|
|
--> tests/ui/map_unwrap_or.rs:25:13
|
2019-10-05 12:23:52 +00:00
|
|
|
|
|
|
|
|
LL | let _ = opt.map(|x| x + 1)
|
|
|
|
| _____________^
|
|
|
|
LL | | .unwrap_or({
|
|
|
|
LL | | 0
|
|
|
|
LL | | });
|
|
|
|
| |__________^
|
|
|
|
|
|
2020-11-05 13:29:48 +00:00
|
|
|
help: use `map_or(<a>, <f>)` instead
|
2019-10-05 12:23:52 +00:00
|
|
|
|
|
2021-08-11 14:21:33 +00:00
|
|
|
LL ~ let _ = opt.map_or({
|
|
|
|
LL + 0
|
|
|
|
LL ~ }, |x| x + 1);
|
2019-10-05 12:23:52 +00:00
|
|
|
|
|
|
|
|
|
2023-12-01 17:21:58 +00:00
|
|
|
error: called `map(<f>).unwrap_or(None)` on an `Option` value
|
2024-02-27 14:25:18 +00:00
|
|
|
--> tests/ui/map_unwrap_or.rs:30:13
|
2019-10-05 12:23:52 +00:00
|
|
|
|
|
|
|
|
LL | let _ = opt.map(|x| Some(x + 1)).unwrap_or(None);
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
2020-11-05 13:29:48 +00:00
|
|
|
help: use `and_then(<f>)` instead
|
2019-10-05 12:23:52 +00:00
|
|
|
|
|
2021-08-11 14:21:33 +00:00
|
|
|
LL - let _ = opt.map(|x| Some(x + 1)).unwrap_or(None);
|
|
|
|
LL + let _ = opt.and_then(|x| Some(x + 1));
|
2022-06-15 11:15:54 +00:00
|
|
|
|
|
2019-10-05 12:23:52 +00:00
|
|
|
|
2023-12-01 17:21:58 +00:00
|
|
|
error: called `map(<f>).unwrap_or(None)` on an `Option` value
|
2024-02-27 14:25:18 +00:00
|
|
|
--> tests/ui/map_unwrap_or.rs:32:13
|
2019-10-05 12:23:52 +00:00
|
|
|
|
|
|
|
|
LL | let _ = opt.map(|x| {
|
|
|
|
| _____________^
|
|
|
|
LL | | Some(x + 1)
|
|
|
|
LL | | }
|
|
|
|
LL | | ).unwrap_or(None);
|
|
|
|
| |_____________________^
|
|
|
|
|
|
2020-11-05 13:29:48 +00:00
|
|
|
help: use `and_then(<f>)` instead
|
2019-10-05 12:23:52 +00:00
|
|
|
|
|
2021-08-11 14:21:33 +00:00
|
|
|
LL ~ let _ = opt.and_then(|x| {
|
2019-10-05 12:23:52 +00:00
|
|
|
LL | Some(x + 1)
|
|
|
|
LL | }
|
2021-08-11 14:21:33 +00:00
|
|
|
LL ~ );
|
2019-10-05 12:23:52 +00:00
|
|
|
|
|
|
|
|
|
2023-12-01 17:21:58 +00:00
|
|
|
error: called `map(<f>).unwrap_or(None)` on an `Option` value
|
2024-02-27 14:25:18 +00:00
|
|
|
--> tests/ui/map_unwrap_or.rs:36:13
|
2019-10-05 12:23:52 +00:00
|
|
|
|
|
|
|
|
LL | let _ = opt
|
|
|
|
| _____________^
|
|
|
|
LL | | .map(|x| Some(x + 1))
|
|
|
|
LL | | .unwrap_or(None);
|
|
|
|
| |________________________^
|
|
|
|
|
|
2020-11-05 13:29:48 +00:00
|
|
|
help: use `and_then(<f>)` instead
|
2019-10-05 12:23:52 +00:00
|
|
|
|
|
2021-08-11 14:21:33 +00:00
|
|
|
LL - .map(|x| Some(x + 1))
|
|
|
|
LL + .and_then(|x| Some(x + 1));
|
2022-06-15 11:15:54 +00:00
|
|
|
|
|
2019-10-05 12:23:52 +00:00
|
|
|
|
2023-12-01 17:21:58 +00:00
|
|
|
error: called `map(<f>).unwrap_or(<a>)` on an `Option` value
|
2024-02-27 14:25:18 +00:00
|
|
|
--> tests/ui/map_unwrap_or.rs:47:13
|
2019-10-05 12:23:52 +00:00
|
|
|
|
|
|
|
|
LL | let _ = Some("prefix").map(|p| format!("{}.", p)).unwrap_or(id);
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
2020-11-05 13:29:48 +00:00
|
|
|
help: use `map_or(<a>, <f>)` instead
|
2019-10-05 12:23:52 +00:00
|
|
|
|
|
2021-08-11 14:21:33 +00:00
|
|
|
LL - let _ = Some("prefix").map(|p| format!("{}.", p)).unwrap_or(id);
|
|
|
|
LL + let _ = Some("prefix").map_or(id, |p| format!("{}.", p));
|
2022-06-15 11:15:54 +00:00
|
|
|
|
|
2019-10-05 12:23:52 +00:00
|
|
|
|
2023-12-01 17:21:58 +00:00
|
|
|
error: called `map(<f>).unwrap_or_else(<g>)` on an `Option` value
|
2024-02-27 14:25:18 +00:00
|
|
|
--> tests/ui/map_unwrap_or.rs:51:13
|
2019-10-05 12:23:52 +00:00
|
|
|
|
|
|
|
|
LL | let _ = opt.map(|x| {
|
|
|
|
| _____________^
|
|
|
|
LL | | x + 1
|
|
|
|
LL | | }
|
|
|
|
LL | | ).unwrap_or_else(|| 0);
|
|
|
|
| |__________________________^
|
|
|
|
|
2023-12-01 17:21:58 +00:00
|
|
|
error: called `map(<f>).unwrap_or_else(<g>)` on an `Option` value
|
2024-02-27 14:25:18 +00:00
|
|
|
--> tests/ui/map_unwrap_or.rs:55:13
|
2019-10-05 12:23:52 +00:00
|
|
|
|
|
|
|
|
LL | let _ = opt.map(|x| x + 1)
|
|
|
|
| _____________^
|
|
|
|
LL | | .unwrap_or_else(||
|
|
|
|
LL | | 0
|
|
|
|
LL | | );
|
|
|
|
| |_________^
|
|
|
|
|
2023-12-01 17:21:58 +00:00
|
|
|
error: called `map(<f>).unwrap_or(false)` on an `Option` value
|
2024-02-27 14:25:18 +00:00
|
|
|
--> tests/ui/map_unwrap_or.rs:61:13
|
2023-07-02 12:35:19 +00:00
|
|
|
|
|
|
|
|
LL | let _ = opt.map(|x| x > 5).unwrap_or(false);
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
|
help: use `is_some_and(<f>)` instead
|
|
|
|
|
|
|
|
|
LL - let _ = opt.map(|x| x > 5).unwrap_or(false);
|
|
|
|
LL + let _ = opt.is_some_and(|x| x > 5);
|
|
|
|
|
|
|
|
|
|
2023-12-01 17:21:58 +00:00
|
|
|
error: called `map(<f>).unwrap_or_else(<g>)` on a `Result` value
|
2024-02-27 14:25:18 +00:00
|
|
|
--> tests/ui/map_unwrap_or.rs:71:13
|
2020-05-17 15:36:26 +00:00
|
|
|
|
|
2020-11-05 13:29:48 +00:00
|
|
|
LL | let _ = res.map(|x| {
|
|
|
|
| _____________^
|
|
|
|
LL | | x + 1
|
|
|
|
LL | | }
|
|
|
|
LL | | ).unwrap_or_else(|_e| 0);
|
|
|
|
| |____________________________^
|
2020-05-17 15:36:26 +00:00
|
|
|
|
2023-12-01 17:21:58 +00:00
|
|
|
error: called `map(<f>).unwrap_or_else(<g>)` on a `Result` value
|
2024-02-27 14:25:18 +00:00
|
|
|
--> tests/ui/map_unwrap_or.rs:75:13
|
2020-05-17 15:36:26 +00:00
|
|
|
|
|
2020-11-05 13:29:48 +00:00
|
|
|
LL | let _ = res.map(|x| x + 1)
|
|
|
|
| _____________^
|
|
|
|
LL | | .unwrap_or_else(|_e| {
|
|
|
|
LL | | 0
|
|
|
|
LL | | });
|
|
|
|
| |__________^
|
2020-05-17 15:36:26 +00:00
|
|
|
|
2023-12-01 17:21:58 +00:00
|
|
|
error: called `map(<f>).unwrap_or_else(<g>)` on a `Result` value
|
2024-02-27 14:25:18 +00:00
|
|
|
--> tests/ui/map_unwrap_or.rs:99:13
|
2022-10-23 13:18:45 +00:00
|
|
|
|
|
|
|
|
LL | let _ = res.map(|x| x + 1).unwrap_or_else(|_e| 0);
|
2023-07-17 08:19:29 +00:00
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `res.map_or_else(|_e| 0, |x| x + 1)`
|
2022-10-23 13:18:45 +00:00
|
|
|
|
2023-12-01 17:21:58 +00:00
|
|
|
error: called `map(<f>).unwrap_or(<a>)` on an `Option` value
|
2024-02-27 14:25:18 +00:00
|
|
|
--> tests/ui/map_unwrap_or.rs:106:13
|
2023-07-02 12:35:19 +00:00
|
|
|
|
|
|
|
|
LL | let _ = opt.map(|x| x > 5).unwrap_or(false);
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
|
help: use `map_or(<a>, <f>)` instead
|
|
|
|
|
|
|
|
|
LL - let _ = opt.map(|x| x > 5).unwrap_or(false);
|
|
|
|
LL + let _ = opt.map_or(false, |x| x > 5);
|
|
|
|
|
|
|
|
|
|
2023-12-01 17:21:58 +00:00
|
|
|
error: called `map(<f>).unwrap_or(false)` on an `Option` value
|
2024-02-27 14:25:18 +00:00
|
|
|
--> tests/ui/map_unwrap_or.rs:113:13
|
2023-07-02 12:35:19 +00:00
|
|
|
|
|
|
|
|
LL | let _ = opt.map(|x| x > 5).unwrap_or(false);
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
|
help: use `is_some_and(<f>)` instead
|
|
|
|
|
|
|
|
|
LL - let _ = opt.map(|x| x > 5).unwrap_or(false);
|
|
|
|
LL + let _ = opt.is_some_and(|x| x > 5);
|
|
|
|
|
|
|
|
|
|
|
|
|
error: aborting due to 15 previous errors
|
2019-10-05 12:23:52 +00:00
|
|
|
|