| error: called `map(<f>).unwrap_or(<a>)` on an `Option` value | |
| --> tests/ui/map_unwrap_or.rs:17:13 | |
| | | |
| LL | let _ = opt.map(|x| x + 1) | |
| | _____________^ | |
| ... | | |
| LL | | .unwrap_or(0); | |
| | |_____________________^ | |
| | | |
| = note: `-D clippy::map-unwrap-or` implied by `-D warnings` | |
| = help: to override `-D warnings` add `#[allow(clippy::map_unwrap_or)]` | |
| help: use `map_or(<a>, <f>)` instead | |
| | | |
| LL - let _ = opt.map(|x| x + 1) | |
| LL - | |
| LL - // Should lint even though this call is on a separate line. | |
| LL - .unwrap_or(0); | |
| LL + let _ = opt.map_or(0, |x| x + 1); | |
| | | |
| error: called `map(<f>).unwrap_or(<a>)` on an `Option` value | |
| --> tests/ui/map_unwrap_or.rs:22:13 | |
| | | |
| LL | let _ = opt.map(|x| { | |
| | _____________^ | |
| LL | | | |
| LL | | x + 1 | |
| LL | | } | |
| LL | | ).unwrap_or(0); | |
| | |__________________^ | |
| | | |
| help: use `map_or(<a>, <f>)` instead | |
| | | |
| LL ~ let _ = opt.map_or(0, |x| { | |
| LL | | |
| LL | x + 1 | |
| LL | } | |
| LL ~ ); | |
| | | |
| error: called `map(<f>).unwrap_or(<a>)` on an `Option` value | |
| --> tests/ui/map_unwrap_or.rs:27:13 | |
| | | |
| LL | let _ = opt.map(|x| x + 1) | |
| | _____________^ | |
| LL | | | |
| LL | | .unwrap_or({ | |
| LL | | 0 | |
| LL | | }); | |
| | |__________^ | |
| | | |
| help: use `map_or(<a>, <f>)` instead | |
| | | |
| LL ~ let _ = opt.map_or({ | |
| LL + 0 | |
| LL ~ }, |x| x + 1); | |
| | | |
| error: called `map(<f>).unwrap_or(None)` on an `Option` value | |
| --> tests/ui/map_unwrap_or.rs:33:13 | |
| | | |
| LL | let _ = opt.map(|x| Some(x + 1)).unwrap_or(None); | |
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| | | |
| help: use `and_then(<f>)` instead | |
| | | |
| LL - let _ = opt.map(|x| Some(x + 1)).unwrap_or(None); | |
| LL + let _ = opt.and_then(|x| Some(x + 1)); | |
| | | |
| error: called `map(<f>).unwrap_or(None)` on an `Option` value | |
| --> tests/ui/map_unwrap_or.rs:36:13 | |
| | | |
| LL | let _ = opt.map(|x| { | |
| | _____________^ | |
| LL | | | |
| LL | | Some(x + 1) | |
| LL | | } | |
| LL | | ).unwrap_or(None); | |
| | |_____________________^ | |
| | | |
| help: use `and_then(<f>)` instead | |
| | | |
| LL ~ let _ = opt.and_then(|x| { | |
| LL | | |
| LL | Some(x + 1) | |
| LL | } | |
| LL ~ ); | |
| | | |
| error: called `map(<f>).unwrap_or(None)` on an `Option` value | |
| --> tests/ui/map_unwrap_or.rs:41:13 | |
| | | |
| LL | let _ = opt | |
| | _____________^ | |
| LL | | | |
| LL | | .map(|x| Some(x + 1)) | |
| LL | | .unwrap_or(None); | |
| | |________________________^ | |
| | | |
| help: use `and_then(<f>)` instead | |
| | | |
| LL - .map(|x| Some(x + 1)) | |
| LL - .unwrap_or(None); | |
| LL + .and_then(|x| Some(x + 1)); | |
| | | |
| error: called `map(<f>).unwrap_or(<a>)` on an `Option` value | |
| --> tests/ui/map_unwrap_or.rs:53:13 | |
| | | |
| LL | let _ = Some("prefix").map(|p| format!("{}.", p)).unwrap_or(id); | |
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| | | |
| help: use `map_or(<a>, <f>)` instead | |
| | | |
| LL - let _ = Some("prefix").map(|p| format!("{}.", p)).unwrap_or(id); | |
| LL + let _ = Some("prefix").map_or(id, |p| format!("{}.", p)); | |
| | | |
| error: called `map(<f>).unwrap_or_else(<g>)` on an `Option` value | |
| --> tests/ui/map_unwrap_or.rs:58:13 | |
| | | |
| LL | let _ = opt.map(|x| { | |
| | _____________^ | |
| LL | | | |
| LL | | x + 1 | |
| LL | | } | |
| LL | | ).unwrap_or_else(|| 0); | |
| | |__________________________^ | |
| | | |
| help: try | |
| | | |
| LL ~ let _ = opt.map_or_else(|| 0, |x| { | |
| LL + | |
| LL + x + 1 | |
| LL ~ }); | |
| | | |
| error: called `map(<f>).unwrap_or_else(<g>)` on an `Option` value | |
| --> tests/ui/map_unwrap_or.rs:63:13 | |
| | | |
| LL | let _ = opt.map(|x| x + 1) | |
| | _____________^ | |
| LL | | | |
| LL | | .unwrap_or_else(|| | |
| LL | | 0 | |
| LL | | ); | |
| | |_________^ | |
| | | |
| help: try | |
| | | |
| LL ~ let _ = opt.map_or_else(|| | |
| LL ~ 0, |x| x + 1); | |
| | | |
| error: called `map(<f>).unwrap_or(false)` on an `Option` value | |
| --> tests/ui/map_unwrap_or.rs:70:13 | |
| | | |
| 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: called `map(<f>).unwrap_or_else(<g>)` on a `Result` value | |
| --> tests/ui/map_unwrap_or.rs:81:13 | |
| | | |
| LL | let _ = res.map(|x| { | |
| | _____________^ | |
| LL | | | |
| LL | | x + 1 | |
| LL | | } | |
| LL | | ).unwrap_or_else(|_e| 0); | |
| | |____________________________^ | |
| | | |
| help: try | |
| | | |
| LL ~ let _ = res.map_or_else(|_e| 0, |x| { | |
| LL + | |
| LL + x + 1 | |
| LL ~ }); | |
| | | |
| error: called `map(<f>).unwrap_or_else(<g>)` on a `Result` value | |
| --> tests/ui/map_unwrap_or.rs:86:13 | |
| | | |
| LL | let _ = res.map(|x| x + 1) | |
| | _____________^ | |
| LL | | | |
| LL | | .unwrap_or_else(|_e| { | |
| LL | | 0 | |
| LL | | }); | |
| | |__________^ | |
| | | |
| help: try | |
| | | |
| LL ~ let _ = res.map_or_else(|_e| { | |
| LL + 0 | |
| LL ~ }, |x| x + 1); | |
| | | |
| error: called `map(<f>).unwrap_or_else(<g>)` on a `Result` value | |
| --> tests/ui/map_unwrap_or.rs:108:13 | |
| | | |
| LL | let _ = res.map(|x| x + 1).unwrap_or_else(|_e| 0); | |
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `res.map_or_else(|_e| 0, |x| x + 1)` | |
| error: called `map(<f>).unwrap_or(<a>)` on an `Option` value | |
| --> tests/ui/map_unwrap_or.rs:116:13 | |
| | | |
| 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); | |
| | | |
| error: called `map(<f>).unwrap_or(false)` on an `Option` value | |
| --> tests/ui/map_unwrap_or.rs:124:13 | |
| | | |
| 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: called `map(<f>).unwrap_or(<a>)` on an `Option` value | |
| --> tests/ui/map_unwrap_or.rs:161:5 | |
| | | |
| LL | x.map(|y| y.0).unwrap_or(&[]); | |
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| error: called `map(<f>).unwrap_or(<a>)` on an `Option` value | |
| --> tests/ui/map_unwrap_or.rs:167:23 | |
| | | |
| LL | let after_scope = raw.split_once(':').map(|(_, v)| v).unwrap_or(&raw); | |
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| error: aborting due to 17 previous errors | |