2020-08-28 09:10:16 -05:00
|
|
|
error: used unwrap or expect in a function that returns result or option
|
2024-02-17 06:16:29 -06:00
|
|
|
--> tests/ui/unwrap_in_result.rs:22:5
|
2020-08-28 09:10:16 -05:00
|
|
|
|
|
|
|
|
LL | / fn bad_divisible_by_3(i_str: String) -> Result<bool, String> {
|
2023-08-24 14:32:12 -05:00
|
|
|
LL | |
|
2020-08-28 09:10:16 -05:00
|
|
|
LL | | // checks whether a string represents a number divisible by 3
|
|
|
|
LL | | let i = i_str.parse::<i32>().unwrap();
|
|
|
|
... |
|
|
|
|
LL | | }
|
|
|
|
LL | | }
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
= help: unwrap and expect should not be used in a function that returns result or option
|
|
|
|
note: potential non-recoverable error(s)
|
2024-02-17 06:16:29 -06:00
|
|
|
--> tests/ui/unwrap_in_result.rs:25:17
|
2020-08-28 09:10:16 -05:00
|
|
|
|
|
|
|
|
LL | let i = i_str.parse::<i32>().unwrap();
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2022-09-22 11:04:22 -05:00
|
|
|
= note: `-D clippy::unwrap-in-result` implied by `-D warnings`
|
2023-08-01 07:02:21 -05:00
|
|
|
= help: to override `-D warnings` add `#[allow(clippy::unwrap_in_result)]`
|
2020-08-28 09:10:16 -05:00
|
|
|
|
|
|
|
error: used unwrap or expect in a function that returns result or option
|
2024-02-17 06:16:29 -06:00
|
|
|
--> tests/ui/unwrap_in_result.rs:33:5
|
2020-08-28 09:10:16 -05:00
|
|
|
|
|
|
|
|
LL | / fn example_option_expect(i_str: String) -> Option<bool> {
|
2023-08-24 14:32:12 -05:00
|
|
|
LL | |
|
2020-08-28 09:10:16 -05:00
|
|
|
LL | | let i = i_str.parse::<i32>().expect("not a number");
|
|
|
|
LL | | if i % 3 == 0 {
|
2023-08-24 14:32:12 -05:00
|
|
|
... |
|
2020-08-28 09:10:16 -05:00
|
|
|
LL | | None
|
|
|
|
LL | | }
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
= help: unwrap and expect should not be used in a function that returns result or option
|
|
|
|
note: potential non-recoverable error(s)
|
2024-02-17 06:16:29 -06:00
|
|
|
--> tests/ui/unwrap_in_result.rs:35:17
|
2020-08-28 09:10:16 -05:00
|
|
|
|
|
|
|
|
LL | let i = i_str.parse::<i32>().expect("not a number");
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
2024-05-19 10:08:36 -05:00
|
|
|
error: used unwrap or expect in a function that returns result or option
|
|
|
|
--> tests/ui/unwrap_in_result.rs:42:5
|
|
|
|
|
|
|
|
|
LL | / fn in_closure(a: Option<bool>) -> Option<bool> {
|
|
|
|
LL | | let c = || a.unwrap();
|
|
|
|
LL | | Some(c())
|
|
|
|
LL | | }
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
= help: unwrap and expect should not be used in a function that returns result or option
|
|
|
|
note: potential non-recoverable error(s)
|
|
|
|
--> tests/ui/unwrap_in_result.rs:43:20
|
|
|
|
|
|
|
|
|
LL | let c = || a.unwrap();
|
|
|
|
| ^^^^^^^^^^
|
|
|
|
|
|
|
|
error: aborting due to 3 previous errors
|
2020-08-28 09:10:16 -05:00
|
|
|
|