mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-11 07:34:18 +00:00
283 lines
11 KiB
Text
283 lines
11 KiB
Text
error: unnecessary closure used to substitute value for `Option::None`
|
|
--> $DIR/unnecessary_lazy_eval.rs:48:13
|
|
|
|
|
LL | let _ = opt.unwrap_or_else(|| 2);
|
|
| ^^^^--------------------
|
|
| |
|
|
| help: use `unwrap_or(..)` instead: `unwrap_or(2)`
|
|
|
|
|
= note: `-D clippy::unnecessary-lazy-evaluations` implied by `-D warnings`
|
|
|
|
error: unnecessary closure used to substitute value for `Option::None`
|
|
--> $DIR/unnecessary_lazy_eval.rs:49:13
|
|
|
|
|
LL | let _ = opt.unwrap_or_else(|| astronomers_pi);
|
|
| ^^^^---------------------------------
|
|
| |
|
|
| help: use `unwrap_or(..)` instead: `unwrap_or(astronomers_pi)`
|
|
|
|
error: unnecessary closure used to substitute value for `Option::None`
|
|
--> $DIR/unnecessary_lazy_eval.rs:50:13
|
|
|
|
|
LL | let _ = opt.unwrap_or_else(|| ext_str.some_field);
|
|
| ^^^^-------------------------------------
|
|
| |
|
|
| help: use `unwrap_or(..)` instead: `unwrap_or(ext_str.some_field)`
|
|
|
|
error: unnecessary closure used to substitute value for `Option::None`
|
|
--> $DIR/unnecessary_lazy_eval.rs:52:13
|
|
|
|
|
LL | let _ = opt.and_then(|_| ext_opt);
|
|
| ^^^^---------------------
|
|
| |
|
|
| help: use `and(..)` instead: `and(ext_opt)`
|
|
|
|
error: unnecessary closure used to substitute value for `Option::None`
|
|
--> $DIR/unnecessary_lazy_eval.rs:53:13
|
|
|
|
|
LL | let _ = opt.or_else(|| ext_opt);
|
|
| ^^^^-------------------
|
|
| |
|
|
| help: use `or(..)` instead: `or(ext_opt)`
|
|
|
|
error: unnecessary closure used to substitute value for `Option::None`
|
|
--> $DIR/unnecessary_lazy_eval.rs:54:13
|
|
|
|
|
LL | let _ = opt.or_else(|| None);
|
|
| ^^^^----------------
|
|
| |
|
|
| help: use `or(..)` instead: `or(None)`
|
|
|
|
error: unnecessary closure used to substitute value for `Option::None`
|
|
--> $DIR/unnecessary_lazy_eval.rs:55:13
|
|
|
|
|
LL | let _ = opt.get_or_insert_with(|| 2);
|
|
| ^^^^------------------------
|
|
| |
|
|
| help: use `get_or_insert(..)` instead: `get_or_insert(2)`
|
|
|
|
error: unnecessary closure used to substitute value for `Option::None`
|
|
--> $DIR/unnecessary_lazy_eval.rs:56:13
|
|
|
|
|
LL | let _ = opt.ok_or_else(|| 2);
|
|
| ^^^^----------------
|
|
| |
|
|
| help: use `ok_or(..)` instead: `ok_or(2)`
|
|
|
|
error: unnecessary closure used to substitute value for `Option::None`
|
|
--> $DIR/unnecessary_lazy_eval.rs:57:13
|
|
|
|
|
LL | let _ = nested_tuple_opt.unwrap_or_else(|| Some((1, 2)));
|
|
| ^^^^^^^^^^^^^^^^^-------------------------------
|
|
| |
|
|
| help: use `unwrap_or(..)` instead: `unwrap_or(Some((1, 2)))`
|
|
|
|
error: unnecessary closure used with `bool::then`
|
|
--> $DIR/unnecessary_lazy_eval.rs:58:13
|
|
|
|
|
LL | let _ = cond.then(|| astronomers_pi);
|
|
| ^^^^^-----------------------
|
|
| |
|
|
| help: use `then_some(..)` instead: `then_some(astronomers_pi)`
|
|
|
|
error: unnecessary closure used to substitute value for `Option::None`
|
|
--> $DIR/unnecessary_lazy_eval.rs:61:13
|
|
|
|
|
LL | let _ = Some(10).unwrap_or_else(|| 2);
|
|
| ^^^^^^^^^--------------------
|
|
| |
|
|
| help: use `unwrap_or(..)` instead: `unwrap_or(2)`
|
|
|
|
error: unnecessary closure used to substitute value for `Option::None`
|
|
--> $DIR/unnecessary_lazy_eval.rs:62:13
|
|
|
|
|
LL | let _ = Some(10).and_then(|_| ext_opt);
|
|
| ^^^^^^^^^---------------------
|
|
| |
|
|
| help: use `and(..)` instead: `and(ext_opt)`
|
|
|
|
error: unnecessary closure used to substitute value for `Option::None`
|
|
--> $DIR/unnecessary_lazy_eval.rs:63:28
|
|
|
|
|
LL | let _: Option<usize> = None.or_else(|| ext_opt);
|
|
| ^^^^^-------------------
|
|
| |
|
|
| help: use `or(..)` instead: `or(ext_opt)`
|
|
|
|
error: unnecessary closure used to substitute value for `Option::None`
|
|
--> $DIR/unnecessary_lazy_eval.rs:64:13
|
|
|
|
|
LL | let _ = None.get_or_insert_with(|| 2);
|
|
| ^^^^^------------------------
|
|
| |
|
|
| help: use `get_or_insert(..)` instead: `get_or_insert(2)`
|
|
|
|
error: unnecessary closure used to substitute value for `Option::None`
|
|
--> $DIR/unnecessary_lazy_eval.rs:65:35
|
|
|
|
|
LL | let _: Result<usize, usize> = None.ok_or_else(|| 2);
|
|
| ^^^^^----------------
|
|
| |
|
|
| help: use `ok_or(..)` instead: `ok_or(2)`
|
|
|
|
error: unnecessary closure used to substitute value for `Option::None`
|
|
--> $DIR/unnecessary_lazy_eval.rs:66:28
|
|
|
|
|
LL | let _: Option<usize> = None.or_else(|| None);
|
|
| ^^^^^----------------
|
|
| |
|
|
| help: use `or(..)` instead: `or(None)`
|
|
|
|
error: unnecessary closure used to substitute value for `Option::None`
|
|
--> $DIR/unnecessary_lazy_eval.rs:69:13
|
|
|
|
|
LL | let _ = deep.0.unwrap_or_else(|| 2);
|
|
| ^^^^^^^--------------------
|
|
| |
|
|
| help: use `unwrap_or(..)` instead: `unwrap_or(2)`
|
|
|
|
error: unnecessary closure used to substitute value for `Option::None`
|
|
--> $DIR/unnecessary_lazy_eval.rs:70:13
|
|
|
|
|
LL | let _ = deep.0.and_then(|_| ext_opt);
|
|
| ^^^^^^^---------------------
|
|
| |
|
|
| help: use `and(..)` instead: `and(ext_opt)`
|
|
|
|
error: unnecessary closure used to substitute value for `Option::None`
|
|
--> $DIR/unnecessary_lazy_eval.rs:71:13
|
|
|
|
|
LL | let _ = deep.0.or_else(|| None);
|
|
| ^^^^^^^----------------
|
|
| |
|
|
| help: use `or(..)` instead: `or(None)`
|
|
|
|
error: unnecessary closure used to substitute value for `Option::None`
|
|
--> $DIR/unnecessary_lazy_eval.rs:72:13
|
|
|
|
|
LL | let _ = deep.0.get_or_insert_with(|| 2);
|
|
| ^^^^^^^------------------------
|
|
| |
|
|
| help: use `get_or_insert(..)` instead: `get_or_insert(2)`
|
|
|
|
error: unnecessary closure used to substitute value for `Option::None`
|
|
--> $DIR/unnecessary_lazy_eval.rs:73:13
|
|
|
|
|
LL | let _ = deep.0.ok_or_else(|| 2);
|
|
| ^^^^^^^----------------
|
|
| |
|
|
| help: use `ok_or(..)` instead: `ok_or(2)`
|
|
|
|
error: unnecessary closure used to substitute value for `Option::None`
|
|
--> $DIR/unnecessary_lazy_eval.rs:96:28
|
|
|
|
|
LL | let _: Option<usize> = None.or_else(|| Some(3));
|
|
| ^^^^^-------------------
|
|
| |
|
|
| help: use `or(..)` instead: `or(Some(3))`
|
|
|
|
error: unnecessary closure used to substitute value for `Option::None`
|
|
--> $DIR/unnecessary_lazy_eval.rs:97:13
|
|
|
|
|
LL | let _ = deep.0.or_else(|| Some(3));
|
|
| ^^^^^^^-------------------
|
|
| |
|
|
| help: use `or(..)` instead: `or(Some(3))`
|
|
|
|
error: unnecessary closure used to substitute value for `Option::None`
|
|
--> $DIR/unnecessary_lazy_eval.rs:98:13
|
|
|
|
|
LL | let _ = opt.or_else(|| Some(3));
|
|
| ^^^^-------------------
|
|
| |
|
|
| help: use `or(..)` instead: `or(Some(3))`
|
|
|
|
error: unnecessary closure used to substitute value for `Result::Err`
|
|
--> $DIR/unnecessary_lazy_eval.rs:104:13
|
|
|
|
|
LL | let _ = res2.unwrap_or_else(|_| 2);
|
|
| ^^^^^---------------------
|
|
| |
|
|
| help: use `unwrap_or(..)` instead: `unwrap_or(2)`
|
|
|
|
error: unnecessary closure used to substitute value for `Result::Err`
|
|
--> $DIR/unnecessary_lazy_eval.rs:105:13
|
|
|
|
|
LL | let _ = res2.unwrap_or_else(|_| astronomers_pi);
|
|
| ^^^^^----------------------------------
|
|
| |
|
|
| help: use `unwrap_or(..)` instead: `unwrap_or(astronomers_pi)`
|
|
|
|
error: unnecessary closure used to substitute value for `Result::Err`
|
|
--> $DIR/unnecessary_lazy_eval.rs:106:13
|
|
|
|
|
LL | let _ = res2.unwrap_or_else(|_| ext_str.some_field);
|
|
| ^^^^^--------------------------------------
|
|
| |
|
|
| help: use `unwrap_or(..)` instead: `unwrap_or(ext_str.some_field)`
|
|
|
|
error: unnecessary closure used to substitute value for `Result::Err`
|
|
--> $DIR/unnecessary_lazy_eval.rs:128:35
|
|
|
|
|
LL | let _: Result<usize, usize> = res.and_then(|_| Err(2));
|
|
| ^^^^--------------------
|
|
| |
|
|
| help: use `and(..)` instead: `and(Err(2))`
|
|
|
|
error: unnecessary closure used to substitute value for `Result::Err`
|
|
--> $DIR/unnecessary_lazy_eval.rs:129:35
|
|
|
|
|
LL | let _: Result<usize, usize> = res.and_then(|_| Err(astronomers_pi));
|
|
| ^^^^---------------------------------
|
|
| |
|
|
| help: use `and(..)` instead: `and(Err(astronomers_pi))`
|
|
|
|
error: unnecessary closure used to substitute value for `Result::Err`
|
|
--> $DIR/unnecessary_lazy_eval.rs:130:35
|
|
|
|
|
LL | let _: Result<usize, usize> = res.and_then(|_| Err(ext_str.some_field));
|
|
| ^^^^-------------------------------------
|
|
| |
|
|
| help: use `and(..)` instead: `and(Err(ext_str.some_field))`
|
|
|
|
error: unnecessary closure used to substitute value for `Result::Err`
|
|
--> $DIR/unnecessary_lazy_eval.rs:132:35
|
|
|
|
|
LL | let _: Result<usize, usize> = res.or_else(|_| Ok(2));
|
|
| ^^^^------------------
|
|
| |
|
|
| help: use `or(..)` instead: `or(Ok(2))`
|
|
|
|
error: unnecessary closure used to substitute value for `Result::Err`
|
|
--> $DIR/unnecessary_lazy_eval.rs:133:35
|
|
|
|
|
LL | let _: Result<usize, usize> = res.or_else(|_| Ok(astronomers_pi));
|
|
| ^^^^-------------------------------
|
|
| |
|
|
| help: use `or(..)` instead: `or(Ok(astronomers_pi))`
|
|
|
|
error: unnecessary closure used to substitute value for `Result::Err`
|
|
--> $DIR/unnecessary_lazy_eval.rs:134:35
|
|
|
|
|
LL | let _: Result<usize, usize> = res.or_else(|_| Ok(ext_str.some_field));
|
|
| ^^^^-----------------------------------
|
|
| |
|
|
| help: use `or(..)` instead: `or(Ok(ext_str.some_field))`
|
|
|
|
error: unnecessary closure used to substitute value for `Result::Err`
|
|
--> $DIR/unnecessary_lazy_eval.rs:135:35
|
|
|
|
|
LL | let _: Result<usize, usize> = res.
|
|
| ___________________________________^
|
|
LL | | // some lines
|
|
LL | | // some lines
|
|
LL | | // some lines
|
|
... |
|
|
LL | | // some lines
|
|
LL | | or_else(|_| Ok(ext_str.some_field));
|
|
| |_________----------------------------------^
|
|
| |
|
|
| help: use `or(..)` instead: `or(Ok(ext_str.some_field))`
|
|
|
|
error: aborting due to 34 previous errors
|
|
|